网易云音乐歌曲免VIP批量下载软件工具python3

  • A+
所属分类:python基础入门

转载:网易云音乐歌曲批量下载目前支持歌单和排名榜,只要使用正确的URL则可以使用。

要求(py脚本)

  • python3+requests+python+BeautifulSoup4+lxml

使用方法

  • 直接双击运行exe软件工具或者通过python运行源码

URL获取如下:

源码及软件下载

vip音乐免费下载,软件下载地址:

https://github.com/CcphAmy/NetEaseCloudMusic-nonmembership-list-download/blob/master/dist/main.exe

  1. #!/usr/bin/python3
  2. # -*- coding: utf-8 -*-
  3. import requests
  4. import threading
  5. import os
  6. import re
  7. import wx
  8. import wx.xrc
  9. from bs4 import BeautifulSoup
  10. class MyFrame1 (threading.Thread,wx.Frame):
  11.     musicData = []
  12.     def __init__self, threadID, name ,counter):
  13.         wx.Frame.__init__ ( self, None, id = wx.ID_ANY, title = u"网易云音乐歌曲批量下载", pos = wx.DefaultPosition, size = wx.Size( 450,409 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
  14.         self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
  15.         self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOW ) )
  16.         bSizer4 = wx.BoxSizer( wx.VERTICAL )
  17.         bSizer5 = wx.BoxSizer( wx.HORIZONTAL )
  18.         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"Url", wx.DefaultPosition, wx.DefaultSize, 0 )
  19.         self.m_staticText3.Wrap( -1 )
  20.         self.m_staticText3.SetFont( wx.Font( 13, wx.FONTFAMILY_DECORATIVE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, wx.EmptyString ) )
  21.         bSizer5.Add( self.m_staticText3, 0, wx.ALL, 5 )
  22.         self.url_text = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 300,-1 ), 0 )
  23.         bSizer5.Add( self.url_text, 0, wx.ALL, 5 )
  24.         self.down_button = wx.Button( self, wx.ID_ANY, u"下载歌单", wx.DefaultPosition, wx.DefaultSize, 0 )
  25.         bSizer5.Add( self.down_button, 0, wx.ALL, 5 )
  26.         bSizer4.Add( bSizer5, 1, wx.EXPAND, 4 )
  27.         self.output_text = wx.TextCtrl( self, wx.ID_ANY, u" \
  28. 网易云音乐歌单下载,网页中复制URL\n \
  29. https://music.163.com/#/playlist?id=xxxxxxxxxx\n \
  30. 保存目录:D:\\music\n \
  31. 线程只能执行一次,下载后如需重新下载其他需要重启\n \
  32. 可多开下载同个歌单或者不同歌单\n \
  33. -------------------------------------------------------\n \
  34. 支持歌单和排名榜 - ccphamy\n \
  35. -------------------------------------------------------\n" \
  36.             , wx.DefaultPosition, wx.Size( 450,320 ), wx.TE_MULTILINE )
  37.         bSizer4.Add( self.output_text, 0, wx.ALL, 5 )
  38.         self.SetSizer( bSizer4 )
  39.         self.Layout()
  40.         self.Centre( wx.BOTH )
  41.         # Connect Events
  42.         self.down_button.Bind( wx.EVT_BUTTON, self.main_button_click )
  43.         # 多线程
  44.         threading.Thread.__init__(self)
  45.         self.threadID = threadID
  46.         self.name = name
  47.         self.counter = counter
  48.         if not os.path.exists("d:/music"):
  49.             os.mkdir('d:/music')
  50.     def __del__self ):
  51.         pass
  52.     def run(self):
  53.         self.output_text.AppendText(u"歌曲获取成功,任务线程开启///\n")
  54.         self.get(self.musicData)
  55.     def main_button_click( self, event ):
  56.         self.musicData = []
  57.         self.musicData = self.getMusicData(self.url_text.GetValue().replace("#/",""))
  58.         if len(self.musicData) >1:
  59.             self.start()
  60.     def get(self,values):
  61.         print(len(values))
  62.         downNum    = 0
  63.         rstr = r"[\/\\\:\*\?\"\<\>\|]"  # '/ \ : * ? " < > |'
  64.         for x in values:
  65.             x['name'] = re.sub(rstr, "_", x['name'])
  66.             if not os.path.exists("d:/music/" + x['name'] + '.mp3'):
  67.                 self.output_text.AppendText('***** ' + x['name'] + '.mp3 ***** Downloading...\n')
  68.                 url = 'http://music.163.com/song/media/outer/url?id=' + x['id'] + '.mp3'
  69.                 try:
  70.                     # urllib.request.urlretrieve(url,'d:/music/' + x['name'] + '.mp3')
  71.                     self.saveFile(url,'d:/music/' + x['name'] + '.mp3')
  72.                     downNum = downNum + 1
  73.                 except:
  74.                     x = x - 1
  75.                     self.output_text.AppendText(u'Download wrong~\n')
  76.         self.output_text.AppendText('Download complete ' + str(downNum) + ' files !\n')           pass
  77.     def getMusicData(self,url):
  78.         user_agent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36'
  79.         headers    = {'User-Agent':user_agent}
  80.         webData    = requests.get(url,headers=headers).text
  81.         soup       = BeautifulSoup(webData,'lxml')
  82.         find_list  = soup.find('ul',class_="f-hide").find_all('a')
  83.         tempArr = []
  84.         for a in find_list:
  85.             music_id  = a['href'].replace('/song?id=','')
  86.             music_name = a.text
  87.             tempArr.append({'id':music_id,'name':music_name})
  88.         return tempArr
  89.     def saveFile(self,url,path):
  90.         response = requests.get(url)
  91.         with open(path, 'wb') as f:
  92.             f.write(response.content)
  93.             f.flush()
  94. def main():
  95.     app = wx.App(False)
  96.     frame = MyFrame1(1, "Thread-1", 1)
  97.     frame.Show(True)
  98.     #start the applications 
  99.     app.MainLoop()
  100. if __name__ == '__main__':
  101.     main()
weinxin
我的微信公众号
爱真理,得永生!          爱在灵灵久博客,网罗天下,福利大家!

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: