1 from .common
import InfoExtractor
13 class HungamaBaseIE(InfoExtractor
):
14 def _call_api(self
, path
, content_id
, fatal
=False):
15 return traverse_obj(self
._download
_json
(
16 f
'https://cpage.api.hungama.com/v2/page/content/{content_id}/{path}/detail',
17 content_id
, fatal
=fatal
, query
={
21 }), ('data', {dict}
)) or {}
24 class HungamaIE(HungamaBaseIE
):
27 (?:www\.|un\.)?hungama\.com/
29 (?:video|movie|short-film)/[^/]+/|
30 tv-show/(?:[^/]+/){2}\d+/episode/[^/]+/
35 'url': 'http://www.hungama.com/video/krishna-chants/39349649/',
36 'md5': '687c5f1e9f832f3b59f44ed0eb1f120a',
40 'title': 'Krishna Chants',
42 'upload_date': '20180829',
44 'timestamp': 1535500800,
46 'thumbnail': 'https://images1.hungama.com/tr:n-a_169_m/c/1/0dc/2ca/39349649/39349649_350x197.jpg?v=8',
50 'url': 'https://un.hungama.com/short-film/adira/102524179/',
51 'md5': '2278463f5dc9db9054d0c02602d44666',
56 'description': 'md5:df20cd4d41eabb33634f06de1025a4b4',
57 'upload_date': '20230417',
58 'timestamp': 1681689600,
60 'thumbnail': 'https://images1.hungama.com/tr:n-a_23_m/c/1/197/ac9/102524179/102524179_350x525.jpg?v=1',
64 'url': 'https://www.hungama.com/movie/kahaani-2/44129919/',
65 'only_matching': True,
67 'url': 'https://www.hungama.com/tv-show/padded-ki-pushup/season-1/44139461/episode/ep-02-training-sasu-pathlaag-karing/44139503/',
68 'only_matching': True,
71 def _real_extract(self
, url
):
72 video_id
= self
._match
_id
(url
)
73 video_json
= self
._download
_json
(
74 'https://www.hungama.com/index.php', video_id
,
75 data
=urlencode_postdata({'content_id': video_id
}), headers
={
76 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
77 'X-Requested-With': 'XMLHttpRequest',
80 'm': 'get_video_mdn_url',
82 formats
= self
._extract
_m
3u8_formats
(video_json
['stream_url'], video_id
, ext
='mp4', m3u8_id
='hls')
83 metadata
= self
._call
_api
('movie', video_id
)
86 **traverse_obj(metadata
, ('head', 'data', {
87 'title': ('title', {str}
),
88 'description': ('misc', 'description', {str}
),
89 'duration': ('duration', {int}
), # duration in JSON is incorrect if string
90 'timestamp': ('releasedate', {unified_timestamp}
),
91 'view_count': ('misc', 'playcount', {int_or_none}
),
92 'thumbnail': ('image', {url_or_none}
),
93 'tags': ('misc', 'keywords', ..., {str}
),
99 'url': video_json
['sub_title'],
102 } if video_json
.get('sub_title') else None,
106 class HungamaSongIE(InfoExtractor
):
107 _VALID_URL
= r
'https?://(?:www\.|un\.)?hungama\.com/song/[^/]+/(?P<id>\d+)'
109 'url': 'https://www.hungama.com/song/kitni-haseen-zindagi/2931166/',
110 'md5': '964f46828e8b250aa35e5fdcfdcac367',
114 'title': 'Lucky Ali - Kitni Haseen Zindagi',
115 'track': 'Kitni Haseen Zindagi',
116 'artist': 'Lucky Ali',
117 'release_year': 2000,
118 'thumbnail': 'https://stat2.hungama.ind.in/assets/images/default_images/da-200x200.png',
121 'url': 'https://un.hungama.com/song/tum-kya-mile-from-rocky-aur-rani-kii-prem-kahaani/103553672',
122 'md5': '964f46828e8b250aa35e5fdcfdcac367',
126 'title': 'md5:5ebeb1e10771b634ce5f700ce68ae5f4',
127 'track': 'Tum Kya Mile (From "Rocky Aur Rani Kii Prem Kahaani")',
128 'artist': 'Pritam Chakraborty, Arijit Singh, Shreya Ghoshal, Amitabh Bhattacharya',
129 'album': 'Tum Kya Mile (From "Rocky Aur Rani Kii Prem Kahaani")',
130 'release_year': 2023,
131 'thumbnail': 'https://images.hungama.com/c/1/7c2/c7b/103553671/103553671_200x200.jpg',
135 def _real_extract(self
, url
):
136 audio_id
= self
._match
_id
(url
)
138 data
= self
._download
_json
(
139 f
'https://www.hungama.com/audio-player-data/track/{audio_id}',
140 audio_id
, query
={'_country': 'IN'})[0]
141 track
= data
['song_name']
142 artist
= data
.get('singer_name')
144 media_json
= self
._download
_json
(data
.get('file') or data
['preview_link'], audio_id
)
145 media_url
= try_get(media_json
, lambda x
: x
['response']['media_url'], str)
146 media_type
= try_get(media_json
, lambda x
: x
['response']['type'], str)
153 'acodec': media_type
,
156 title
= f
'{artist} - {track}' if artist
else track
157 thumbnail
= data
.get('img_src') or data
.get('album_image')
162 'thumbnail': thumbnail
,
165 'album': data
.get('album_name') or None,
166 'release_year': int_or_none(data
.get('date')),
171 class HungamaAlbumPlaylistIE(HungamaBaseIE
):
172 _VALID_URL
= r
'https?://(?:www\.|un\.)?hungama\.com/(?P<path>playlists|album)/[^/]+/(?P<id>\d+)'
174 'url': 'https://www.hungama.com/album/bhuj-the-pride-of-india/69481490/',
175 'playlist_mincount': 7,
180 'url': 'https://www.hungama.com/playlists/hindi-jan-to-june-2021/123063/',
181 'playlist_mincount': 33,
186 'url': 'https://un.hungama.com/album/what-jhumka-%3F-from-rocky-aur-rani-kii-prem-kahaani/103891805/',
187 'playlist_mincount': 1,
193 def _real_extract(self
, url
):
194 playlist_id
, path
= self
._match
_valid
_url
(url
).group('id', 'path')
195 data
= self
._call
_api
(remove_end(path
, 's'), playlist_id
, fatal
=True)
198 for song_url
in traverse_obj(data
, ('body', 'rows', ..., 'data', 'misc', 'share', {url_or_none}
)):
199 yield self
.url_result(song_url
, HungamaSongIE
)
201 return self
.playlist_result(entries(), playlist_id
)