mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 20:52:31 +03:00
Merge branch 'develop' of ssh://github.com/ddcatgg/you-get into develop
This commit is contained in:
commit
61502e5f72
@ -7,6 +7,7 @@ from ..common import *
|
||||
from ..common import print_more_compatible as print
|
||||
from ..util import fs
|
||||
from json import loads
|
||||
import urllib
|
||||
import hashlib
|
||||
import base64
|
||||
import os
|
||||
@ -106,18 +107,41 @@ def netease_video_download(vinfo, output_dir='.', info_only=False):
|
||||
output_dir=output_dir, info_only=info_only)
|
||||
|
||||
def netease_song_download(song, output_dir='.', info_only=False, playlist_prefix=""):
|
||||
def _download():
|
||||
netease_download_common(title, url_best,
|
||||
output_dir=output_dir, info_only=info_only)
|
||||
|
||||
title = "%s%s. %s" % (playlist_prefix, song['position'], song['name'])
|
||||
songNet = 'p' + song['mp3Url'].split('/')[2][1:]
|
||||
|
||||
k = 0
|
||||
while k < 3:
|
||||
down = False
|
||||
if k == 0:
|
||||
if 'hMusic' in song and song['hMusic'] != None:
|
||||
url_best = make_url(songNet, song['hMusic']['dfsId'])
|
||||
elif 'mp3Url' in song:
|
||||
print('hMusic url: %s' % url_best)
|
||||
down = True
|
||||
elif k == 1:
|
||||
if 'mp3Url' in song:
|
||||
url_best = song['mp3Url']
|
||||
elif 'bMusic' in song:
|
||||
print('mp3Url url: %s' % url_best)
|
||||
down = True
|
||||
elif k == 2:
|
||||
if 'bMusic' in song:
|
||||
url_best = make_url(songNet, song['bMusic']['dfsId'])
|
||||
print('bMusic url: %s' % url_best)
|
||||
down = True
|
||||
if down:
|
||||
try:
|
||||
_download()
|
||||
break
|
||||
except urllib.error.HTTPError: # urllib.error.HTTPError: HTTP Error 404: Not Found
|
||||
import traceback
|
||||
print(traceback.format_exc())
|
||||
|
||||
k += 1
|
||||
|
||||
netease_download_common(title, url_best,
|
||||
output_dir=output_dir, info_only=info_only)
|
||||
|
||||
def netease_download_common(title, url_best, output_dir, info_only):
|
||||
songtype, ext, size = url_info(url_best)
|
||||
|
Loading…
Reference in New Issue
Block a user