[cleanup] Misc (#8968)
[yt-dlp.git] / yt_dlp / extractor / utreon.py
blob12a7e4984a33605226b652239568638d8fa43178
1 from .common import InfoExtractor
2 from ..utils import (
3 dict_get,
4 int_or_none,
5 str_or_none,
6 try_get,
7 unified_strdate,
8 url_or_none,
12 class UtreonIE(InfoExtractor):
13 IE_NAME = 'playeur'
14 _VALID_URL = r'https?://(?:www\.)?(?:utreon|playeur)\.com/v/(?P<id>[\w-]+)'
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',
23 'thumbnail': r're:^https?://.+\.jpg',
24 'release_date': '20210723',
25 'duration': 586,
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]',
33 'description': 'md5:4026aa3a2c10169c3649926ac8ef62b6',
34 'uploader': 'Frases e Poemas Quotes and Poems',
35 'thumbnail': r're:^https?://.+\.jpg',
36 'release_date': '20210723',
37 'duration': 60,
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',
45 'description': 'md5:995aa9ad0733c0e5863ebdeff954f40e',
46 'uploader': 'Nomad Capitalist',
47 'thumbnail': r're:^https?://.+\.jpg',
48 'release_date': '20210723',
49 'duration': 884,
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',
59 'thumbnail': r're:^https?://.+\.jpg',
60 'release_date': '20210718',
61 'duration': 151,
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,
77 def _real_extract(self, url):
78 video_id = self._match_id(url)
79 json_data = self._download_json(
80 'https://api.playeur.com/v1/videos/' + video_id,
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)]
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')),