1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
4 from ..compat
import compat_b64decode
13 class SharedBaseIE(InfoExtractor
):
14 def _real_extract(self
, url
):
15 video_id
= self
._match
_id
(url
)
17 webpage
, urlh
= self
._download
_webpage
_handle
(url
, video_id
)
19 if self
._FILE
_NOT
_FOUND
in webpage
:
21 'Video %s does not exist' % video_id
, expected
=True)
23 video_url
= self
._extract
_video
_url
(webpage
, video_id
, url
)
25 title
= compat_b64decode(self
._html
_search
_meta
(
26 'full:title', webpage
, 'title')).decode('utf-8')
27 filesize
= int_or_none(self
._html
_search
_meta
(
28 'full:size', webpage
, 'file size', fatal
=False))
39 class SharedIE(SharedBaseIE
):
41 _VALID_URL
= r
'https?://shared\.sx/(?P<id>[\da-z]{10})'
42 _FILE_NOT_FOUND
= '>File does not exist<'
45 'url': 'http://shared.sx/0060718775',
46 'md5': '106fefed92a8a2adb8c98e6a0652f49b',
55 def _extract_video_url(self
, webpage
, video_id
, url
):
56 download_form
= self
._hidden
_inputs
(webpage
)
58 video_page
= self
._download
_webpage
(
59 url
, video_id
, 'Downloading video page',
60 data
=urlencode_postdata(download_form
),
62 'Content-Type': 'application/x-www-form-urlencoded',
66 video_url
= self
._html
_search
_regex
(
67 r
'data-url=(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1',
68 video_page, 'video URL
', group='url
')
73 class VivoIE(SharedBaseIE):
75 _VALID_URL = r'https?
://vivo\
.sx
/(?P
<id>[\da
-z
]{10}
)'
76 _FILE_NOT_FOUND = '>The
file you have requested does
not exists
or has been removed
'
79 'url
': 'http
://vivo
.sx
/d7ddda0e78
',
80 'md5
': '15b3af41be0b4fe01f4df075c2678b2c
',
89 def _extract_video_url(self, webpage, video_id, *args):
90 def decode_url(encoded_url):
91 return compat_b64decode(encoded_url).decode('utf
-8')
93 stream_url = url_or_none(decode_url(self._search_regex(
94 r'data
-stream\s
*=\s
*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage,
95 'stream url', default=None, group='url')))
98 return self._parse_json(
100 r'InitializeStream\s*\(\s*(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1',
101 webpage, 'stream
', group='url
'),
102 video_id, transform_source=decode_url)[0]