Python——付費/版權歌曲下載


很多歌曲需要版權或者付費才能收聽

 

 

 

 

正確食用方法:

1、找到歌曲編號

 

 2、輸入編號並點擊下載歌曲

 

 

# coding:utf8
# author:Jery
# datetime:2019/4/13 23:42
# software:PyCharm
# function:輸入編號下載歌曲,百度音樂/千千音樂歌曲下載
import tkinter as tk
import requests

root = tk.Tk()
root.geometry('400x150')
root.title('千千音樂歌曲下載')
l1 = tk.Label(root, text='請輸入編號:')
l1.grid()
e1 = tk.Entry(root, text='', width=57)
e1.grid(row=1, column=0)


def download():
    songids = []
    songids.append(e1.get())
    s = ','.join(songids)
    url = 'http://play.taihe.com/data/music/songlink'
    data = {
        'songIds': s,
        'hq': '0',
        'type': 'm4a,mp3',
        'rate': '',
        'pt': '0',
        'flag': '-1',
        's2p': '-1',
        'prerate': '-1',
        'bwt': '-1',
        'dur': '-1',
        'bat': '-1',
        'bp': '-1',
        'pos': '-1',
        'auto': '-1'
    }
    response = requests.post(url, data=data)
    music_infos = response.json()['data']['songList']
    for music_info in music_infos:
        songLink = music_info['songLink']
        songName = music_info['songName']
        response = requests.get(songLink)
        # 路徑自己修改
        with open('E:\\Jay2\\' + songName + '.mp3', 'wb')as f:
            f.write(response.content)


b1 = tk.Button(root, text='下載歌曲', width=8, command=download)
b1.grid(row=2, column=0)


def clear():
    e1.delete(0, 'end')


b2 = tk.Button(root, text='清除內容', width=8, command=clear)
b2.grid(row=3, column=0)
root.mainloop()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM