[netease] fix #1341, also do not create new directory when info_only

This commit is contained in:
Mort Yao 2016-08-10 13:56:52 +02:00
parent 9a4b255dc1
commit e765f32805
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -4,6 +4,7 @@
__all__ = ['netease_download']
from ..common import *
from ..util import fs
from json import loads
import hashlib
import base64
@ -28,10 +29,10 @@ def netease_cloud_music_download(url, output_dir='.', merge=True, info_only=Fals
artist_name = j['album']['artists'][0]['name']
album_name = j['album']['name']
new_dir = output_dir + '/' + "%s - %s" % (artist_name, album_name)
new_dir = output_dir + '/' + fs.legitimize("%s - %s" % (artist_name, album_name))
if not info_only:
if not os.path.exists(new_dir):
os.mkdir(new_dir)
if not info_only:
cover_url = j['album']['picUrl']
download_urls([cover_url], "cover", "jpg", 0, new_dir)
@ -46,10 +47,10 @@ def netease_cloud_music_download(url, output_dir='.', merge=True, info_only=Fals
elif "playlist" in url:
j = loads(get_content("http://music.163.com/api/playlist/detail?id=%s&csrf_token=" % rid, headers={"Referer": "http://music.163.com/"}))
new_dir = output_dir + '/' + j['result']['name']
new_dir = output_dir + '/' + fs.legitimize(j['result']['name'])
if not info_only:
if not os.path.exists(new_dir):
os.mkdir(new_dir)
if not info_only:
cover_url = j['result']['coverImgUrl']
download_urls([cover_url], "cover", "jpg", 0, new_dir)