]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hungama.py
2 from __future__
import unicode_literals
4 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': 'a845a6d1ebd08d80c1035126d49bd6a0',
27 'title': 'Lucky Ali - Kitni Haseen Zindagi',
28 'track': 'Kitni Haseen Zindagi',
29 'artist': 'Lucky Ali',
34 'url': 'https://www.hungama.com/movie/kahaani-2/44129919/',
35 'only_matching': True,
37 'url': 'https://www.hungama.com/tv-show/padded-ki-pushup/season-1/44139461/episode/ep-02-training-sasu-pathlaag-karing/44139503/',
38 'only_matching': True,
41 def _real_extract(self
, url
):
42 video_id
= self
._match
_id
(url
)
44 webpage
= self
._download
_webpage
(url
, video_id
)
46 info
= self
._search
_json
_ld
(webpage
, video_id
)
48 m3u8_url
= self
._download
_json
(
49 'https://www.hungama.com/index.php', video_id
,
50 data
=urlencode_postdata({'content_id': video_id
}), headers
={
51 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
52 'X-Requested-With': 'XMLHttpRequest',
55 'm': 'get_video_mdn_url',
58 formats
= self
._extract
_m
3u8_formats
(
59 m3u8_url
, video_id
, ext
='mp4', entry_protocol
='m3u8_native',
61 self
._sort
_formats
(formats
)
70 class HungamaSongIE(InfoExtractor
):
71 _VALID_URL
= r
'https?://(?:www\.)?hungama\.com/song/[^/]+/(?P<id>\d+)'
73 'url': 'https://www.hungama.com/song/kitni-haseen-zindagi/2931166/',
74 'md5': 'a845a6d1ebd08d80c1035126d49bd6a0',
78 'title': 'Lucky Ali - Kitni Haseen Zindagi',
79 'track': 'Kitni Haseen Zindagi',
80 'artist': 'Lucky Ali',
86 def _real_extract(self
, url
):
87 audio_id
= self
._match
_id
(url
)
89 data
= self
._download
_json
(
90 'https://www.hungama.com/audio-player-data/track/%s' % audio_id
,
91 audio_id
, query
={'_country': 'IN'})[0]
93 track
= data
['song_name']
94 artist
= data
.get('singer_name')
96 m3u8_url
= self
._download
_json
(
97 data
.get('file') or data
['preview_link'],
98 audio_id
)['response']['media_url']
100 formats
= self
._extract
_m
3u8_formats
(
101 m3u8_url
, audio_id
, ext
='mp4', entry_protocol
='m3u8_native',
103 self
._sort
_formats
(formats
)
105 title
= '%s - %s' % (artist
, track
) if artist
else track
106 thumbnail
= data
.get('img_src') or data
.get('album_image')
111 'thumbnail': thumbnail
,
114 'album': data
.get('album_name'),
115 'release_year': int_or_none(data
.get('date')),