novamov.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..compat import compat_urlparse
  5. from ..utils import (
  6. ExtractorError,
  7. NO_DEFAULT,
  8. encode_dict,
  9. sanitized_Request,
  10. urlencode_postdata,
  11. )
  12. class NovaMovIE(InfoExtractor):
  13. IE_NAME = 'novamov'
  14. IE_DESC = 'NovaMov'
  15. _VALID_URL_TEMPLATE = r'http://(?:(?:www\.)?%(host)s/(?:file|video)/|(?:(?:embed|www)\.)%(host)s/embed\.php\?(?:.*?&)?v=)(?P<id>[a-z\d]{13})'
  16. _VALID_URL = _VALID_URL_TEMPLATE % {'host': 'novamov\.com'}
  17. _HOST = 'www.novamov.com'
  18. _FILE_DELETED_REGEX = r'This file no longer exists on our servers!</h2>'
  19. _FILEKEY_REGEX = r'flashvars\.filekey=(?P<filekey>"?[^"]+"?);'
  20. _TITLE_REGEX = r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>([^<]+)</h3>'
  21. _DESCRIPTION_REGEX = r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>[^<]+</h3><p>([^<]+)</p>'
  22. _URL_TEMPLATE = 'http://%s/video/%s'
  23. _TEST = {
  24. 'url': 'http://www.novamov.com/video/4rurhn9x446jj',
  25. 'md5': '7205f346a52bbeba427603ba10d4b935',
  26. 'info_dict': {
  27. 'id': '4rurhn9x446jj',
  28. 'ext': 'flv',
  29. 'title': 'search engine optimization',
  30. 'description': 'search engine optimization is used to rank the web page in the google search engine'
  31. },
  32. 'skip': '"Invalid token" errors abound (in web interface as well as youtube-dl, there is nothing we can do about it.)'
  33. }
  34. def _real_extract(self, url):
  35. video_id = self._match_id(url)
  36. url = self._URL_TEMPLATE % (self._HOST, video_id)
  37. webpage = self._download_webpage(
  38. url, video_id, 'Downloading video page')
  39. if re.search(self._FILE_DELETED_REGEX, webpage) is not None:
  40. raise ExtractorError('Video %s does not exist' % video_id, expected=True)
  41. def extract_filekey(default=NO_DEFAULT):
  42. filekey = self._search_regex(
  43. self._FILEKEY_REGEX, webpage, 'filekey', default=default)
  44. if filekey is not default and (filekey[0] != '"' or filekey[-1] != '"'):
  45. return self._search_regex(
  46. r'var\s*%s\s*=\s*"([^"]+)"', webpage, 'filekey', default=default)
  47. else:
  48. return filekey
  49. filekey = extract_filekey(default=None)
  50. if not filekey:
  51. fields = self._hidden_inputs(webpage)
  52. post_url = self._search_regex(
  53. r'<form[^>]+action=(["\'])(?P<url>.+?)\1', webpage,
  54. 'post url', default=url, group='url')
  55. if not post_url.startswith('http'):
  56. post_url = compat_urlparse.urljoin(url, post_url)
  57. request = sanitized_Request(
  58. post_url, urlencode_postdata(encode_dict(fields)))
  59. request.add_header('Content-Type', 'application/x-www-form-urlencoded')
  60. request.add_header('Referer', post_url)
  61. webpage = self._download_webpage(
  62. request, video_id, 'Downloading continue to the video page')
  63. filekey = extract_filekey()
  64. title = self._html_search_regex(self._TITLE_REGEX, webpage, 'title', fatal=False)
  65. description = self._html_search_regex(self._DESCRIPTION_REGEX, webpage, 'description', default='', fatal=False)
  66. api_response = self._download_webpage(
  67. 'http://%s/api/player.api.php?key=%s&file=%s' % (self._HOST, filekey, video_id), video_id,
  68. 'Downloading video api response')
  69. response = compat_urlparse.parse_qs(api_response)
  70. if 'error_msg' in response:
  71. raise ExtractorError('%s returned error: %s' % (self.IE_NAME, response['error_msg'][0]), expected=True)
  72. video_url = response['url'][0]
  73. return {
  74. 'id': video_id,
  75. 'url': video_url,
  76. 'title': title,
  77. 'description': description
  78. }
  79. class WholeCloudIE(NovaMovIE):
  80. IE_NAME = 'wholecloud'
  81. IE_DESC = 'WholeCloud'
  82. _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': '(?:wholecloud\.net|movshare\.(?:net|sx|ag))'}
  83. _HOST = 'www.wholecloud.net'
  84. _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<'
  85. _TITLE_REGEX = r'<strong>Title:</strong> ([^<]+)</p>'
  86. _DESCRIPTION_REGEX = r'<strong>Description:</strong> ([^<]+)</p>'
  87. _TEST = {
  88. 'url': 'http://www.wholecloud.net/video/559e28be54d96',
  89. 'md5': 'abd31a2132947262c50429e1d16c1bfd',
  90. 'info_dict': {
  91. 'id': '559e28be54d96',
  92. 'ext': 'flv',
  93. 'title': 'dissapeared image',
  94. 'description': 'optical illusion dissapeared image magic illusion',
  95. }
  96. }
  97. class NowVideoIE(NovaMovIE):
  98. IE_NAME = 'nowvideo'
  99. IE_DESC = 'NowVideo'
  100. _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': 'nowvideo\.(?:to|ch|ec|sx|eu|at|ag|co|li)'}
  101. _HOST = 'www.nowvideo.to'
  102. _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<'
  103. _TITLE_REGEX = r'<h4>([^<]+)</h4>'
  104. _DESCRIPTION_REGEX = r'</h4>\s*<p>([^<]+)</p>'
  105. _TEST = {
  106. 'url': 'http://www.nowvideo.to/video/0mw0yow7b6dxa',
  107. 'md5': 'f8fbbc8add72bd95b7850c6a02fc8817',
  108. 'info_dict': {
  109. 'id': '0mw0yow7b6dxa',
  110. 'ext': 'flv',
  111. 'title': 'youtubedl test video _BaW_jenozKc.mp4',
  112. 'description': 'Description',
  113. }
  114. }
  115. class VideoWeedIE(NovaMovIE):
  116. IE_NAME = 'videoweed'
  117. IE_DESC = 'VideoWeed'
  118. _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': 'videoweed\.(?:es|com)'}
  119. _HOST = 'www.videoweed.es'
  120. _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<'
  121. _TITLE_REGEX = r'<h1 class="text_shadow">([^<]+)</h1>'
  122. _URL_TEMPLATE = 'http://%s/file/%s'
  123. _TEST = {
  124. 'url': 'http://www.videoweed.es/file/b42178afbea14',
  125. 'md5': 'abd31a2132947262c50429e1d16c1bfd',
  126. 'info_dict': {
  127. 'id': 'b42178afbea14',
  128. 'ext': 'flv',
  129. 'title': 'optical illusion dissapeared image magic illusion',
  130. 'description': ''
  131. },
  132. }
  133. class CloudTimeIE(NovaMovIE):
  134. IE_NAME = 'cloudtime'
  135. IE_DESC = 'CloudTime'
  136. _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': 'cloudtime\.to'}
  137. _HOST = 'www.cloudtime.to'
  138. _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<'
  139. _TITLE_REGEX = r'<div[^>]+class=["\']video_det["\'][^>]*>\s*<strong>([^<]+)</strong>'
  140. _TEST = None