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