脚本分享 - 同步网易云音乐歌单到 qq 音乐

2017-06-17 16:49:11 +08:00
 denonw
最近准备叛逃网易云音乐- -. 先做个爬虫脚本。 用了 selenium + phantomjs
项目地址: https://github.com/Denon/syncPlaylist

自己测试过应该没啥问题, 但是不知道在其他机器上会不会有啥 bug。如有问题留 issue 就好。
大家多多提提意见~ 谢谢
5951 次点击
所在节点    分享创造
44 条回复
denonw
2017-06-18 10:18:33 +08:00
@helloworld000 网页版不行么。。
lhie1
2017-06-19 00:54:12 +08:00
多谢
lhie1
2017-06-19 02:00:41 +08:00
不好意思打扰了

请问提示:

Traceback (most recent call last):
File "WYtoQQ.py", line 64, in <module>
browser = init_browser()
File "WYtoQQ.py", line 61, in init_browser
browser = webdriver.PhantomJS(phantomjs_driver)
File "/Library/Python/2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in __init__
self.service.start()
File "/Library/Python/2.7/site-packages/selenium/webdriver/common/service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH.

是什么原因呢?
lhie1
2017-06-19 02:02:53 +08:00
phantomjs_driver_path = "/Users/denon/Downloads/phantomjs-2.1.1-macosx/bin/phantomjs"
chrome_driver_path = ""
headers = {
"User-Agent": 'Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.'
}
search_url = "https://y.qq.com/portal/search.html#page=1&searchid=1&remoteplace=txt.yqq.top&t=song&w={}"
qq_playlist_url = 'https://y.qq.com/portal/profile.html#sub=other&tab=create&'
denonw
2017-06-19 10:49:52 +08:00
@lhie1 phantomjs_driver_path = "/Users/denon/Downloads/phantomjs-2.1.1-macosx/bin/phantomjs" 这个要换成你自己那边的路径。 我 README 上面写的是个例子= =
denonw
2017-06-19 13:23:42 +08:00
@myhu exe 程序已做好
lhie1
2017-06-19 14:29:44 +08:00
@denonw 我傻逼了..
denonw
2017-06-19 14:35:46 +08:00
@lhie1 这部分配置做的有点复杂... 后面打算直接脚本里面下载好👍, 就不用手动操作了
lhie1
2017-06-19 14:41:41 +08:00
你好 同步成功了 但是有了新的问题

get 163 playlist success
login sucess
song:哑子的爱情 success
song:革命时期的爱情 success
song:南方姑娘 success
song:追梦赤子心 success
song:斑马,斑马 success
total success:5
total failed:0, detail:

其中“哑子的爱情”和“革命时期的爱情”还不是我歌单里的..
denonw
2017-06-19 14:42:57 +08:00
@lhie1 恩? 网易云歌单的 url 发我下看看?
lhie1
2017-06-19 14:54:18 +08:00
myhu
2017-06-19 14:56:22 +08:00
@denonw 厉害!上架苹果应用商店,和 kilb 一样肯定大卖
denonw
2017-06-19 14:58:53 +08:00
@lhie1 知道问题了... 这种 url 格式没考虑进去= =. 我想想怎么改
denonw
2017-06-19 14:59:27 +08:00
@myhu 哈哈, 谢谢. 可惜不太会开发 app= =
lhie1
2017-06-19 15:04:22 +08:00
@denonw 请问正确的链接应该是怎样的?

我从网页上复制来的无法同步

这是从客户端里复制来的
lhie1
2017-06-19 15:05:44 +08:00
Traceback (most recent call last):
File "WYtoQQ.py", line 179, in main
song_list = get_163_song_list()
File "WYtoQQ.py", line 121, in get_163_song_list
singer, album = song_detail[1].split('- ', 1)
ValueError: need more than 1 value to unpack
total success:0
total failed:0, detail:
denonw
2017-06-19 15:09:46 +08:00
@lhie1 http://music.163.com/#/playlist?id=48371355 试试这个? 我是根据后面的 id 来取歌单的, 所以会有点问题. 我后面改下逻辑应该就好. 如果还有问题, 直接在 github 上提 issue 吧~ 谢谢。v2ex 回复代码有点乱
lhie1
2017-06-19 15:11:44 +08:00
@denonw 好的 试了 好像是获取不了
denonw
2017-06-19 18:14:48 +08:00
@lhie1 我推了一版新的. 你再试试?
lhie1
2017-06-19 18:31:11 +08:00
@denonw 好的 不知道对 py 版本有没有要求

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/369133

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX