]>
Commit | Line | Data |
---|---|---|
4bfa401d A |
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, | |
9 | ) | |
10 | ||
11 | ||
12 | class UtreonIE(InfoExtractor): | |
73f035e1 | 13 | _VALID_URL = r'https?://(?:www\.)?utreon.com/v/(?P<id>[a-zA-Z0-9_-]+)' |
4bfa401d A |
14 | _TESTS = [{ |
15 | 'url': 'https://utreon.com/v/z_I7ikQbuDw', | |
16 | 'info_dict': { | |
17 | 'id': 'z_I7ikQbuDw', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Freedom Friday meditation - Rising in the wind', | |
20 | 'description': 'md5:a9bf15a42434a062fe313b938343ad1b', | |
21 | 'uploader': 'Heather Dawn Elemental Health', | |
22 | 'thumbnail': 'https://data-1.utreon.com/v/MG/M2/NT/z_I7ikQbuDw/z_I7ikQbuDw_preview.jpg', | |
23 | 'release_date': '20210723', | |
24 | } | |
25 | }, { | |
26 | 'url': 'https://utreon.com/v/jerJw5EOOVU', | |
27 | 'info_dict': { | |
28 | 'id': 'jerJw5EOOVU', | |
29 | 'ext': 'mp4', | |
30 | 'title': 'When I\'m alone, I love to reflect in peace, to make my dreams come true... [Quotes and Poems]', | |
31 | 'description': 'md5:61ee6c2da98be51b04b969ca80273aaa', | |
32 | 'uploader': 'Frases e Poemas Quotes and Poems', | |
33 | 'thumbnail': 'https://data-1.utreon.com/v/Mz/Zh/ND/jerJw5EOOVU/jerJw5EOOVU_89af85470a4b16eededde7f8674c96d9_cover.jpg', | |
34 | 'release_date': '20210723', | |
35 | } | |
36 | }, { | |
37 | 'url': 'https://utreon.com/v/C4ZxXhYBBmE', | |
38 | 'info_dict': { | |
39 | 'id': 'C4ZxXhYBBmE', | |
40 | 'ext': 'mp4', | |
41 | 'title': 'Biden’s Capital Gains Tax Rate to Test World’s Highest', | |
42 | 'description': 'md5:fb5a6c2e506f013cc76f133f673bc5c8', | |
43 | 'uploader': 'Nomad Capitalist', | |
44 | 'thumbnail': 'https://data-1.utreon.com/v/ZD/k1/Mj/C4ZxXhYBBmE/C4ZxXhYBBmE_628342076198c9c06dd6b2c665978584_cover.jpg', | |
45 | 'release_date': '20210723', | |
46 | } | |
47 | }, { | |
48 | 'url': 'https://utreon.com/v/Y-stEH-FBm8', | |
49 | 'info_dict': { | |
50 | 'id': 'Y-stEH-FBm8', | |
51 | 'ext': 'mp4', | |
52 | 'title': 'Creeper-Chan Pranks Steve! 💚 [MINECRAFT ANIME]', | |
53 | 'description': 'md5:7a48450b0d761b96dec194be0c5ecb5f', | |
54 | 'uploader': 'Merryweather Comics', | |
55 | 'thumbnail': 'https://data-1.utreon.com/v/MT/E4/Zj/Y-stEH-FBm8/Y-stEH-FBm8_5290676a41a4a1096db133b09f54f77b_cover.jpg', | |
56 | 'release_date': '20210718', | |
57 | }}, | |
58 | ] | |
59 | ||
60 | def _real_extract(self, url): | |
61 | video_id = self._match_id(url) | |
62 | json_data = self._download_json( | |
63 | 'https://api.utreon.com/v1/videos/' + video_id, | |
64 | video_id) | |
65 | videos_json = json_data['videos'] | |
66 | formats = [{ | |
67 | 'url': format_url, | |
68 | 'format_id': format_key.split('_')[1], | |
69 | 'height': int(format_key.split('_')[1][:-1]), | |
70 | } for format_key, format_url in videos_json.items() if url_or_none(format_url)] | |
71 | self._sort_formats(formats) | |
72 | thumbnail = url_or_none(dict_get(json_data, ('cover_image_url', 'preview_image_url'))) | |
73 | return { | |
74 | 'id': video_id, | |
75 | 'title': json_data['title'], | |
76 | 'formats': formats, | |
77 | 'description': str_or_none(json_data.get('description')), | |
78 | 'duration': int_or_none(json_data.get('duration')), | |
79 | 'uploader': str_or_none(try_get(json_data, lambda x: x['channel']['title'])), | |
80 | 'thumbnail': thumbnail, | |
81 | 'release_date': unified_strdate(json_data.get('published_datetime')), | |
82 | } |