注意
只支持免费音频下载;
分析视频
# -*- coding: utf-8 -*-
# @Author: Null119
# @Desc: { 蜻蜓FM一键下载 }
# @Date: 2022/03/11 7:28
import requests, urllib3, re, jsonpath, hmac, time, os, random
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
r = requests.session()
def downFile(path, url):
song = r.get(url, verify=False)
with open(path, 'wb') as f:
f.write(song.content)
def startDown(url):
bookid = re.search('channels/(\d+)', url).group(1)
html = r.get(url, verify=False).text
ver = re.search(r'"version":"(.*?)"', html).group(1)
bookName = re.search(r'<span class="title">(.*?)<',html).group(1)
nurl = 'https://i.qingting.fm/capi/channel/%s/programs/%s?curpage=1&pagesize=999&order=asc' % (bookid, ver)
html = r.get(nurl, verify=False)
sid = jsonpath.jsonpath(html.json(), '$.data.programs..id')
title = jsonpath.jsonpath(html.json(), '$.data.programs..title')
for i in range(len(sid)):
s_id = sid[i]
s_title = title[i]
print('开始下载:%s [%d/%d]' % (s_title, i + 1, len(sid)))
ts = str(int(time.time() * 1000))
enstr = "/audiostream/redirect/%s/%s?access_token=&device_id=MOBILESITE&qingting_id=&t=%s" % (bookid, s_id, ts)
key = b'fpMn12&38f_2e'
sign = hmac.new(key, enstr.encode(), digestmod='MD5').hexdigest()
durl = "https://audio.qtfm.cn/audiostream/redirect/%s/%s?access_token=&device_id=MOBILESITE&qingting_id=&t=%s&sign=%s" % (
bookid, s_id, ts, sign)
html = r.get(durl, allow_redirects=False, verify=False)
try:
surl = re.search('href="(.*?)"', html.text).group(1)
except:
print(html.json()['errormsg'])
break
fileTyp = re.search(r'\d+_\d+(\..*?)\?', surl).group(1)
if not os.path.exists('./' + bookName + '/'): os.mkdir('./' + bookName + '/')
if not os.path.isfile('./' + bookName + '/' + s_title + fileTyp):
downFile('./' + bookName + '/' + s_title + fileTyp, surl)
time.sleep(random.randint(1, 3))
if __name__ == '__main__':
url = 'https://www.qingting.fm/channels/237097/'
startDown(url)
声明:①本站为个人博客,博客所发布的一切修改补丁、注册机和注册信息及软件的文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。②本站信息来自网络,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。访问和下载本站内容,说明您已同意上述条款。③本站为非盈利性站点,VIP功能仅仅作为用户喜欢本站捐赠打赏功能,不开通VIP同样可以通过每日签到免费获取积分下载所有软件资源,本站不贩卖软件,所有内容不作为商业行为。