码迷,mamicode.com
首页 > 编程语言 > 详细

Python——付费/版权歌曲下载

时间:2019-04-14 09:17:19      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:software   date   img   link   ihe   nload   title   bwt   png   

很多歌曲需要版权或者付费才能收听

技术图片

 

 

 

 

正确食用方法:

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()

 

Python——付费/版权歌曲下载

标签:software   date   img   link   ihe   nload   title   bwt   png   

原文地址:https://www.cnblogs.com/Jery-9527/p/10703701.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!