1 from .common
import InfoExtractor
8 class KooIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:www\.)?kooapp\.com/koo/[^/]+/(?P<id>[^/&#$?]+)'
11 _TESTS
= [{ # Test for video in the comments
12 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/946c4189-bc2d-4524-b95b-43f641e2adde',
14 'id': '946c4189-bc2d-4524-b95b-43f641e2adde',
16 'title': 'test for video in comment',
17 'description': 'md5:daa77dc214add4da8b6ea7d2226776e7',
18 'timestamp': 1632215195,
19 'uploader_id': 'ytdlpTestAccount',
20 'uploader': 'yt-dlpTestAccount',
22 'upload_date': '20210921',
24 'params': {'skip_download': True},
25 }, { # Test for koo with long title
26 'url': 'https://www.kooapp.com/koo/laxman_kumarDBFEC/33decbf7-5e1e-4bb8-bfd7-04744a064361',
28 'id': '33decbf7-5e1e-4bb8-bfd7-04744a064361',
30 'title': 'md5:47a71c2337295330c5a19a8af1bbf450',
31 'description': 'md5:06a6a84e9321499486dab541693d8425',
32 'timestamp': 1632106884,
33 'uploader_id': 'laxman_kumarDBFEC',
34 'uploader': 'Laxman Kumar 🇮🇳',
36 'upload_date': '20210920',
38 'params': {'skip_download': True},
40 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/a2a9c88e-ce4b-4d2d-952f-d06361c5b602',
42 'id': 'a2a9c88e-ce4b-4d2d-952f-d06361c5b602',
44 'title': 'Test for audio',
45 'description': 'md5:ecb9a2b6a5d34b736cecb53788cb11e8',
46 'timestamp': 1632211634,
47 'uploader_id': 'ytdlpTestAccount',
48 'uploader': 'yt-dlpTestAccount',
50 'upload_date': '20210921',
52 'params': {'skip_download': True},
54 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/a3e56c53-c1ed-4ac9-ac02-ed1630e6b1d1',
56 'id': 'a3e56c53-c1ed-4ac9-ac02-ed1630e6b1d1',
58 'title': 'Test for video',
59 'description': 'md5:7afc4eb839074ddeb2beea5dd6fe9500',
60 'timestamp': 1632211468,
61 'uploader_id': 'ytdlpTestAccount',
62 'uploader': 'yt-dlpTestAccount',
64 'upload_date': '20210921',
66 'params': {'skip_download': True},
68 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/01bf5b94-81a5-4d8e-a387-5f732022e15a',
69 'skip': 'No video/audio found at the provided url.',
71 'id': '01bf5b94-81a5-4d8e-a387-5f732022e15a',
72 'title': 'Test for link',
75 }, { # Test for images
76 'url': 'https://www.kooapp.com/koo/ytdlpTestAccount/dc05d9cd-a61d-45fd-bb07-e8019d8ca8cb',
77 'skip': 'No video/audio found at the provided url.',
79 'id': 'dc05d9cd-a61d-45fd-bb07-e8019d8ca8cb',
80 'title': 'Test for images',
85 def _real_extract(self
, url
):
86 video_id
= self
._match
_id
(url
)
87 data_json
= self
._download
_json
(
88 f
'https://www.kooapp.com/apiV1/ku/{video_id}?limit=20&offset=0&showSimilarKoos=true', video_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']) == video_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
, video_id
, fatal
=False, ext
='mp4'))
104 self
.raise_no_formats('No video/audio found at the provided url.', expected
=True)
108 'title': clean_html(item_json
.get('title')),
109 'description': f
'{clean_html(item_json.get("title"))}\n\n{clean_html(item_json.get("enTransliteration"))}',
110 'timestamp': item_json
.get('createdAt'),
111 'uploader_id': item_json
.get('handle'),
112 'uploader': item_json
.get('name'),
113 'duration': media_json
.get('duration'),