1 from .common
import InfoExtractor
10 class YapFilesIE(InfoExtractor
):
12 _YAPFILES_URL
= r
'//(?:(?:www|api)\.)?yapfiles\.ru/get_player/*\?.*?\bv=(?P<id>\w+)'
13 _VALID_URL
= rf
'https?:{_YAPFILES_URL}'
14 _EMBED_REGEX
= [rf
'<iframe\b[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?{_YAPFILES_URL}.*?)\1']
17 'url': 'http://www.yapfiles.ru/get_player/?v=vMDE1NjcyNDUt0413',
18 'md5': '2db19e2bfa2450568868548a1aa1956c',
20 'id': 'vMDE1NjcyNDUt0413',
22 'title': 'Самый худший пароль WIFI',
23 'thumbnail': r
're:^https?://.*\.jpg$',
28 'url': 'https://api.yapfiles.ru/get_player/?uid=video_player_1872528&plroll=1&adv=1&v=vMDE4NzI1Mjgt690b',
29 'only_matching': True,
32 def _real_extract(self
, url
):
33 video_id
= self
._match
_id
(url
)
35 webpage
= self
._download
_webpage
(url
, video_id
, fatal
=False)
40 player_url
= self
._search
_regex
(
41 r
'player\.init\s*\(\s*(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1', webpage,
42 'player url
', default=None, group='url
')
45 player_url = f'http
://api
.yapfiles
.ru
/load
/{video_id}
/'
47 'md5
': 'ded5f369be61b8ae5f88e2eeb2f3caff
',
52 player = self._download_json(
53 player_url, video_id, query=query)['player
']
55 playlist_url = player['playlist
']
56 title = player['title
']
57 thumbnail = player.get('poster
')
59 if title == 'Ролик удален
' or 'deleted
.jpg
' in (thumbnail or ''):
61 f'Video {video_id} has been removed
', expected=True)
63 playlist = self._download_json(
64 playlist_url, video_id)['player
']['main
']
66 hd_height = int_or_none(player.get('hd
'))
68 QUALITIES = ('sd
', 'hd
')
69 quality_key = qualities(QUALITIES)
71 for format_id in QUALITIES:
72 is_hd = format_id == 'hd
'
73 format_url = url_or_none(playlist.get(
74 'file%s' % ('_hd
' if is_hd else '')))
79 'format_id
': format_id,
80 'quality
': quality_key(format_id),
81 'height
': hd_height if is_hd else None,
87 'thumbnail
': thumbnail,
88 'duration
': int_or_none(player.get('length
')),