2015-02-27 19:15:03 +01:00
|
|
|
|
from .common import InfoExtractor
|
2016-04-25 18:15:15 +02:00
|
|
|
|
from ..compat import (
|
2017-04-16 22:24:34 +02:00
|
|
|
|
compat_etree_fromstring,
|
2016-04-25 18:15:15 +02:00
|
|
|
|
compat_parse_qs,
|
|
|
|
|
compat_urllib_parse_unquote,
|
|
|
|
|
compat_urllib_parse_urlparse,
|
|
|
|
|
)
|
2015-02-27 19:15:03 +01:00
|
|
|
|
from ..utils import (
|
2015-09-17 18:59:15 +02:00
|
|
|
|
ExtractorError,
|
2021-12-14 19:09:57 +01:00
|
|
|
|
float_or_none,
|
2015-02-27 19:15:03 +01:00
|
|
|
|
int_or_none,
|
|
|
|
|
qualities,
|
2022-11-07 17:02:42 +01:00
|
|
|
|
smuggle_url,
|
2015-05-13 18:26:30 +02:00
|
|
|
|
unescapeHTML,
|
2022-11-07 17:02:42 +01:00
|
|
|
|
unified_strdate,
|
|
|
|
|
unsmuggle_url,
|
2017-11-28 09:04:51 +01:00
|
|
|
|
urlencode_postdata,
|
2015-02-27 19:15:03 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OdnoklassnikiIE(InfoExtractor):
|
2018-04-08 17:21:21 +02:00
|
|
|
|
_VALID_URL = r'''(?x)
|
|
|
|
|
https?://
|
|
|
|
|
(?:(?:www|m|mobile)\.)?
|
|
|
|
|
(?:odnoklassniki|ok)\.ru/
|
|
|
|
|
(?:
|
2022-11-07 17:02:42 +01:00
|
|
|
|
video(?P<embed>embed)?/|
|
2018-04-08 17:21:21 +02:00
|
|
|
|
web-api/video/moviePlayer/|
|
|
|
|
|
live/|
|
|
|
|
|
dk\?.*?st\.mvId=
|
|
|
|
|
)
|
|
|
|
|
(?P<id>[\d-]+)
|
|
|
|
|
'''
|
2022-08-01 03:23:25 +02:00
|
|
|
|
_EMBED_REGEX = [r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//(?:odnoklassniki|ok)\.ru/videoembed/.+?)\1']
|
2015-02-27 19:15:03 +01:00
|
|
|
|
_TESTS = [{
|
2022-01-31 19:37:07 +01:00
|
|
|
|
'note': 'Coub embedded',
|
|
|
|
|
'url': 'http://ok.ru/video/1484130554189',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '1keok9',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'timestamp': 1545580896,
|
|
|
|
|
'view_count': int,
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'thumbnail': 'https://coub-attachments.akamaized.net/coub_storage/coub/simple/cw_image/c5ac87553bd/608e806a1239c210ab692/1545580913_00026.jpg',
|
2022-01-31 19:37:07 +01:00
|
|
|
|
'title': 'Народная забава',
|
|
|
|
|
'uploader': 'Nevata',
|
|
|
|
|
'upload_date': '20181223',
|
|
|
|
|
'age_limit': 0,
|
|
|
|
|
'uploader_id': 'nevata.s',
|
|
|
|
|
'like_count': int,
|
|
|
|
|
'duration': 8.08,
|
|
|
|
|
'repost_count': int,
|
|
|
|
|
},
|
|
|
|
|
}, {
|
|
|
|
|
'note': 'vk.com embedded',
|
|
|
|
|
'url': 'https://ok.ru/video/3568183087575',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '-165101755_456243749',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'uploader_id': '-165101755',
|
|
|
|
|
'duration': 132,
|
|
|
|
|
'timestamp': 1642869935,
|
|
|
|
|
'upload_date': '20220122',
|
|
|
|
|
'thumbnail': str,
|
|
|
|
|
'title': str,
|
|
|
|
|
'uploader': str,
|
|
|
|
|
},
|
|
|
|
|
}, {
|
2015-05-25 17:22:13 +02:00
|
|
|
|
# metadata in JSON
|
2015-02-27 19:15:03 +01:00
|
|
|
|
'url': 'http://ok.ru/video/20079905452',
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'md5': '5d2b64756e2af296e3b383a0bc02a6aa',
|
2015-02-27 19:15:03 +01:00
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '20079905452',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Культура меняет нас (прекрасный ролик!))',
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'thumbnail': str,
|
2015-02-27 19:15:03 +01:00
|
|
|
|
'duration': 100,
|
2015-08-08 18:08:54 +02:00
|
|
|
|
'upload_date': '20141207',
|
2015-02-27 19:15:03 +01:00
|
|
|
|
'uploader_id': '330537914540',
|
|
|
|
|
'uploader': 'Виталий Добровольский',
|
|
|
|
|
'like_count': int,
|
2015-08-08 18:04:48 +02:00
|
|
|
|
'age_limit': 0,
|
2015-05-25 17:22:13 +02:00
|
|
|
|
},
|
|
|
|
|
}, {
|
|
|
|
|
# metadataUrl
|
2016-04-25 18:15:15 +02:00
|
|
|
|
'url': 'http://ok.ru/video/63567059965189-0?fromTime=5',
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'md5': 'f8c951122516af72e6e6ffdd3c41103b',
|
2015-05-25 17:22:13 +02:00
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '63567059965189-0',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Девушка без комплексов ...',
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'thumbnail': str,
|
2015-05-25 17:22:13 +02:00
|
|
|
|
'duration': 191,
|
2015-08-08 18:08:54 +02:00
|
|
|
|
'upload_date': '20150518',
|
2015-05-25 17:22:13 +02:00
|
|
|
|
'uploader_id': '534380003155',
|
2015-08-08 18:08:54 +02:00
|
|
|
|
'uploader': '☭ Андрей Мещанинов ☭',
|
2015-05-25 17:22:13 +02:00
|
|
|
|
'like_count': int,
|
2015-08-08 18:04:48 +02:00
|
|
|
|
'age_limit': 0,
|
2016-04-25 18:15:15 +02:00
|
|
|
|
'start_time': 5,
|
2015-02-27 19:15:03 +01:00
|
|
|
|
},
|
2015-09-02 18:08:50 +02:00
|
|
|
|
}, {
|
|
|
|
|
# YouTube embed (metadataUrl, provider == USER_YOUTUBE)
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'url': 'https://ok.ru/video/3952212382174',
|
|
|
|
|
'md5': '91749d0bd20763a28d083fa335bbd37a',
|
2015-09-02 18:08:50 +02:00
|
|
|
|
'info_dict': {
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'id': '5axVgHHDBvU',
|
2015-09-02 18:08:50 +02:00
|
|
|
|
'ext': 'mp4',
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'title': 'Youtube-dl 101: What is it and HOW to use it! Full Download Walkthrough and Guide',
|
|
|
|
|
'description': 'md5:b57209eeb9d5c2f20c984dfb58862097',
|
|
|
|
|
'uploader': 'Lod Mer',
|
|
|
|
|
'uploader_id': '575186401502',
|
|
|
|
|
'duration': 1529,
|
2015-09-02 18:08:50 +02:00
|
|
|
|
'age_limit': 0,
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'upload_date': '20210405',
|
|
|
|
|
'comment_count': int,
|
|
|
|
|
'live_status': 'not_live',
|
|
|
|
|
'view_count': int,
|
|
|
|
|
'thumbnail': 'https://i.mycdn.me/i?r=AEHujHvw2RjEbemUCNEorZbxYpb_p_9AcN2FmGik64Krkcmz37YtlY093oAM5-HIEAt7Zi9s0CiBOSDmbngC-I-k&fn=external_8',
|
|
|
|
|
'uploader_url': 'http://www.youtube.com/user/MrKewlkid94',
|
|
|
|
|
'channel_follower_count': int,
|
|
|
|
|
'tags': ['youtube-dl', 'youtube playlists', 'download videos', 'download audio'],
|
|
|
|
|
'channel_id': 'UCVGtvURtEURYHtJFUegdSug',
|
|
|
|
|
'like_count': int,
|
|
|
|
|
'availability': 'public',
|
|
|
|
|
'channel_url': 'https://www.youtube.com/channel/UCVGtvURtEURYHtJFUegdSug',
|
|
|
|
|
'categories': ['Education'],
|
|
|
|
|
'playable_in_embed': True,
|
|
|
|
|
'channel': 'BornToReact',
|
2015-09-02 18:08:50 +02:00
|
|
|
|
},
|
2016-04-25 18:05:47 +02:00
|
|
|
|
}, {
|
|
|
|
|
# YouTube embed (metadata, provider == USER_YOUTUBE, no metadata.movie.title field)
|
|
|
|
|
'url': 'http://ok.ru/video/62036049272859-0',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '62036049272859-0',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'МУЗЫКА ДОЖДЯ .',
|
|
|
|
|
'description': 'md5:6f1867132bd96e33bf53eda1091e8ed0',
|
|
|
|
|
'upload_date': '20120106',
|
|
|
|
|
'uploader_id': '473534735899',
|
|
|
|
|
'uploader': 'МARINA D',
|
|
|
|
|
'age_limit': 0,
|
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
},
|
2017-04-19 01:16:31 +02:00
|
|
|
|
'skip': 'Video has not been found',
|
2021-12-14 19:09:57 +01:00
|
|
|
|
}, {
|
2022-11-07 17:02:42 +01:00
|
|
|
|
# TODO: HTTP Error 400: Bad Request, it only works if there's no cookies when downloading
|
2021-12-14 19:09:57 +01:00
|
|
|
|
'note': 'Only available in mobile webpage',
|
|
|
|
|
'url': 'https://m.ok.ru/video/2361249957145',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '2361249957145',
|
2022-11-07 17:02:42 +01:00
|
|
|
|
'ext': 'mp4',
|
2021-12-14 19:09:57 +01:00
|
|
|
|
'title': 'Быковское крещение',
|
|
|
|
|
'duration': 3038.181,
|
|
|
|
|
},
|
2015-02-27 19:15:03 +01:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://ok.ru/web-api/video/moviePlayer/20079905452',
|
|
|
|
|
'only_matching': True,
|
2015-09-01 10:34:05 +02:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.ok.ru/video/20648036891',
|
|
|
|
|
'only_matching': True,
|
2015-10-18 20:11:16 +02:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://www.ok.ru/videoembed/20648036891',
|
|
|
|
|
'only_matching': True,
|
2016-01-28 17:56:49 +01:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://m.ok.ru/video/20079905452',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://mobile.ok.ru/video/20079905452',
|
|
|
|
|
'only_matching': True,
|
2018-01-08 15:53:03 +01:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://www.ok.ru/live/484531969818',
|
|
|
|
|
'only_matching': True,
|
2018-04-08 17:13:00 +02:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://m.ok.ru/dk?st.cmd=movieLayer&st.discId=863789452017&st.retLoc=friend&st.rtu=%2Fdk%3Fst.cmd%3DfriendMovies%26st.mode%3Down%26st.mrkId%3D%257B%2522uploadedMovieMarker%2522%253A%257B%2522marker%2522%253A%25221519410114503%2522%252C%2522hasMore%2522%253Atrue%257D%252C%2522sharedMovieMarker%2522%253A%257B%2522marker%2522%253Anull%252C%2522hasMore%2522%253Afalse%257D%257D%26st.friendId%3D561722190321%26st.frwd%3Don%26_prevCmd%3DfriendMovies%26tkn%3D7257&st.discType=MOVIE&st.mvId=863789452017&_prevCmd=friendMovies&tkn=3648#lst#',
|
|
|
|
|
'only_matching': True,
|
2019-01-20 09:15:01 +01:00
|
|
|
|
}, {
|
|
|
|
|
# Paid video
|
|
|
|
|
'url': 'https://ok.ru/video/954886983203',
|
|
|
|
|
'only_matching': True,
|
2022-11-07 17:02:42 +01:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://ok.ru/videoembed/2932705602075',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '2932705602075',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'thumbnail': 'https://i.mycdn.me/videoPreview?id=1369902483995&type=37&idx=2&tkn=fqlnoQD_xwq5ovIlKfgNyU08qmM&fn=external_8',
|
|
|
|
|
'title': 'Boosty для тебя!',
|
|
|
|
|
'uploader_id': '597811038747',
|
|
|
|
|
'like_count': 0,
|
|
|
|
|
'duration': 35,
|
|
|
|
|
},
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
_WEBPAGE_TESTS = [{
|
|
|
|
|
'url': 'https://boosty.to/ikakprosto/posts/56cedaca-b56a-4dfd-b3ed-98c79cfa0167',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '3950343629563',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'thumbnail': 'https://i.mycdn.me/videoPreview?id=2776238394107&type=37&idx=11&tkn=F3ejkUFcpuI4DnMRxrDGcH5YcmM&fn=external_8',
|
|
|
|
|
'title': 'Заяц Бусти.mp4',
|
|
|
|
|
'uploader_id': '571368965883',
|
|
|
|
|
'like_count': 0,
|
|
|
|
|
'duration': 10444,
|
|
|
|
|
},
|
2015-02-27 19:15:03 +01:00
|
|
|
|
}]
|
|
|
|
|
|
2022-11-07 17:02:42 +01:00
|
|
|
|
@classmethod
|
|
|
|
|
def _extract_embed_urls(cls, url, webpage):
|
|
|
|
|
for x in super()._extract_embed_urls(url, webpage):
|
|
|
|
|
yield smuggle_url(x, {'referrer': url})
|
|
|
|
|
|
2015-02-27 19:15:03 +01:00
|
|
|
|
def _real_extract(self, url):
|
2021-12-14 19:09:57 +01:00
|
|
|
|
try:
|
|
|
|
|
return self._extract_desktop(url)
|
|
|
|
|
except ExtractorError as e:
|
|
|
|
|
try:
|
|
|
|
|
return self._extract_mobile(url)
|
|
|
|
|
except ExtractorError:
|
|
|
|
|
# error message of desktop webpage is in English
|
|
|
|
|
raise e
|
|
|
|
|
|
|
|
|
|
def _extract_desktop(self, url):
|
2016-04-25 18:15:15 +02:00
|
|
|
|
start_time = int_or_none(compat_parse_qs(
|
|
|
|
|
compat_urllib_parse_urlparse(url).query).get('fromTime', [None])[0])
|
|
|
|
|
|
2022-11-07 17:02:42 +01:00
|
|
|
|
url, smuggled = unsmuggle_url(url, {})
|
|
|
|
|
video_id, is_embed = self._match_valid_url(url).group('id', 'embed')
|
|
|
|
|
mode = 'videoembed' if is_embed else 'video'
|
2015-02-27 19:15:03 +01:00
|
|
|
|
|
2015-05-25 17:27:43 +02:00
|
|
|
|
webpage = self._download_webpage(
|
2022-11-07 17:02:42 +01:00
|
|
|
|
f'https://ok.ru/{mode}/{video_id}', video_id,
|
|
|
|
|
note='Downloading desktop webpage',
|
|
|
|
|
headers={'Referer': smuggled['referrer']} if smuggled.get('referrer') else {})
|
2015-02-27 19:15:03 +01:00
|
|
|
|
|
2015-09-17 18:59:15 +02:00
|
|
|
|
error = self._search_regex(
|
|
|
|
|
r'[^>]+class="vp_video_stub_txt"[^>]*>([^<]+)<',
|
|
|
|
|
webpage, 'error', default=None)
|
2022-11-07 17:02:42 +01:00
|
|
|
|
# Direct link from boosty
|
|
|
|
|
if (error == 'The author of this video has not been found or is blocked'
|
|
|
|
|
and not smuggled.get('referrer') and mode == 'videoembed'):
|
|
|
|
|
return self._extract_desktop(smuggle_url(url, {'referrer': 'https://boosty.to'}))
|
|
|
|
|
elif error:
|
2015-09-17 18:59:15 +02:00
|
|
|
|
raise ExtractorError(error, expected=True)
|
|
|
|
|
|
2015-02-27 19:15:03 +01:00
|
|
|
|
player = self._parse_json(
|
2015-05-13 18:26:30 +02:00
|
|
|
|
unescapeHTML(self._search_regex(
|
2015-09-02 17:38:56 +02:00
|
|
|
|
r'data-options=(?P<quote>["\'])(?P<player>{.+?%s.+?})(?P=quote)' % video_id,
|
|
|
|
|
webpage, 'player', group='player')),
|
2015-02-27 19:15:03 +01:00
|
|
|
|
video_id)
|
|
|
|
|
|
2022-01-31 19:37:07 +01:00
|
|
|
|
# embedded external player
|
|
|
|
|
if player.get('isExternalPlayer') and player.get('url'):
|
|
|
|
|
return self.url_result(player['url'])
|
|
|
|
|
|
2015-05-25 17:22:13 +02:00
|
|
|
|
flashvars = player['flashvars']
|
|
|
|
|
|
|
|
|
|
metadata = flashvars.get('metadata')
|
|
|
|
|
if metadata:
|
|
|
|
|
metadata = self._parse_json(metadata, video_id)
|
|
|
|
|
else:
|
2017-11-28 09:04:51 +01:00
|
|
|
|
data = {}
|
|
|
|
|
st_location = flashvars.get('location')
|
|
|
|
|
if st_location:
|
|
|
|
|
data['st.location'] = st_location
|
2015-05-25 17:22:13 +02:00
|
|
|
|
metadata = self._download_json(
|
2015-07-17 19:45:00 +02:00
|
|
|
|
compat_urllib_parse_unquote(flashvars['metadataUrl']),
|
2017-11-28 09:04:51 +01:00
|
|
|
|
video_id, 'Downloading metadata JSON',
|
|
|
|
|
data=urlencode_postdata(data))
|
2015-02-27 19:15:03 +01:00
|
|
|
|
|
|
|
|
|
movie = metadata['movie']
|
2016-04-25 18:05:47 +02:00
|
|
|
|
|
|
|
|
|
# Some embedded videos may not contain title in movie dict (e.g.
|
|
|
|
|
# http://ok.ru/video/62036049272859-0) thus we allow missing title
|
|
|
|
|
# here and it's going to be extracted later by an extractor that
|
|
|
|
|
# will process the actual embed.
|
|
|
|
|
provider = metadata.get('provider')
|
|
|
|
|
title = movie['title'] if provider == 'UPLOADED_ODKL' else movie.get('title')
|
|
|
|
|
|
2015-02-27 19:15:03 +01:00
|
|
|
|
thumbnail = movie.get('poster')
|
|
|
|
|
duration = int_or_none(movie.get('duration'))
|
|
|
|
|
|
|
|
|
|
author = metadata.get('author', {})
|
|
|
|
|
uploader_id = author.get('id')
|
|
|
|
|
uploader = author.get('name')
|
|
|
|
|
|
|
|
|
|
upload_date = unified_strdate(self._html_search_meta(
|
2015-05-25 17:22:13 +02:00
|
|
|
|
'ya:ovs:upload_date', webpage, 'upload date', default=None))
|
2015-02-27 19:15:03 +01:00
|
|
|
|
|
|
|
|
|
age_limit = None
|
|
|
|
|
adult = self._html_search_meta(
|
2015-05-25 17:22:13 +02:00
|
|
|
|
'ya:ovs:adult', webpage, 'age limit', default=None)
|
2015-02-27 19:15:03 +01:00
|
|
|
|
if adult:
|
|
|
|
|
age_limit = 18 if adult == 'true' else 0
|
|
|
|
|
|
|
|
|
|
like_count = int_or_none(metadata.get('likeCount'))
|
|
|
|
|
|
2015-09-02 18:08:50 +02:00
|
|
|
|
info = {
|
2015-02-27 19:15:03 +01:00
|
|
|
|
'id': video_id,
|
|
|
|
|
'title': title,
|
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
|
'duration': duration,
|
|
|
|
|
'upload_date': upload_date,
|
|
|
|
|
'uploader': uploader,
|
|
|
|
|
'uploader_id': uploader_id,
|
|
|
|
|
'like_count': like_count,
|
|
|
|
|
'age_limit': age_limit,
|
2016-04-25 18:15:15 +02:00
|
|
|
|
'start_time': start_time,
|
2015-02-27 19:15:03 +01:00
|
|
|
|
}
|
2015-09-02 18:08:50 +02:00
|
|
|
|
|
2022-01-31 19:37:07 +01:00
|
|
|
|
# pladform
|
|
|
|
|
if provider == 'OPEN_GRAPH':
|
|
|
|
|
info.update({
|
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
|
'url': movie['contentId'],
|
|
|
|
|
})
|
|
|
|
|
return info
|
|
|
|
|
|
2016-04-25 18:05:47 +02:00
|
|
|
|
if provider == 'USER_YOUTUBE':
|
2015-09-02 18:08:50 +02:00
|
|
|
|
info.update({
|
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
|
'url': movie['contentId'],
|
|
|
|
|
})
|
|
|
|
|
return info
|
|
|
|
|
|
2018-01-08 15:53:03 +01:00
|
|
|
|
assert title
|
|
|
|
|
if provider == 'LIVE_TV_APP':
|
2021-12-15 17:00:46 +01:00
|
|
|
|
info['title'] = title
|
2018-01-08 15:53:03 +01:00
|
|
|
|
|
2022-11-07 17:02:42 +01:00
|
|
|
|
quality = qualities(('4', '0', '1', '2', '3', '5', '6', '7'))
|
2015-09-02 18:08:50 +02:00
|
|
|
|
|
|
|
|
|
formats = [{
|
|
|
|
|
'url': f['url'],
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'format_id': f['name'],
|
|
|
|
|
} for f in metadata['videos']]
|
2017-04-16 22:24:34 +02:00
|
|
|
|
|
|
|
|
|
m3u8_url = metadata.get('hlsManifestUrl')
|
|
|
|
|
if m3u8_url:
|
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
|
m3u8_url, video_id, 'mp4', 'm3u8_native',
|
|
|
|
|
m3u8_id='hls', fatal=False))
|
|
|
|
|
|
|
|
|
|
dash_manifest = metadata.get('metadataEmbedded')
|
|
|
|
|
if dash_manifest:
|
|
|
|
|
formats.extend(self._parse_mpd_formats(
|
|
|
|
|
compat_etree_fromstring(dash_manifest), 'mpd'))
|
|
|
|
|
|
|
|
|
|
for fmt in formats:
|
|
|
|
|
fmt_type = self._search_regex(
|
|
|
|
|
r'\btype[/=](\d)', fmt['url'],
|
|
|
|
|
'format type', default=None)
|
|
|
|
|
if fmt_type:
|
|
|
|
|
fmt['quality'] = quality(fmt_type)
|
|
|
|
|
|
2018-01-08 15:53:03 +01:00
|
|
|
|
# Live formats
|
|
|
|
|
m3u8_url = metadata.get('hlsMasterPlaylistUrl')
|
|
|
|
|
if m3u8_url:
|
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
2021-05-22 20:28:11 +02:00
|
|
|
|
m3u8_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
|
2018-01-08 15:53:03 +01:00
|
|
|
|
rtmp_url = metadata.get('rtmpUrl')
|
|
|
|
|
if rtmp_url:
|
|
|
|
|
formats.append({
|
|
|
|
|
'url': rtmp_url,
|
|
|
|
|
'format_id': 'rtmp',
|
|
|
|
|
'ext': 'flv',
|
|
|
|
|
})
|
|
|
|
|
|
2019-01-20 09:15:01 +01:00
|
|
|
|
if not formats:
|
|
|
|
|
payment_info = metadata.get('paymentInfo')
|
|
|
|
|
if payment_info:
|
2021-04-17 02:09:58 +02:00
|
|
|
|
self.raise_no_formats('This video is paid, subscribe to download it', expected=True)
|
2019-01-20 09:15:01 +01:00
|
|
|
|
|
2015-09-02 18:08:50 +02:00
|
|
|
|
info['formats'] = formats
|
|
|
|
|
return info
|
2021-12-14 19:09:57 +01:00
|
|
|
|
|
|
|
|
|
def _extract_mobile(self, url):
|
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
|
|
|
|
|
webpage = self._download_webpage(
|
|
|
|
|
'http://m.ok.ru/video/%s' % video_id, video_id,
|
|
|
|
|
note='Downloading mobile webpage')
|
|
|
|
|
|
|
|
|
|
error = self._search_regex(
|
|
|
|
|
r'видео</a>\s*<div\s+class="empty">(.+?)</div>',
|
|
|
|
|
webpage, 'error', default=None)
|
|
|
|
|
if error:
|
|
|
|
|
raise ExtractorError(error, expected=True)
|
|
|
|
|
|
|
|
|
|
json_data = self._search_regex(
|
|
|
|
|
r'data-video="(.+?)"', webpage, 'json data')
|
|
|
|
|
json_data = self._parse_json(unescapeHTML(json_data), video_id) or {}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'id': video_id,
|
|
|
|
|
'title': json_data.get('videoName'),
|
|
|
|
|
'duration': float_or_none(json_data.get('videoDuration'), scale=1000),
|
|
|
|
|
'thumbnail': json_data.get('videoPosterSrc'),
|
|
|
|
|
'formats': [{
|
|
|
|
|
'format_id': 'mobile',
|
|
|
|
|
'url': json_data.get('videoSrc'),
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
}]
|
|
|
|
|
}
|