]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/myvideoge.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / myvideoge.py
1 from .common import InfoExtractor
2 from ..utils import js_to_json
3
4
5 class MyVideoGeIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?myvideo\.ge/v/(?P<id>[0-9]+)'
7 _TEST = {
8 'url': 'https://www.myvideo.ge/v/3941048',
9 'md5': '8c192a7d2b15454ba4f29dc9c9a52ea9',
10 'info_dict': {
11 'id': '3941048',
12 'ext': 'mp4',
13 'title': 'The best prikol',
14 'thumbnail': r're:^https?://.*\.jpg$',
15 'uploader': 'md5:d72addd357b0dd914e704781f7f777d8',
16 'description': 'md5:5c0371f540f5888d603ebfedd46b6df3'
17 }
18 }
19
20 def _real_extract(self, url):
21 video_id = self._match_id(url)
22 webpage = self._download_webpage(url, video_id)
23
24 title = self._html_search_regex(r'<h1[^>]*>([^<]+)</h1>', webpage, 'title')
25 description = self._og_search_description(webpage)
26 thumbnail = self._html_search_meta(['og:image'], webpage)
27 uploader = self._search_regex(r'<a[^>]+class="mv_user_name"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False)
28
29 jwplayer_sources = self._parse_json(
30 self._search_regex(
31 r"(?s)jwplayer\(\"mvplayer\"\).setup\(.*?sources: (.*?])", webpage, 'jwplayer sources'),
32 video_id, transform_source=js_to_json)
33
34 def _formats_key(f):
35 if f['label'] == 'SD':
36 return -1
37 elif f['label'] == 'HD':
38 return 1
39 else:
40 return 0
41
42 jwplayer_sources = sorted(jwplayer_sources, key=_formats_key)
43
44 formats = self._parse_jwplayer_formats(jwplayer_sources, video_id)
45
46 return {
47 'id': video_id,
48 'title': title,
49 'description': description,
50 'uploader': uploader,
51 'formats': formats,
52 'thumbnail': thumbnail
53 }