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