aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorAwal Garg <awalgarg@gmail.com>2019-01-07 17:41:12 +0530
committerSergey M․ <dstftw@gmail.com>2019-01-08 09:14:22 +0700
commit8cb5c2181ac039e92a20247f266f48cee2411748 (patch)
tree37f6dd9387680b02f939bec79fe6b37bef307056 /youtube_dl/extractor
parent0266854f63baaa9669b30ee49c5e7e9f353970dd (diff)
[hungama] Add extractor
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/extractors.py1
-rw-r--r--youtube_dl/extractor/hungama.py32
2 files changed, 33 insertions, 0 deletions
diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py
index 3b1dfc451..5ff34216f 100644
--- a/youtube_dl/extractor/extractors.py
+++ b/youtube_dl/extractor/extractors.py
@@ -469,6 +469,7 @@ from .hrti import (
)
from .huajiao import HuajiaoIE
from .huffpost import HuffPostIE
+from .hungama import HungamaIE
from .hypem import HypemIE
from .iconosquare import IconosquareIE
from .ign import (
diff --git a/youtube_dl/extractor/hungama.py b/youtube_dl/extractor/hungama.py
new file mode 100644
index 000000000..e51440299
--- /dev/null
+++ b/youtube_dl/extractor/hungama.py
@@ -0,0 +1,32 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+
+class HungamaIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)hungama\.com/song/[\w\d-]+/(?P<id>[0-9]+)'
+ _TEST = {
+ 'url': 'https://www.hungama.com/song/kitni-haseen-zindagi/2931166/',
+ 'md5': '396fa7e8e7e67aa25da0edc4cac9b785',
+ 'info_dict': {
+ 'id': '2931166',
+ 'ext': 'mp4',
+ 'title': 'Kitni Haseen Zindagi',
+ }
+ }
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+ webpage = self._download_webpage(url, video_id)
+
+ player_data = self._download_json('https://www.hungama.com/audio-player-data/track/%s?_country=IN' % video_id, video_id)[0]
+ title = player_data.get('song_name') or self._og_search_title(webpage)
+ track_data = self._download_json(player_data['file'], video_id)
+ media_url = track_data['response']['media_url']
+
+ return {
+ 'id': video_id,
+ 'title': title,
+ 'formats': self._extract_m3u8_formats(media_url, video_id, ext='mp4'),
+ }