[vivo] added ROT47 to utils; updated stream url decoding; updated test video
This commit is contained in:
parent
9e4e864639
commit
9efe794fb9
@ -1,7 +1,10 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_b64decode
|
from ..compat import (
|
||||||
|
compat_b64decode,
|
||||||
|
compat_urllib_parse_unquote_plus
|
||||||
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
determine_ext,
|
determine_ext,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
@ -10,6 +13,7 @@ from ..utils import (
|
|||||||
parse_filesize,
|
parse_filesize,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
|
rot47
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -85,13 +89,13 @@ class VivoIE(SharedBaseIE):
|
|||||||
_FILE_NOT_FOUND = '>The file you have requested does not exists or has been removed'
|
_FILE_NOT_FOUND = '>The file you have requested does not exists or has been removed'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://vivo.sx/d7ddda0e78',
|
'url': 'https://vivo.sx/5ec5b4cd00',
|
||||||
'md5': '15b3af41be0b4fe01f4df075c2678b2c',
|
'md5': 'b95282602513086f5b71aae4cd043a0c',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'd7ddda0e78',
|
'id': '5ec5b4cd00',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Chicken',
|
'title': 'big_buck_bunny_480p_surround-fix',
|
||||||
'filesize': 515659,
|
'filesize': 68270000,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,15 +117,12 @@ class VivoIE(SharedBaseIE):
|
|||||||
|
|
||||||
def _extract_video_url(self, webpage, video_id, url):
|
def _extract_video_url(self, webpage, video_id, url):
|
||||||
def decode_url(encoded_url):
|
def decode_url(encoded_url):
|
||||||
return compat_b64decode(encoded_url).decode('utf-8')
|
return rot47(compat_urllib_parse_unquote_plus(encoded_url))
|
||||||
|
|
||||||
|
stream_url = self._search_regex(
|
||||||
|
r'InitializeStream\s*\(\{[\s\S]*(source\:[\s]\')(?P<url>[\s\S\:]+?)(\',\s*)', webpage,
|
||||||
|
'stream url', default=None, group='url')
|
||||||
|
|
||||||
stream_url = url_or_none(decode_url(self._search_regex(
|
|
||||||
r'data-stream\s*=\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage,
|
|
||||||
'stream url', default=None, group='url')))
|
|
||||||
if stream_url:
|
if stream_url:
|
||||||
return stream_url
|
return url_or_none(decode_url(stream_url))
|
||||||
return self._parse_json(
|
return None
|
||||||
self._search_regex(
|
|
||||||
r'InitializeStream\s*\(\s*(["\'])(?P<url>(?:(?!\1).)+)\1',
|
|
||||||
webpage, 'stream', group='url'),
|
|
||||||
video_id, transform_source=decode_url)[0]
|
|
||||||
|
@ -5594,3 +5594,15 @@ def random_birthday(year_field, month_field, day_field):
|
|||||||
month_field: str(random_date.month),
|
month_field: str(random_date.month),
|
||||||
day_field: str(random_date.day),
|
day_field: str(random_date.day),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# source: https://rot47.net/_py/rot47.txt
|
||||||
|
def rot47(s):
|
||||||
|
x = []
|
||||||
|
for i in range(len(s)):
|
||||||
|
j = ord(s[i])
|
||||||
|
if j >= 33 and j <= 126:
|
||||||
|
x.append(chr(33 + ((j + 14) % 94)))
|
||||||
|
else:
|
||||||
|
x.append(s[i])
|
||||||
|
return ''.join(x)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user