]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/yapfiles.py
3 from .common
import InfoExtractor
13 class YapFilesIE(InfoExtractor
):
14 _YAPFILES_URL
= r
'//(?:(?:www|api)\.)?yapfiles\.ru/get_player/*\?.*?\bv=(?P<id>\w+)'
15 _VALID_URL
= r
'https?:%s' % _YAPFILES_URL
18 'url': 'http://www.yapfiles.ru/get_player/?v=vMDE1NjcyNDUt0413',
19 'md5': '2db19e2bfa2450568868548a1aa1956c',
21 'id': 'vMDE1NjcyNDUt0413',
23 'title': 'Самый худший пароль WIFI',
24 'thumbnail': r
're:^https?://.*\.jpg$',
29 'url': 'https://api.yapfiles.ru/get_player/?uid=video_player_1872528&plroll=1&adv=1&v=vMDE4NzI1Mjgt690b',
30 'only_matching': True,
34 def _extract_urls(webpage
):
35 return [unescapeHTML(mobj
.group('url')) for mobj
in re
.finditer(
36 r
'<iframe\b[^>]+\bsrc=(["\'])(?P
<url
>(?
:https?
:)?
%s.*?
)\
1'
37 % YapFilesIE._YAPFILES_URL, webpage)]
39 def _real_extract(self, url):
40 video_id = self._match_id(url)
42 webpage = self._download_webpage(url, video_id, fatal=False)
47 player_url = self._search_regex(
48 r'player\
.init\s
*\
(\s
*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage,
49 'player url', default=None, group='url')
52 player_url = 'http://api.yapfiles.ru/load/%s/' % video_id
54 'md5': 'ded5f369be61b8ae5f88e2eeb2f3caff',
59 player = self._download_json(
60 player_url, video_id, query=query)['player']
62 playlist_url = player['playlist']
63 title = player['title']
64 thumbnail = player.get('poster')
66 if title == 'Ролик удален' or 'deleted.jpg' in (thumbnail or ''):
68 'Video %s has been removed' % video_id, expected=True)
70 playlist = self._download_json(
71 playlist_url, video_id)['player']['main']
73 hd_height = int_or_none(player.get('hd'))
75 QUALITIES = ('sd', 'hd')
76 quality_key = qualities(QUALITIES)
78 for format_id in QUALITIES:
79 is_hd = format_id == 'hd'
80 format_url = url_or_none(playlist.get(
81 'file%s' % ('_hd' if is_hd else '')))
86 'format_id': format_id,
87 'quality': quality_key(format_id),
88 'height': hd_height if is_hd else None,
90 self._sort_formats(formats)
95 'thumbnail': thumbnail,
96 'duration': int_or_none(player.get('length')),