]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/hungama.py
3 from .common
import InfoExtractor
11 class HungamaIE(InfoExtractor
):
14 (?:www\.)?hungama\.com/
16 (?:video|movie)/[^/]+/|
17 tv-show/(?:[^/]+/){2}\d+/episode/[^/]+/
22 'url': 'http://www.hungama.com/video/krishna-chants/39349649/',
23 'md5': '687c5f1e9f832f3b59f44ed0eb1f120a',
27 'title': 'Krishna Chants',
28 'description': 'Watch Krishna Chants video now. You can also watch other latest videos only at Hungama',
29 'upload_date': '20180829',
31 'timestamp': 1535500800,
33 'thumbnail': 'https://images.hungama.com/c/1/0dc/2ca/39349649/39349649_700x394.jpg',
36 'url': 'https://www.hungama.com/movie/kahaani-2/44129919/',
37 'only_matching': True,
39 'url': 'https://www.hungama.com/tv-show/padded-ki-pushup/season-1/44139461/episode/ep-02-training-sasu-pathlaag-karing/44139503/',
40 'only_matching': True,
43 def _real_extract(self
, url
):
44 video_id
= self
._match
_id
(url
)
45 video_json
= self
._download
_json
(
46 'https://www.hungama.com/index.php', video_id
,
47 data
=urlencode_postdata({'content_id': video_id}
), headers
={
48 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
49 'X-Requested-With': 'XMLHttpRequest',
52 'm': 'get_video_mdn_url',
55 formats
= self
._extract
_m
3u8_formats
(video_json
['stream_url'], video_id
, ext
='mp4', m3u8_id
='hls')
56 self
._sort
_formats
(formats
)
58 json_ld
= self
._search
_json
_ld
(
59 self
._download
_webpage
(url
, video_id
, fatal
=False) or '', video_id
, fatal
=False)
67 'url': video_json
['sub_title'],
70 } if video_json
.get('sub_title') else None,
74 class HungamaSongIE(InfoExtractor
):
75 _VALID_URL
= r
'https?://(?:www\.)?hungama\.com/song/[^/]+/(?P<id>\d+)'
77 'url': 'https://www.hungama.com/song/kitni-haseen-zindagi/2931166/',
78 'md5': 'd4a6a05a394ad0453a9bea3ca00e6024',
82 'title': 'Lucky Ali - Kitni Haseen Zindagi',
83 'track': 'Kitni Haseen Zindagi',
84 'artist': 'Lucky Ali',
90 def _real_extract(self
, url
):
91 audio_id
= self
._match
_id
(url
)
93 data
= self
._download
_json
(
94 'https://www.hungama.com/audio-player-data/track/%s' % audio_id
,
95 audio_id
, query
={'_country': 'IN'}
)[0]
96 track
= data
['song_name']
97 artist
= data
.get('singer_name')
99 media_json
= self
._download
_json
(data
.get('file') or data
['preview_link'], audio_id
)
100 media_url
= try_get(media_json
, lambda x
: x
['response']['media_url'], str)
101 media_type
= try_get(media_json
, lambda x
: x
['response']['type'], str)
108 'acodec': media_type
,
111 title
= '%s - %s' % (artist
, track
) if artist
else track
112 thumbnail
= data
.get('img_src') or data
.get('album_image')
117 'thumbnail': thumbnail
,
120 'album': data
.get('album_name') or None,
121 'release_year': int_or_none(data
.get('date')),
126 class HungamaAlbumPlaylistIE(InfoExtractor
):
127 _VALID_URL
= r
'https?://(?:www\.)?hungama\.com/(?:playlists|album)/[^/]+/(?P<id>\d+)'
129 'url': 'https://www.hungama.com/album/bhuj-the-pride-of-india/69481490/',
130 'playlist_mincount': 7,
135 'url': 'https://www.hungama.com/playlists/hindi-jan-to-june-2021/123063/',
136 'playlist_mincount': 50,
142 def _real_extract(self
, url
):
143 video_id
= self
._match
_id
(url
)
144 webpage
= self
._download
_webpage
(url
, video_id
)
145 ptrn
= r
'<meta[^>]+?property=[\"\']?music
:song
:url
[\"\']?
[^
>]+?content
=[\"\']?
([^
\"\']+)'
146 items = re.findall(ptrn, webpage)
147 entries = [self.url_result(item, ie=HungamaSongIE.ie_key()) for item in items]
148 return self.playlist_result(entries, video_id)