novamov.py 6.5 KB

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