novamov.py 6.8 KB

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