注意
只支持免费音频下载;
分析视频
# -*- 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小时内删除,严禁商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
【注意:本站发布资源来源于网络搜集,均有较强时效性,请在下载前注意查看文章资源发布或更新时间,距离当前时间太久的资源不建议下载,特别是安卓专区相关资源,会有大概率失效无法使用】
评论(0)