mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 09:01:43 +00:00
[Hungama] Fix HungamaSongIE
and add HungamaAlbumPlaylistIE
(#744)
Authored by: Ashish0804
This commit is contained in:
parent
58adec4677
commit
14183d1f80
@ -538,6 +538,7 @@
|
|||||||
from .hungama import (
|
from .hungama import (
|
||||||
HungamaIE,
|
HungamaIE,
|
||||||
HungamaSongIE,
|
HungamaSongIE,
|
||||||
|
HungamaAlbumPlaylistIE,
|
||||||
)
|
)
|
||||||
from .hypem import HypemIE
|
from .hypem import HypemIE
|
||||||
from .ign import (
|
from .ign import (
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
try_get,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -71,14 +74,14 @@ class HungamaSongIE(InfoExtractor):
|
|||||||
_VALID_URL = r'https?://(?:www\.)?hungama\.com/song/[^/]+/(?P<id>\d+)'
|
_VALID_URL = r'https?://(?:www\.)?hungama\.com/song/[^/]+/(?P<id>\d+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://www.hungama.com/song/kitni-haseen-zindagi/2931166/',
|
'url': 'https://www.hungama.com/song/kitni-haseen-zindagi/2931166/',
|
||||||
'md5': 'a845a6d1ebd08d80c1035126d49bd6a0',
|
'md5': 'd4a6a05a394ad0453a9bea3ca00e6024',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '2931166',
|
'id': '2931166',
|
||||||
'ext': 'mp4',
|
'ext': 'mp3',
|
||||||
'title': 'Lucky Ali - Kitni Haseen Zindagi',
|
'title': 'Lucky Ali - Kitni Haseen Zindagi',
|
||||||
'track': 'Kitni Haseen Zindagi',
|
'track': 'Kitni Haseen Zindagi',
|
||||||
'artist': 'Lucky Ali',
|
'artist': 'Lucky Ali',
|
||||||
'album': 'Aks',
|
'album': None,
|
||||||
'release_year': 2000,
|
'release_year': 2000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,18 +92,20 @@ def _real_extract(self, url):
|
|||||||
data = self._download_json(
|
data = self._download_json(
|
||||||
'https://www.hungama.com/audio-player-data/track/%s' % audio_id,
|
'https://www.hungama.com/audio-player-data/track/%s' % audio_id,
|
||||||
audio_id, query={'_country': 'IN'})[0]
|
audio_id, query={'_country': 'IN'})[0]
|
||||||
|
|
||||||
track = data['song_name']
|
track = data['song_name']
|
||||||
artist = data.get('singer_name')
|
artist = data.get('singer_name')
|
||||||
|
formats = []
|
||||||
|
media_json = self._download_json(data.get('file') or data['preview_link'], audio_id)
|
||||||
|
media_url = try_get(media_json, lambda x: x['response']['media_url'], str)
|
||||||
|
media_type = try_get(media_json, lambda x: x['response']['type'], str)
|
||||||
|
|
||||||
m3u8_url = self._download_json(
|
if media_url:
|
||||||
data.get('file') or data['preview_link'],
|
formats.append({
|
||||||
audio_id)['response']['media_url']
|
'url': media_url,
|
||||||
|
'ext': media_type,
|
||||||
formats = self._extract_m3u8_formats(
|
'vcodec': 'none',
|
||||||
m3u8_url, audio_id, ext='mp4', entry_protocol='m3u8_native',
|
'acodec': media_type,
|
||||||
m3u8_id='hls')
|
})
|
||||||
self._sort_formats(formats)
|
|
||||||
|
|
||||||
title = '%s - %s' % (artist, track) if artist else track
|
title = '%s - %s' % (artist, track) if artist else track
|
||||||
thumbnail = data.get('img_src') or data.get('album_image')
|
thumbnail = data.get('img_src') or data.get('album_image')
|
||||||
@ -111,7 +116,32 @@ def _real_extract(self, url):
|
|||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
'track': track,
|
'track': track,
|
||||||
'artist': artist,
|
'artist': artist,
|
||||||
'album': data.get('album_name'),
|
'album': data.get('album_name') or None,
|
||||||
'release_year': int_or_none(data.get('date')),
|
'release_year': int_or_none(data.get('date')),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class HungamaAlbumPlaylistIE(InfoExtractor):
|
||||||
|
_VALID_URL = r'https?://(?:www\.)?hungama\.com/(?:playlists|album)/[^/]+/(?P<id>\d+)'
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'https://www.hungama.com/album/bhuj-the-pride-of-india/69481490/',
|
||||||
|
'playlist_mincount': 7,
|
||||||
|
'info_dict': {
|
||||||
|
'id': '69481490',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.hungama.com/playlists/hindi-jan-to-june-2021/123063/',
|
||||||
|
'playlist_mincount': 50,
|
||||||
|
'info_dict': {
|
||||||
|
'id': '123063',
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
id = self._match_id(url)
|
||||||
|
webpage = self._download_webpage(url, id)
|
||||||
|
ptrn = r'<meta[^>]+?property=[\"\']?music:song:url[\"\']?[^>]+?content=[\"\']?([^\"\']+)'
|
||||||
|
items = re.findall(ptrn, webpage)
|
||||||
|
entries = [self.url_result(item, ie=HungamaSongIE.ie_key()) for item in items]
|
||||||
|
return self.playlist_result(entries, id)
|
||||||
|
Loading…
Reference in New Issue
Block a user