]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/utreon.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / utreon.py
CommitLineData
4bfa401d
A
1from .common import InfoExtractor
2from ..utils import (
3 dict_get,
4 int_or_none,
5 str_or_none,
6 try_get,
7 unified_strdate,
8 url_or_none,
9)
10
11
12class UtreonIE(InfoExtractor):
41d6b61e
D
13 IE_NAME = 'playeur'
14 _VALID_URL = r'https?://(?:www\.)?(?:utreon|playeur)\.com/v/(?P<id>[\w-]+)'
4bfa401d
A
15 _TESTS = [{
16 'url': 'https://utreon.com/v/z_I7ikQbuDw',
17 'info_dict': {
18 'id': 'z_I7ikQbuDw',
19 'ext': 'mp4',
20 'title': 'Freedom Friday meditation - Rising in the wind',
21 'description': 'md5:a9bf15a42434a062fe313b938343ad1b',
22 'uploader': 'Heather Dawn Elemental Health',
41d6b61e 23 'thumbnail': r're:^https?://.+\.jpg',
4bfa401d 24 'release_date': '20210723',
41d6b61e 25 'duration': 586,
4bfa401d
A
26 }
27 }, {
28 'url': 'https://utreon.com/v/jerJw5EOOVU',
29 'info_dict': {
30 'id': 'jerJw5EOOVU',
31 'ext': 'mp4',
32 'title': 'When I\'m alone, I love to reflect in peace, to make my dreams come true... [Quotes and Poems]',
41d6b61e 33 'description': 'md5:4026aa3a2c10169c3649926ac8ef62b6',
4bfa401d 34 'uploader': 'Frases e Poemas Quotes and Poems',
41d6b61e 35 'thumbnail': r're:^https?://.+\.jpg',
4bfa401d 36 'release_date': '20210723',
41d6b61e 37 'duration': 60,
4bfa401d
A
38 }
39 }, {
40 'url': 'https://utreon.com/v/C4ZxXhYBBmE',
41 'info_dict': {
42 'id': 'C4ZxXhYBBmE',
43 'ext': 'mp4',
44 'title': 'Biden’s Capital Gains Tax Rate to Test World’s Highest',
41d6b61e 45 'description': 'md5:995aa9ad0733c0e5863ebdeff954f40e',
4bfa401d 46 'uploader': 'Nomad Capitalist',
41d6b61e 47 'thumbnail': r're:^https?://.+\.jpg',
4bfa401d 48 'release_date': '20210723',
41d6b61e 49 'duration': 884,
4bfa401d
A
50 }
51 }, {
52 'url': 'https://utreon.com/v/Y-stEH-FBm8',
53 'info_dict': {
54 'id': 'Y-stEH-FBm8',
55 'ext': 'mp4',
56 'title': 'Creeper-Chan Pranks Steve! 💚 [MINECRAFT ANIME]',
57 'description': 'md5:7a48450b0d761b96dec194be0c5ecb5f',
58 'uploader': 'Merryweather Comics',
41d6b61e 59 'thumbnail': r're:^https?://.+\.jpg',
4bfa401d 60 'release_date': '20210718',
41d6b61e
D
61 'duration': 151,
62 }
63 }, {
64 'url': 'https://playeur.com/v/Wzqp-UrxSeu',
65 'info_dict': {
66 'id': 'Wzqp-UrxSeu',
67 'ext': 'mp4',
68 'title': 'Update: Clockwork Basilisk Books on the Way!',
69 'description': 'md5:d9756b0b1884c904655b0e170d17cea5',
70 'uploader': 'Forgotten Weapons',
71 'release_date': '20240208',
72 'thumbnail': r're:^https?://.+\.jpg',
73 'duration': 262,
74 }
75 }]
4bfa401d
A
76
77 def _real_extract(self, url):
78 video_id = self._match_id(url)
79 json_data = self._download_json(
41d6b61e 80 'https://api.playeur.com/v1/videos/' + video_id,
4bfa401d
A
81 video_id)
82 videos_json = json_data['videos']
83 formats = [{
84 'url': format_url,
85 'format_id': format_key.split('_')[1],
86 'height': int(format_key.split('_')[1][:-1]),
87 } for format_key, format_url in videos_json.items() if url_or_none(format_url)]
4bfa401d
A
88 thumbnail = url_or_none(dict_get(json_data, ('cover_image_url', 'preview_image_url')))
89 return {
90 'id': video_id,
91 'title': json_data['title'],
92 'formats': formats,
93 'description': str_or_none(json_data.get('description')),
94 'duration': int_or_none(json_data.get('duration')),
95 'uploader': str_or_none(try_get(json_data, lambda x: x['channel']['title'])),
96 'thumbnail': thumbnail,
97 'release_date': unified_strdate(json_data.get('published_datetime')),
98 }