mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 03:03:01 +00:00
Merge branch 'ping-patch-8239'
This commit is contained in:
commit
7d4d9c526a
1 changed files with 26 additions and 14 deletions
|
@ -12,7 +12,10 @@
|
||||||
compat_str,
|
compat_str,
|
||||||
compat_itertools_count,
|
compat_itertools_count,
|
||||||
)
|
)
|
||||||
from ..utils import sanitized_Request
|
from ..utils import (
|
||||||
|
sanitized_Request,
|
||||||
|
float_or_none,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NetEaseMusicBaseIE(InfoExtractor):
|
class NetEaseMusicBaseIE(InfoExtractor):
|
||||||
|
@ -32,23 +35,32 @@ def _encrypt(cls, dfsid):
|
||||||
result = b64encode(m.digest()).decode('ascii')
|
result = b64encode(m.digest()).decode('ascii')
|
||||||
return result.replace('/', '_').replace('+', '-')
|
return result.replace('/', '_').replace('+', '-')
|
||||||
|
|
||||||
@classmethod
|
def extract_formats(self, info):
|
||||||
def extract_formats(cls, info):
|
|
||||||
formats = []
|
formats = []
|
||||||
for song_format in cls._FORMATS:
|
for song_format in self._FORMATS:
|
||||||
details = info.get(song_format)
|
details = info.get(song_format)
|
||||||
if not details:
|
if not details:
|
||||||
continue
|
continue
|
||||||
formats.append({
|
song_file_path = '/%s/%s.%s' % (
|
||||||
'url': 'http://m5.music.126.net/%s/%s.%s' %
|
self._encrypt(details['dfsId']), details['dfsId'], details['extension'])
|
||||||
(cls._encrypt(details['dfsId']), details['dfsId'],
|
|
||||||
details['extension']),
|
# 203.130.59.9, 124.40.233.182, 115.231.74.139, etc is a reverse proxy-like feature
|
||||||
'ext': details.get('extension'),
|
# from NetEase's CDN provider that can be used if m5.music.126.net does not
|
||||||
'abr': details.get('bitrate', 0) / 1000,
|
# work, especially for users outside of Mainland China
|
||||||
'format_id': song_format,
|
# via: https://github.com/JixunMoe/unblock-163/issues/3#issuecomment-163115880
|
||||||
'filesize': details.get('size'),
|
for host in ('http://m5.music.126.net', 'http://115.231.74.139/m1.music.126.net',
|
||||||
'asr': details.get('sr')
|
'http://124.40.233.182/m1.music.126.net', 'http://203.130.59.9/m1.music.126.net'):
|
||||||
})
|
song_url = host + song_file_path
|
||||||
|
if self._is_valid_url(song_url, info['id'], 'song'):
|
||||||
|
formats.append({
|
||||||
|
'url': song_url,
|
||||||
|
'ext': details.get('extension'),
|
||||||
|
'abr': float_or_none(details.get('bitrate'), scale=1000),
|
||||||
|
'format_id': song_format,
|
||||||
|
'filesize': details.get('size'),
|
||||||
|
'asr': details.get('sr')
|
||||||
|
})
|
||||||
|
break
|
||||||
return formats
|
return formats
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in a new issue