1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..compat import compat_urlparse
15 class NovaMovIE(InfoExtractor):
19 _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})'
20 _VALID_URL = _VALID_URL_TEMPLATE % {'host': 'novamov\.com'}
22 _HOST = 'www.novamov.com'
24 _FILE_DELETED_REGEX = r'This file no longer exists on our servers!</h2>'
25 _FILEKEY_REGEX = r'flashvars\.filekey=(?P<filekey>"?[^"]+"?);'
26 _TITLE_REGEX = r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>([^<]+)</h3>'
27 _DESCRIPTION_REGEX = r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>[^<]+</h3><p>([^<]+)</p>'
28 _URL_TEMPLATE = 'http://%s/video/%s'
31 'url': 'http://www.novamov.com/video/4rurhn9x446jj',
32 'md5': '7205f346a52bbeba427603ba10d4b935',
34 'id': '4rurhn9x446jj',
36 'title': 'search engine optimization',
37 'description': 'search engine optimization is used to rank the web page in the google search engine'
39 'skip': '"Invalid token" errors abound (in web interface as well as youtube-dl, there is nothing we can do about it.)'
42 def _check_existence(self, webpage, video_id):
43 if re.search(self._FILE_DELETED_REGEX, webpage) is not None:
44 raise ExtractorError('Video %s does not exist' % video_id, expected=True)
46 def _real_extract(self, url):
47 video_id = self._match_id(url)
49 url = self._URL_TEMPLATE % (self._HOST, video_id)
51 webpage = self._download_webpage(
52 url, video_id, 'Downloading video page')
54 self._check_existence(webpage, video_id)
56 def extract_filekey(default=NO_DEFAULT):
57 filekey = self._search_regex(
58 self._FILEKEY_REGEX, webpage, 'filekey', default=default)
59 if filekey is not default and (filekey[0] != '"' or filekey[-1] != '"'):
60 return self._search_regex(
61 r'var\s+%s\s*=\s*"([^"]+)"' % re.escape(filekey), webpage, 'filekey', default=default)
65 filekey = extract_filekey(default=None)
68 fields = self._hidden_inputs(webpage)
69 post_url = self._search_regex(
70 r'<form[^>]+action=(["\'])(?P<url>.+?)\1', webpage,
71 'post url', default=url, group='url')
72 if not post_url.startswith('http'):
73 post_url = compat_urlparse.urljoin(url, post_url)
74 request = sanitized_Request(
75 post_url, urlencode_postdata(fields))
76 request.add_header('Content-Type', 'application/x-www-form-urlencoded')
77 request.add_header('Referer', post_url)
78 webpage = self._download_webpage(
79 request, video_id, 'Downloading continue to the video page')
80 self._check_existence(webpage, video_id)
82 filekey = extract_filekey()
84 title = self._html_search_regex(self._TITLE_REGEX, webpage, 'title')
85 description = self._html_search_regex(self._DESCRIPTION_REGEX, webpage, 'description', default='', fatal=False)
87 api_response = self._download_webpage(
88 'http://%s/api/player.api.php?key=%s&file=%s' % (self._HOST, filekey, video_id), video_id,
89 'Downloading video api response')
91 response = compat_urlparse.parse_qs(api_response)
93 if 'error_msg' in response:
94 raise ExtractorError('%s returned error: %s' % (self.IE_NAME, response['error_msg'][0]), expected=True)
96 video_url = response['url'][0]
102 'description': description
106 class WholeCloudIE(NovaMovIE):
107 IE_NAME = 'wholecloud'
108 IE_DESC = 'WholeCloud'
110 _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': '(?:wholecloud\.net|movshare\.(?:net|sx|ag))'}
112 _HOST = 'www.wholecloud.net'
114 _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<'
115 _TITLE_REGEX = r'<strong>Title:</strong> ([^<]+)</p>'
116 _DESCRIPTION_REGEX = r'<strong>Description:</strong> ([^<]+)</p>'
119 'url': 'http://www.wholecloud.net/video/559e28be54d96',
120 'md5': 'abd31a2132947262c50429e1d16c1bfd',
122 'id': '559e28be54d96',
124 'title': 'dissapeared image',
125 'description': 'optical illusion dissapeared image magic illusion',
130 class NowVideoIE(NovaMovIE):
134 _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': 'nowvideo\.(?:to|ch|ec|sx|eu|at|ag|co|li)'}
136 _HOST = 'www.nowvideo.to'
138 _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<'
139 _TITLE_REGEX = r'<h4>([^<]+)</h4>'
140 _DESCRIPTION_REGEX = r'</h4>\s*<p>([^<]+)</p>'
143 'url': 'http://www.nowvideo.sx/video/f1d6fce9a968b',
144 'md5': '12c82cad4f2084881d8bc60ee29df092',
146 'id': 'f1d6fce9a968b',
148 'title': 'youtubedl test video BaWjenozKc',
149 'description': 'Description',
154 class VideoWeedIE(NovaMovIE):
155 IE_NAME = 'videoweed'
156 IE_DESC = 'VideoWeed'
158 _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': 'videoweed\.(?:es|com)'}
160 _HOST = 'www.videoweed.es'
162 _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<'
163 _TITLE_REGEX = r'<h1 class="text_shadow">([^<]+)</h1>'
164 _URL_TEMPLATE = 'http://%s/file/%s'
167 'url': 'http://www.videoweed.es/file/b42178afbea14',
168 'md5': 'abd31a2132947262c50429e1d16c1bfd',
170 'id': 'b42178afbea14',
172 'title': 'optical illusion dissapeared image magic illusion',
178 class CloudTimeIE(NovaMovIE):
179 IE_NAME = 'cloudtime'
180 IE_DESC = 'CloudTime'
182 _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': 'cloudtime\.to'}
184 _HOST = 'www.cloudtime.to'
186 _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<'
187 _TITLE_REGEX = r'<div[^>]+class=["\']video_det["\'][^>]*>\s*<strong>([^<]+)</strong>'