]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/koo.py
1 from .common
import InfoExtractor
8 class KooIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?kooapp\.com/koo/[^/]+/(?P<id>[^/&#$?]+)'
10 _TESTS
= [{ # Test for video in the comments
11 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/946c4189-bc2d-4524-b95b-43f641e2adde',
13 'id': '946c4189-bc2d-4524-b95b-43f641e2adde',
15 'title': 'test for video in comment',
16 'description': 'md5:daa77dc214add4da8b6ea7d2226776e7',
17 'timestamp': 1632215195,
18 'uploader_id': 'ytdlpTestAccount',
19 'uploader': 'yt-dlpTestAccount',
21 'upload_date': '20210921'
23 'params': {'skip_download': True}
24 }, { # Test for koo with long title
25 'url': 'https://www.kooapp.com/koo/laxman_kumarDBFEC/33decbf7-5e1e-4bb8-bfd7-04744a064361',
27 'id': '33decbf7-5e1e-4bb8-bfd7-04744a064361',
29 'title': 'md5:47a71c2337295330c5a19a8af1bbf450',
30 'description': 'md5:06a6a84e9321499486dab541693d8425',
31 'timestamp': 1632106884,
32 'uploader_id': 'laxman_kumarDBFEC',
33 'uploader': 'Laxman Kumar 🇮🇳',
35 'upload_date': '20210920'
37 'params': {'skip_download': True}
39 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/a2a9c88e-ce4b-4d2d-952f-d06361c5b602',
41 'id': 'a2a9c88e-ce4b-4d2d-952f-d06361c5b602',
43 'title': 'Test for audio',
44 'description': 'md5:ecb9a2b6a5d34b736cecb53788cb11e8',
45 'timestamp': 1632211634,
46 'uploader_id': 'ytdlpTestAccount',
47 'uploader': 'yt-dlpTestAccount',
49 'upload_date': '20210921'
51 'params': {'skip_download': True}
53 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/a3e56c53-c1ed-4ac9-ac02-ed1630e6b1d1',
55 'id': 'a3e56c53-c1ed-4ac9-ac02-ed1630e6b1d1',
57 'title': 'Test for video',
58 'description': 'md5:7afc4eb839074ddeb2beea5dd6fe9500',
59 'timestamp': 1632211468,
60 'uploader_id': 'ytdlpTestAccount',
61 'uploader': 'yt-dlpTestAccount',
63 'upload_date': '20210921'
65 'params': {'skip_download': True}
67 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/01bf5b94-81a5-4d8e-a387-5f732022e15a',
68 'skip': 'No video/audio found at the provided url.',
70 'id': '01bf5b94-81a5-4d8e-a387-5f732022e15a',
71 'title': 'Test for link',
74 }, { # Test for images
75 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/dc05d9cd-a61d-45fd-bb07-e8019d8ca8cb',
76 'skip': 'No video/audio found at the provided url.',
78 'id': 'dc05d9cd-a61d-45fd-bb07-e8019d8ca8cb',
79 'title': 'Test for images',
84 def _real_extract(self
, url
):
85 id = self
._match
_id
(url
)
86 data_json
= self
._download
_json
(f
'https://www.kooapp.com/apiV1/ku/{id}?limit=20&offset=0&showSimilarKoos=true', id)['parentContent']
87 item_json
= next(content
['items'][0] for content
in data_json
88 if try_get(content
, lambda x
: x
['items'][0]['id']) == id)
89 media_json
= item_json
['mediaMap']
92 mp4_url
= media_json
.get('videoMp4')
93 video_m3u8_url
= media_json
.get('videoHls')
100 formats
.extend(self
._extract
_m
3u8_formats
(video_m3u8_url
, id, fatal
=False, ext
='mp4'))
102 self
.raise_no_formats('No video/audio found at the provided url.', expected
=True)
106 'title': clean_html(item_json
.get('title')),
107 'description': f
'{clean_html(item_json.get("title"))}\n\n{clean_html(item_json.get("enTransliteration"))}',
108 'timestamp': item_json
.get('createdAt'),
109 'uploader_id': item_json
.get('handle'),
110 'uploader': item_json
.get('name'),
111 'duration': media_json
.get('duration'),