1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_urlparse
16 class NovaMovIE(InfoExtractor
):
20 _VALID_URL_TEMPLATE
= r
'http://(?:(?:www\.)?%(host)s/(?:file|video)/|(?:(?:embed|www)\.)%(host)s/embed\.php\?(?:.*?&)?v=)(?P<id>[a-z\d]{13})'
21 _VALID_URL
= _VALID_URL_TEMPLATE
% {'host': 'novamov\.com'}
23 _HOST
= 'www.novamov.com'
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>'
29 _URL_TEMPLATE
= 'http://%s/video/%s'
32 'url': 'http://www.novamov.com/video/4rurhn9x446jj',
33 'md5': '7205f346a52bbeba427603ba10d4b935',
35 'id': '4rurhn9x446jj',
37 'title': 'search engine optimization',
38 'description': 'search engine optimization is used to rank the web page in the google search engine'
40 'skip': '"Invalid token" errors abound (in web interface as well as youtube-dl, there is nothing we can do about it.)'
43 def _check_existence(self
, webpage
, video_id
):
44 if re
.search(self
._FILE
_DELETED
_REGEX
, webpage
) is not None:
45 raise ExtractorError('Video %s does not exist' % video_id
, expected
=True)
47 def _real_extract(self
, url
):
48 video_id
= self
._match
_id
(url
)
50 url
= self
._URL
_TEMPLATE
% (self
._HOST
, video_id
)
52 webpage
= self
._download
_webpage
(
53 url
, video_id
, 'Downloading video page')
55 self
._check
_existence
(webpage
, video_id
)
57 def extract_filekey(default
=NO_DEFAULT
):
58 filekey
= self
._search
_regex
(
59 self
._FILEKEY
_REGEX
, webpage
, 'filekey', default
=default
)
60 if filekey
is not default
and (filekey
[0] != '"' or filekey
[-1] != '"'):
61 return self
._search
_regex
(
62 r
'var\s*%s\s*=\s*"([^"]+)"', webpage
, 'filekey', default
=default
)
66 filekey
= extract_filekey(default
=None)
69 fields
= self
._hidden
_inputs
(webpage
)
70 post_url
= self
._search
_regex
(
71 r
'<form[^>]+action=(["\'])(?P
<url
>.+?
)\
1', webpage,
72 'post url
', default=url, group='url
')
73 if not post_url.startswith('http
'):
74 post_url = compat_urlparse.urljoin(url, post_url)
75 request = sanitized_Request(
76 post_url, urlencode_postdata(encode_dict(fields)))
77 request.add_header('Content
-Type
', 'application
/x
-www
-form
-urlencoded
')
78 request.add_header('Referer
', post_url)
79 webpage = self._download_webpage(
80 request, video_id, 'Downloading
continue to the video page
')
81 self._check_existence(webpage, video_id)
83 filekey = extract_filekey()
85 title = self._html_search_regex(self._TITLE_REGEX, webpage, 'title
', fatal=False)
86 description = self._html_search_regex(self._DESCRIPTION_REGEX, webpage, 'description
', default='', fatal=False)
88 api_response = self._download_webpage(
89 'http
://%s/api
/player
.api
.php?key
=%s&file=%s' % (self._HOST, filekey, video_id), video_id,
90 'Downloading video api response
')
92 response = compat_urlparse.parse_qs(api_response)
94 if 'error_msg
' in response:
95 raise ExtractorError('%s returned error
: %s' % (self.IE_NAME, response['error_msg
'][0]), expected=True)
97 video_url = response['url
'][0]
103 'description
': description
107 class WholeCloudIE(NovaMovIE):
108 IE_NAME = 'wholecloud
'
109 IE_DESC = 'WholeCloud
'
111 _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': '(?:wholecloud\.net|movshare\.(?:net|sx|ag))'}
113 _HOST = 'www
.wholecloud
.net
'
115 _FILE_DELETED_REGEX = r'>This
file no longer exists on our servers
.<'
116 _TITLE_REGEX = r'<strong
>Title
:</strong
> ([^
<]+)</p
>'
117 _DESCRIPTION_REGEX = r'<strong
>Description
:</strong
> ([^
<]+)</p
>'
120 'url
': 'http
://www
.wholecloud
.net
/video
/559e28be54d96
',
121 'md5
': 'abd31a2132947262c50429e1d16c1bfd
',
123 'id': '559e28be54d96
',
125 'title
': 'dissapeared image
',
126 'description
': 'optical illusion dissapeared image magic illusion
',
131 class NowVideoIE(NovaMovIE):
135 _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': 'nowvideo\.(?:to|ch|ec|sx|eu|at|ag|co|li)'}
137 _HOST = 'www
.nowvideo
.to
'
139 _FILE_DELETED_REGEX = r'>This
file no longer exists on our servers
.<'
140 _TITLE_REGEX = r'<h4
>([^
<]+)</h4
>'
141 _DESCRIPTION_REGEX = r'</h4
>\s
*<p
>([^
<]+)</p
>'
144 'url
': 'http
://www
.nowvideo
.to
/video
/0mw0yow7b6dxa
',
145 'md5
': 'f8fbbc8add72bd95b7850c6a02fc8817
',
147 'id': '0mw0yow7b6dxa
',
149 'title
': 'youtubedl test video _BaW_jenozKc
.mp4
',
150 'description
': 'Description
',
152 'skip
': 'Video
0mw0yow7b6dxa does
not exist
',
156 class VideoWeedIE(NovaMovIE):
157 IE_NAME = 'videoweed
'
158 IE_DESC = 'VideoWeed
'
160 _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': 'videoweed\.(?:es|com)'}
162 _HOST = 'www
.videoweed
.es
'
164 _FILE_DELETED_REGEX = r'>This
file no longer exists on our servers
.<'
165 _TITLE_REGEX = r'<h1
class="text_shadow">([^
<]+)</h1
>'
166 _URL_TEMPLATE = 'http
://%s/file/%s'
169 'url
': 'http
://www
.videoweed
.es
/file/b42178afbea14
',
170 'md5
': 'abd31a2132947262c50429e1d16c1bfd
',
172 'id': 'b42178afbea14
',
174 'title
': 'optical illusion dissapeared image magic illusion
',
180 class CloudTimeIE(NovaMovIE):
181 IE_NAME = 'cloudtime
'
182 IE_DESC = 'CloudTime
'
184 _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': 'cloudtime\.to'}
186 _HOST = 'www
.cloudtime
.to
'
188 _FILE_DELETED_REGEX = r'>This
file no longer exists on our servers
.<'
189 _TITLE_REGEX = r'<div
[^
>]+class=["\']video_det["\'][^
>]*>\s
*<strong
>([^
<]+)</strong
>'