Coder Social home page Coder Social logo

anjia0532 / netease_download Goto Github PK

View Code? Open in Web Editor NEW
70.0 5.0 29.0 23 KB

一款简单且极少依赖的网易云音乐批量下载器,支持根据网易歌曲详情修改mp3的id3 tag信息

Python 100.00%
163music 163 netease-cloud-music netease netease-music neteasecloud netease-musicbox python python3

netease_download's Introduction

名字(Name)

netease_download -- 一款简单且极少依赖的网易云音乐下载器,支持根据网易歌曲详情修改mp3的id3 tag信息

声明(Statement)

代码为大多是本人原创,部分参考其他开源项目(代码内部和下方有注明),且仅限于学习交流,请勿用于任何商业用途!本人不承担任何法律责任,如果涉及到侵权问题,请留言告知。

使用(Useage)

需要python3

注意:

  1. 如果是windows的cmd/powershell,默认字符集是GBK,部分歌名会报错,所以需要运行 CHCP 65001
  2. 部分歌曲下架后,下载时会提示,暂无版权。
git clone https://github.com/anjia0532/netease_download.git
cd netease_download
pip install -r requestments.txt

python main.py http://music.163.com/#/song?id=27836179 # 单曲
python main.py http://music.163.com/#/album?id=37253721 # 专辑
python main.py http://music.163.com/#/playlist?id=2225407480 # 歌单
python main.py http://music.163.com/#/discover/toplist?id=1978921795 # 流行榜
python main.py http://music.163.com/#/artist?id=905705 # 艺术家
python main.py http://music.163.com/#/djradio?id=526696677 # 电台节目
python main.py http://music.163.com/#/program?id=1369232209 # dj

鸣谢(Thanks)

本工具借鉴了下面三个优秀开源项目的代码,特此注明

反馈(Feedback)

如果有问题,欢迎提 issues

Copyright and License

This module is licensed under the BSD license.

Copyright (C) 2017-, by AnJia [email protected].

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

netease_download's People

Contributors

anjia0532 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

netease_download's Issues

下载失败

centos7 python版本3.6,安装了依赖包,下载歌单地址:https://music.163.com/#/playlist?id=199676

下载失败报错如下:

Traceback (most recent call last):
File "/opt/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/opt/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/local/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/py3/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/opt/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/opt/py3/lib/python3.6/site-packages/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/opt/py3/lib/python3.6/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/opt/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/opt/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 389, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/opt/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 309, in _raise_timeout
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='music.163.com', port=80): Read timed out. (read timeout=60)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 450, in
main(args.url)
File "main.py", line 432, in main
x.url_parser(url)
File "main.py", line 396, in url_parser
self.download_playlist(self.id_parser('playlist'))
File "main.py", line 243, in download_playlist
self.get_song_infos(songs)
File "main.py", line 181, in get_song_infos
urls=self.get_durls(songs)
File "main.py", line 150, in get_durls
result = self.post_request(apis['song_url'], params)
File "main.py", line 136, in post_request
resp = ss.post('http://music.163.com/%s'%uri, data=data, timeout=self.timeout)
File "/opt/py3/lib/python3.6/site-packages/requests/sessions.py", line 555, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/opt/py3/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/opt/py3/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/opt/py3/lib/python3.6/site-packages/requests/adapters.py", line 521, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='music.163.com', port=80): Read timed out. (read timeout=60)

下载电台时,解析歌曲信息时发生异常,直接退出

silas@silas-ThinkPad netease_download % python3 /mnt/app/netease_download/main.py 'http://music.163.com/#/djradio?id=337895050'
http://music.163.com/#/djradio?id=337895050

-- 正在分析DJ节目信息 ...
Traceback (most recent call last):
File "/mnt/app/netease_download/main.py", line 450, in
main(args.url)
File "/mnt/app/netease_download/main.py", line 432, in main
x.url_parser(url)
File "/mnt/app/netease_download/main.py", line 420, in url_parser
self.download_djradio(self.id_parser('id'))
File "/mnt/app/netease_download/main.py", line 320, in download_djradio
self.download_song(i)
File "/mnt/app/netease_download/main.py", line 224, in download_song
self.get_song_infos(result['songs'])
File "/mnt/app/netease_download/main.py", line 183, in get_song_infos
song_info = self.get_song_info(i)
File "/mnt/app/netease_download/main.py", line 204, in get_song_info
song_info['song_name'] = modificate_text(i['name']).strip()
File "/mnt/app/netease_download/main.py", line 57, in modificate_text
text = html.unescape(text)
File "/usr/lib/python3.4/html/init.py", line 130, in unescape
if '&' not in s:
TypeError: argument of type 'NoneType' is not iterable
silas@silas-ThinkPad netease_download %

TypeError: 'NoneType' object is not subscriptable

