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