aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHa Tien Loi <loiht.b17vt220@stu.ptit.edu.vn>2022-03-10 13:13:19 +0700
committerGitHub <noreply@github.com>2022-03-09 22:13:19 -0800
commit63b2f88bc77f3fa8388f2ec329f270672d4430b1 (patch)
tree2f677c6fe47bf2dc1e53a53892fdc75c5c6727ed
parent07ff290dce6713a80e4fe92fcf24cb23d07c5ce6 (diff)
downloadhypervideo-pre-63b2f88bc77f3fa8388f2ec329f270672d4430b1.tar.lz
hypervideo-pre-63b2f88bc77f3fa8388f2ec329f270672d4430b1.tar.xz
hypervideo-pre-63b2f88bc77f3fa8388f2ec329f270672d4430b1.zip
[Zingmp3] Fix signature (#3004)
Authored by: hatienl0i261299
-rw-r--r--yt_dlp/extractor/zingmp3.py32
1 files changed, 26 insertions, 6 deletions
diff --git a/yt_dlp/extractor/zingmp3.py b/yt_dlp/extractor/zingmp3.py
index 22c62e22e..419bf30d8 100644
--- a/yt_dlp/extractor/zingmp3.py
+++ b/yt_dlp/extractor/zingmp3.py
@@ -9,7 +9,6 @@ from .common import InfoExtractor
from ..utils import (
int_or_none,
traverse_obj,
- HEADRequest,
)
@@ -106,18 +105,17 @@ class ZingMp3BaseIE(InfoExtractor):
def _real_initialize(self):
if not self.get_param('cookiefile') and not self.get_param('cookiesfrombrowser'):
- self._request_webpage(HEADRequest(self._DOMAIN), None, note='Updating cookies')
+ self._request_webpage(self.get_api_with_signature(name_api=self._SLUG_API['bai-hat'], param={'id': ''}),
+ None, note='Updating cookies')
def _real_extract(self, url):
song_id, type_url = self._match_valid_url(url).group('id', 'type')
-
api = self.get_api_with_signature(name_api=self._SLUG_API[type_url], param={'id': song_id})
-
return self._process_data(self._download_json(api, song_id)['data'], song_id, type_url)
def get_api_with_signature(self, name_api, param):
- sha256 = hashlib.sha256(''.join(f'{k}={v}' for k, v in param.items()).encode('utf-8')).hexdigest()
-
+ param.update({'ctime': '1'})
+ sha256 = hashlib.sha256(''.join(f'{i}={param[i]}' for i in sorted(param)).encode('utf-8')).hexdigest()
data = {
'apiKey': self._API_KEY,
'sig': hmac.new(self._SECRET_KEY, f'{name_api}{sha256}'.encode('utf-8'), hashlib.sha512).hexdigest(),
@@ -162,6 +160,20 @@ class ZingMp3IE(ZingMp3BaseIE):
'album_artist': 'K-ICM, RYO',
},
}, {
+ 'url': 'https://zingmp3.vn/bai-hat/Nguoi-Yeu-Toi-Lanh-Lung-Sat-Da-Mr-Siro/ZZ6IW7OU.html',
+ 'md5': '3e9f7a9bd0d965573dbff8d7c68b629d',
+ 'info_dict': {
+ 'id': 'ZZ6IW7OU',
+ 'title': 'Người Yêu Tôi Lạnh Lùng Sắt Đá',
+ 'ext': 'mp3',
+ 'thumbnail': r're:^https?://.+\.jpg',
+ 'duration': 303,
+ 'track': 'Người Yêu Tôi Lạnh Lùng Sắt Đá',
+ 'artist': 'Mr. Siro',
+ 'album': 'Người Yêu Tôi Lạnh Lùng Sắt Đá (Single)',
+ 'album_artist': 'Mr. Siro',
+ },
+ }, {
'url': 'https://zingmp3.vn/embed/song/ZWZEI76B?start=false',
'only_matching': True,
}, {
@@ -186,6 +198,14 @@ class ZingMp3AlbumIE(ZingMp3BaseIE):
},
'playlist_count': 9,
}, {
+ 'url': 'https://zingmp3.vn/album/Nhung-Bai-Hat-Hay-Nhat-Cua-Mr-Siro-Mr-Siro/ZWZAEZZD.html',
+ 'info_dict': {
+ '_type': 'playlist',
+ 'id': 'ZWZAEZZD',
+ 'title': 'Những Bài Hát Hay Nhất Của Mr. Siro',
+ },
+ 'playlist_count': 49,
+ }, {
'url': 'http://mp3.zing.vn/playlist/Duong-Hong-Loan-apollobee/IWCAACCB.html',
'only_matching': True,
}, {