]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/plays.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / plays.py
CommitLineData
d1ea5e17 1import re
2
3from .common import InfoExtractor
4from ..utils import int_or_none
5
6
7class PlaysTVIE(InfoExtractor):
3d272951
S
8 _VALID_URL = r'https?://(?:www\.)?plays\.tv/(?:video|embeds)/(?P<id>[0-9a-f]{18})'
9 _TESTS = [{
8b1aeadc 10 'url': 'https://plays.tv/video/56af17f56c95335490/when-you-outplay-the-azir-wall',
d1ea5e17 11 'md5': 'dfeac1198506652b5257a62762cec7bc',
12 'info_dict': {
13 'id': '56af17f56c95335490',
14 'ext': 'mp4',
8b1aeadc 15 'title': 'Bjergsen - When you outplay the Azir wall',
d1ea5e17 16 'description': 'Posted by Bjergsen',
17 }
3d272951
S
18 }, {
19 'url': 'https://plays.tv/embeds/56af17f56c95335490',
20 'only_matching': True,
21 }]
d1ea5e17 22
23 def _real_extract(self, url):
24 video_id = self._match_id(url)
3d272951
S
25 webpage = self._download_webpage(
26 'https://plays.tv/video/%s' % video_id, video_id)
27
28 info = self._search_json_ld(webpage, video_id,)
d1ea5e17 29
d1ea5e17 30 mpd_url, sources = re.search(
31 r'(?s)<video[^>]+data-mpd="([^"]+)"[^>]*>(.+?)</video>',
8b1aeadc 32 webpage).groups()
d1ea5e17 33 formats = self._extract_mpd_formats(
34 self._proto_relative_url(mpd_url), video_id, mpd_id='DASH')
35 for format_id, height, format_url in re.findall(r'<source\s+res="((\d+)h?)"\s+src="([^"]+)"', sources):
36 formats.append({
37 'url': self._proto_relative_url(format_url),
38 'format_id': 'http-' + format_id,
39 'height': int_or_none(height),
40 })
d1ea5e17 41
3d272951 42 info.update({
d1ea5e17 43 'id': video_id,
d1ea5e17 44 'description': self._og_search_description(webpage),
3d272951 45 'thumbnail': info.get('thumbnail') or self._og_search_thumbnail(webpage),
d1ea5e17 46 'formats': formats,
3d272951
S
47 })
48
49 return info