[2;92m
-- 正在分析歌曲信息 ...�[0m
post_request error
Traceback (most recent call last):
File "main.py", line 450, in
main(args.url)
File "main.py", line 432, in main
x.url_parser(url)
File "main.py", line 417, in url_parser
self.download_song(self.id_parser('song'))
File "main.py", line 224, in download_song
self.get_song_infos(result['songs'])
File "main.py", line 181, in get_song_infos
urls=self.get_durls(songs)
File "main.py", line 151, in get_durls
return dict([str(s["id"]),s["url"]] for s in result['data'] if result['code'] == 200)
TypeError: 'NoneType' object is not subscriptable

为下载的文件名加一个排序的前缀

我经常用这个脚本下载音乐到U盘,再插到车时听, 只能按歌名排序。 歌单的次序全乱了~_~

加一个配置项,下载时就在文件名加一个排序的前缀

下载失败

python3 main.py https://music.163.com/#/album?id=34751905

运行结果

  >> 11 首歌曲将要下载.

  ++ 正在下载: #1/11# 不害怕 - 张韶涵.mp3
  ++ mp3_quality: High
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3.4/site-packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/usr/lib/python3.4/site-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
OSError: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.4/site-packages/urllib3/connectionpool.py", line 357, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.4/http/client.py", line 1137, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python3.4/http/client.py", line 1182, in _send_request
    self.endheaders(body)
  File "/usr/lib64/python3.4/http/client.py", line 1133, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python3.4/http/client.py", line 963, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.4/http/client.py", line 898, in send
    self.connect()
  File "/usr/lib/python3.4/site-packages/urllib3/connection.py", line 166, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.4/site-packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f68d02328d0>: Failed to establish a new connection: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/usr/lib/python3.4/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.4/site-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='m10.music.126.net', port=80): Max retries exceeded with url: /20190205085912/ce42394e7b338f149318ca69
78a52548/ymusic/9967/e28c/91f1/7cedb2d4b86386f8022faafaa245499e.mp3 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f68d02328d0>:
 Failed to establish a new connection: [Errno 113] No route to host',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 451, in <module>
    main(args.url)
  File "main.py", line 433, in main
    x.url_parser(url)
  File "main.py", line 428, in url_parser
    self.download()
  File "main.py", line 379, in download
    r = requests.session().get(i['durl'], stream=True,headers=download_headers,timeout=self.timeout)
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.4/site-packages/requests/adapters.py", line 508, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='m10.music.126.net', port=80): Max retries exceeded with url: /20190205085912/ce42394e7b338f149318c
a6978a52548/ymusic/9967/e28c/91f1/7cedb2d4b86386f8022faafaa245499e.mp3 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f68d02328d
0>: Failed to establish a new connection: [Errno 113] No route to host',))

ping结果如下

[root@host netease_download]# ping m10.music.126.net
PING m10.music.126.net (113.107.57.64) 56(84) bytes of data.
From 113.107.57.1 (113.107.57.1) icmp_seq=14 Destination Host Unreachable
From 113.107.57.1 (113.107.57.1) icmp_seq=15 Destination Host Unreachable

所以是网络原因?我是vps在海外挂的unblock youku的dns

下排行榜出错

++ ▒▒▒▒▒▒▒▒: #11/100# Lemon - ▒׽▒▒▒▒▒.mp3
++ mp3_quality: High

++ ▒▒▒▒▒▒▒▒: #12/100# ▒▒▒▒ - ▒▒▒.mp3
++ mp3_quality: High

++ ▒▒▒▒▒▒▒▒: #13/100# Three Pass (Live) - ▒▒▒▒▒▒▒LIL-EM & ICE.mp3
++ mp3_quality: High

++ ▒▒▒▒▒▒▒▒: #14/100# ▒▒ӥ󥰥ǥå▒ - amazarashi.mp3
++ mp3_quality: High
Traceback (most recent call last):
File "main.py", line 450, in
main(args.url)
File "main.py", line 432, in main
x.url_parser(url)
File "main.py", line 427, in url_parser
self.download()
File "main.py", line 374, in download
% (n or ii, amount_songs, col,s % (1, 91, mp3_quality)))
UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 33: illegal multibyte sequence

歌单不能下载,报错

PS E:\Github\netease_download> python main.py https://music.163.com/#/playlist?id=2850086850
https://music.163.com/#/playlist?id=2850086850
-- 正在分析歌单信息 ...
post_request error
Traceback (most recent call last):
File "E:\Github\netease_download\main.py", line 452, in
main(args.url)
File "E:\Github\netease_download\main.py", line 434, in main
x.url_parser(url)
File "E:\Github\netease_download\main.py", line 398, in url_parser
self.download_playlist(self.id_parser('playlist'))
File "E:\Github\netease_download\main.py", line 237, in download_playlist
songs = result['result']['tracks']
TypeError: 'NoneType' object is not subscriptable
PS E:\Github\netease_download> python main.py
usage: main.py [-h] [-d DIR] [-c] url
main.py: error: the following arguments are required: url
PS E:\Github\netease_download> python main.py https://music.163.com/song?id=66842
https://music.163.com/song?id=66842

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.