Merge pull request 'master' (#1) from comeonbaby0122/Q:master into master

Reviewed-on: https://agit.ai/zzzlllmmm1/Q/pulls/1
This commit is contained in:
zzzlllmmm1 2022-09-27 11:50:25 +00:00
commit 146388758c
6 changed files with 457 additions and 2444 deletions

1950
TV/Q.json

File diff suppressed because one or more lines are too long

View File

@ -543,95 +543,6 @@ SING女团】《风陵渡口》歌词版PV[640*360],https://vdse.bdstatic.com//a
怀旧金曲:刀郎《黄玫瑰》[960*544],https://vdse.bdstatic.com//893331fdfab5d04e5c93e2adbbf1e949.mp4
《那一夜》谢军[640*360],https://vdse.bdstatic.com//da6d866213a8bce7b317f508cf702e2e.mp4
狼爪•央视频道,#genre#
CCTV-1综合高清,rtsp://221.203.83.34:554/PLTV/88888888/224/0/3221226118/iptv65795.smil
CCTV-1综合高清,http://182.151.211.171:808/hls/1/index.m3u8$1920*1080
CCTV-1综合高清,http://183.207.249.15/PLTV/3/224/3221225530/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.32.101:6610/270000001111/1110000023/index.m3u8?IASHttpSessionId=OTT$1920*1080
CCTV-1综合高清,http://111.40.196.27/PLTV/88888888/224/3221225548/index.m3u8$1280*720
CCTV-1综合高清,http://111.40.196.9/PLTV/88888888/224/3221225548/index.m3u8$1280*720
CCTV-1综合高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888910/224/3221225618/index.m3u8$1920*1080
CCTV-1综合高清,http://39.135.138.58:18890/PLTV/88888910/224/3221225618/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.32.101:6610/270000001111/1110000151/index.m3u8?IASHttpSessionId=OTT$1920*1080
CCTV-1综合高清,http://59.49.41.44/live.aishang.ctlcdn.com/00000110240127_1/playlist.m3u8?CONTENTID=00000110240127_1$1920*1080
CCTV-1综合高清,http://39.136.48.7:8089/PLTV/88888888/224/3221225859/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.66.110/PLTV/88888888/224/3221225816/index.m3u8$1920*1080
CCTV-1综合高清,http://39.136.48.18:8089/PLTV/88888888/224/3221225859/index.m3u8$1920*1080
CCTV-1综合高清,http://183.207.249.9/PLTV/3/224/3221225530/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.115.163:8080/PLTV/88888910/224/3221225630/index.m3u8$1280*720
CCTV-1综合高清,http://39.134.32.102:6610/270000001111/1110000301/index.m3u8?IASHttpSessionId=OTT$1920*1080
CCTV-1综合高清,http://115.182.96.25/gitv_live/CCTV-1-HD/CCTV-1-HD.m3u8?p=GITV&area=AH_CMCC$1920*1080
CCTV-1综合高清,http://39.134.32.103:6610/270000001111/1110000301/index.m3u8?IASHttpSessionId=OTT$1920*1080
CCTV-1综合高清,http://219.151.31.38/liveplay-kk.rtxapp.com/live/program/live/CCTV-1综合高清hd/4000000/mnf.m3u8$1920*1080
CCTV-1综合高清,http://39.136.48.5:8089/PLTV/88888888/224/3221225859/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.67.99/PLTV/88888888/224/3221225816/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.67.98/PLTV/88888888/224/3221225816/index.m3u8$1920*1080
CCTV-1综合高清,http://39.135.138.60:18890/PLTV/88888910/224/3221225618/index.m3u8$1920*1080
CCTV-1综合高清,http://111.13.42.238/PLTV/88888888/224/3221226564/1.m3u8?icpid=88888888&from=1&hms_devid=461$1280*720
CCTV-1综合高清,http://39.134.115.163:8080/PLTV/88888910/224/3221225642/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.32.101:6610/270000001111/1110000301/index.m3u8?IASHttpSessionId=OTT$1920*1080
CCTV-1综合高清,http://39.134.65.181/PLTV/88888888/224/3221225816/1.m3u8$1920*1080
CCTV-1综合高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888888/224/3221225630/index.m3u8$1280*720
CCTV-1综合高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888910/224/3221225918/index.m3u8$1920*1080
CCTV-1综合高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888910/224/3221225642/index.m3u8$1920*1080
CCTV-1综合高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888910/224/3221225762/index.m3u8$1920*1080
CCTV-1综合高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888888/224/3221225618/index.m3u8$1920*1080
CCTV-1综合高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888888/224/3221225762/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.32.103:6610/270000001111/1110000151/index.m3u8?IASHttpSessionId=OTT$1920*1080
CCTV-1综合高清,http://39.134.32.108:6610/270000001111/1110000301/index.m3u8?IASHttpSessionId=OTT$1920*1080
CCTV-1综合高清,http://183.207.249.9/PLTV/3/224/3221225530/1.m3u8$1920*1080
CCTV-1综合高清,http://39.136.48.2:8089/PLTV/88888888/224/3221225859/index.m3u8$1920*1080
CCTV-1综合高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888888/224/3221225642/index.m3u8$1920*1080
CCTV-1综合高清,http://111.13.42.238/PLTV/88888888/224/3221226563/1.m3u8?icpid=88888888&from=1&hms_devid=461$1280*720
CCTV-1综合高清,http://120.253.104.16:808/hls/1/index.m3u8$1920*1080
CCTV-1综合高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888888/224/3221225918/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.116.30:8080/PLTV/88888910/224/3221225618/index.m3u8$1920*1080
CCTV-1综合高清,http://39.135.138.59:18890/PLTV/88888910/224/3221225918/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.65.141/PLTV/88888888/224/3221225816/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.67.226/PLTV/88888888/224/3221225816/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.116.30:8080/PLTV/88888910/224/3221225762/index.m3u8$1920*1080
CCTV-1综合高清,http://39.135.138.59:18890/PLTV/88888910/224/3221225642/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.116.30:8080/PLTV/88888910/224/3221225918/index.m3u8$1920*1080
CCTV-1综合高清,http://39.134.65.142/PLTV/88888888/224/3221225816/index.m3u8$1920*1080
CCTV-1综合高清,http://39.135.138.58:18890/PLTV/88888910/224/3221225762/index.m3u8$1920*1080
CCTV-1综合高清,http://39.135.138.59:18890/PLTV/88888910/224/3221225618/index.m3u8$1920*1080
CCTV-1综合高清,http://39.135.138.59:18890/PLTV/88888910/224/3221225630/index.m3u8$1280*720
CCTV-1综合高清,http://59.49.41.41/live.aishang.ctlcdn.com/00000110240127_1/playlist.m3u8?CONTENTID=00000110240127_1$1920*1080
CCTV-1综合高清,http://39.134.116.30:8080/PLTV/88888910/224/3221225630/index.m3u8$1280*720
CCTV-1综合高清,http://39.135.138.58:18890/PLTV/88888888/224/3221225762/index.m3u8$1920*1080
CCTV-2财经高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226584/10000100000000060000000000499223_0.smil
CCTV-3综艺高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226726/10000100000000060000000006489752_0.smil
CCTV-4中文国际高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226601/10000100000000060000000000755997_0.smil
CCTV-4欧洲高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226741/10000100000000060000000006582740_0.smil
CCTV-4美洲高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226762/10000100000000060000000006582745_0.smil
CCTV-5体育高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226707/10000100000000060000000006489753_0.smil
CCTV-6电影高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226728/10000100000000060000000006489754_0.smil
CCTV-7国防军事高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226531/10000100000000060000000000499224_0.smil
CCTV-8电视剧高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226730/10000100000000060000000006489755_0.smil
CCTV-9记录高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226588/10000100000000060000000000499231_0.smil
CCTV-10科教高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226586/10000100000000060000000000499225_0.smil
CCTV-11戏曲高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226727/10000100000000060000000006519577_0.smil
CCTV-12社会与法高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226533/10000100000000060000000000499226_0.smil
CCTV-13新闻高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226691/10000100000000060000000006385281_0.smil
CCTV-14少儿高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226529/10000100000000060000000000499222_0.smil
CCTV-15音乐高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226744/10000100000000060000000006519578_0.smil
CCTV-16奥林匹克高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226747/10000100000000060000000006758792_0.smil
CCTV-17农村农业高清,http://39.134.52.153/hwottcdn.ln.chinamobile.com/PLTV/88888888/224/3221226841/index.m3u8
CCTV-5+体育赛事高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226743/10000100000000060000000006603048_0.smil
CCTV-第一剧场高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226698/10000100000000060000000006385142_0.smil
CCTV-怀旧剧场高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226700/10000100000000060000000006385151_0.smil
CCTV-风云剧场高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226671/10000100000000060000000006385152_0.smil
CCTV-风云音乐高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226718/10000100000000060000000006385496_0.smil
CCTV-女性时尚高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226675/10000100000000060000000006385156_0.smil
CCTV-风云足球高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226702/10000100000000060000000006385159_0.smil
CCTV-央视文化精品高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226677/10000100000000060000000006385162_0.smil
CCTV-兵器科技高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226704/10000100000000060000000006385167_0.smil
CCTV-央视台球高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226706/10000100000000060000000006385172_0.smil
CCTV-世界地理高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226679/10000100000000060000000006385175_0.smil
CCTV-电视指南高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226708/10000100000000060000000006385178_0.smil
CGTN-高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226756/10000100000000060000000006569861_0.smil
CGTN-记录频道高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226758/10000100000000060000000006569863_0.smil
狼爪•央视蓝光,#genre#
CCTV1[1920•1080],http://hwrr.jx.chinamobile.com:8080/PLTV/88888888/224/3221225618/index.m3u8
CCTV1[1920•1080],http://hwrr.jx.chinamobile.com:8080/PLTV/88888888/224/3221225918/index.m3u8
@ -643,7 +554,6 @@ CCTV1[1920•1080],http://39.134.65.179/PLTV/88888888/224/3221225816/index.m3u8
CCTV1[1920•1080],http://39.134.65.181/PLTV/88888888/224/3221225816/index.m3u8
CCTV1[1920•1080],http://39.134.67.7:80/ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226016/index.m3u8
CCTV1[1920•1080],http://117.148.179.155/PLTV/88888888/224/3221231468/1.m3u8
CCTV2[1920•1080],http://39.135.138.58:18890/PLTV/88888888/224/3221225619/index.m3u8
CCTV2[1920•1080],http://117.148.179.147/PLTV/88888888/224/3221231678/1.m3u8
CCTV-2财经高清,http://39.136.48.6:8089/PLTV/88888888/224/3221225751/index.m3u8$1920*1080
CCTV-2财经高清,http://hwrr.jx.chinamobile.com:8080/PLTV/88888910/224/3221225643/index.m3u8$1920*1080
@ -941,6 +851,17 @@ CCTV17[1920•1080],http://39.134.66.46/PLTV/88888888/224/3221225708/index.m3u8
CCTV17[1920•1080],http://39.134.65.181/PLTV/88888888/224/3221225708/index.m3u8
CCTV17[1920•1080],http://39.134.65.183/PLTV/88888888/224/3221225708/index.m3u8
CCTV17[1920•1080],http://117.148.179.167/PLTV/88888888/224/3221231772/1.m3u8
CCTV-第一剧场高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226698/10000100000000060000000006385142_0.smil
CCTV-怀旧剧场高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226700/10000100000000060000000006385151_0.smil
CCTV-风云剧场高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226671/10000100000000060000000006385152_0.smil
CCTV-风云音乐高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226718/10000100000000060000000006385496_0.smil
CCTV-女性时尚高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226675/10000100000000060000000006385156_0.smil
CCTV-风云足球高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226702/10000100000000060000000006385159_0.smil
CCTV-央视文化精品高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226677/10000100000000060000000006385162_0.smil
CCTV-兵器科技高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226704/10000100000000060000000006385167_0.smil
CCTV-央视台球高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226706/10000100000000060000000006385172_0.smil
CCTV-世界地理高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226679/10000100000000060000000006385175_0.smil
CCTV-电视指南高清,rtsp://221.203.83.34:554/PLTV/88888888/224/3221226708/10000100000000060000000006385178_0.smil
狼爪•香港频道,#genre#
凤凰中文,http://play-live.ifeng.com/live/06OLEGEGM4G.m3u8

BIN
jar/LZ0328.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,405 +1,445 @@
#coding=utf-8
#!/usr/bin/python
import sys
sys.path.append('..')
from base.spider import Spider
import json
import requests
import time
import re
class Spider(Spider): # 元类 默认的元类 type
def getName(self):
return "阿里云盘"
def init(self,extend=""):
print("============{0}============".format(extend))
pass
def homeContent(self,filter):
result = {}
return result
def homeVideoContent(self):
result = {}
return result
def categoryContent(self,tid,pg,filter,extend):
result = {}
return result
def searchContent(self,key,quick):
result = {}
return result
def isVideoFormat(self,url):
pass
def manualVideoCheck(self):
pass
def playerContent(self,flag,id,vipFlags):
if flag == 'AliYun':
return self.originContent(flag,id,vipFlags)
elif flag == 'AliYun原画':
return self.fhdContent(flag,id,vipFlags)
else:
return {}
def fhdContent(self,flag,id,vipFlags):
self.login()
ids = id.split('+')
shareId = ids[0]
shareToken = ids[1]
fileId = ids[2]
category = ids[3]
url = self.getDownloadUrl(shareId,shareToken,fileId,category)
print(url)
noRsp = requests.get(url,headers=self.header, allow_redirects=False,verify = False)
realUrl = ''
if 'Location' in noRsp.headers:
realUrl = noRsp.headers['Location']
if 'location' in noRsp.headers and len(realUrl) == 0 :
realUrl = noRsp.headers['location']
newHeader = {
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36",
"referer":"https://www.aliyundrive.com/",
}
result = {
'parse':'0',
'playUrl':'',
'url':realUrl,
'header':newHeader
}
return result
def originContent(self,flag,id,vipFlags):
self.login()
ids = id.split('+')
shareId = ids[0]
shareToken = ids[1]
fileId = ids[2]
url = '{0}?do=push_agent&api=python&type=m3u8&share_id={1}&file_id={2}'.format(self.localProxyUrl,shareId,fileId)
result = {
'parse':'0',
'playUrl':'',
'url':url,
'header':''
}
# shareToken = self.getToken(shareId,'')
# self.getMediaSlice(shareId,shareToken,fileId)
# map = {
# 'share_id':'p1GJYEqgeb2',
# 'file_id':'62ed1b95b1048d60ffc246669f5e0999e90b8c2f',
# 'media_id':'1'
# }
# self.proxyMedia(map)
return result
def detailContent(self,array):
tid = array[0]
# shareId = self.regStr(href,'www.aliyundrive.com\\/s\\/([^\\/]+)(\\/folder\\/([^\\/]+))?')
# todo =========================================================================================
m = re.search('www.aliyundrive.com\\/s\\/([^\\/]+)(\\/folder\\/([^\\/]+))?', tid)
col = m.groups()
shareId = col[0]
fileId = col[2]
infoUrl = 'https://api.aliyundrive.com/adrive/v3/share_link/get_share_by_anonymous'
infoForm = {'share_id':shareId}
infoRsp = requests.post(infoUrl,json = infoForm,headers=self.header)
infoJo = json.loads(infoRsp.text)
infoJa = []
if 'file_infos' in infoJo:
infoJa = infoJo['file_infos']
if len(infoJa) <= 0 :
return ''
fileInfo = {}
# todo
fileInfo = infoJa[0]
print(fileId)
if fileId == None or len(fileId) <= 0:
fileId = fileInfo['file_id']
vodList = {
'vod_id':tid,
'vod_name':infoJo['share_name'],
'vod_pic':infoJo['avatar'],
'vod_content':tid,
'vod_play_from':'AliYun原画'
}
fileType = fileInfo['type']
if fileType != 'folder':
if fileType != 'file' or fileInfo['category'] != video:
return ''
fileId = 'root'
shareToken = self.getToken(shareId,'')
hashMap = {}
self.listFiles(hashMap,shareId,shareToken,fileId)
sortedMap = sorted(hashMap.items(), key=lambda x: x[0])
arrayList = []
playList = []
for sm in sortedMap:
arrayList.append(sm[0]+'$'+sm[1])
playList.append('#'.join(arrayList))
playList.append('#'.join(arrayList))
vodList['vod_play_url'] = '$$$'.join(playList)
result = {
'list':[vodList]
}
return result
authorization = ''
timeoutTick = 0
localTime = 0
expiresIn = 0
shareTokenMap = {}
expiresMap = {}
localMedia = {}
header = {
"Referer":"https://www.aliyundrive.com/",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36"
}
localProxyUrl = 'http://127.0.0.1:UndCover/proxy'
def redirectResponse(tUrl):
rsp = requests.get(tUrl, allow_redirects=False,verify = False)
if 'Location' in rsp.headers:
return redirectResponse(rsp.headers['Location'])
else:
return rsp
def getDownloadUrl(self,shareId,token,fileId,category):
lShareId = shareId
lFileId = fileId
params = {
"share_id": lShareId,
"category": "live_transcoding",
"file_id": lFileId,
"template_id": ""
}
customHeader = self.header.copy()
customHeader['x-share-token'] = token
customHeader['authorization'] = self.authorization
url = 'https://api.aliyundrive.com/v2/file/get_share_link_video_preview_play_info'
if category == 'video':
rsp = requests.post(url,json = params,headers=customHeader)
rspJo = json.loads(rsp.text)
lShareId = rspJo['share_id']
lFileId = rspJo['file_id']
jo = {
}
if category == 'video':
jo['share_id'] = lShareId
jo['file_id'] = lFileId
jo['expire_sec'] = 600
if category == 'audio':
jo['share_id'] = lShareId
jo['file_id'] = lFileId
jo['get_audio_play_info'] = True
downloadUrl = 'https://api.aliyundrive.com/v2/file/get_share_link_download_url'
downloadRsp = requests.post(downloadUrl,json = jo,headers=customHeader)
resultJo = json.loads(downloadRsp.text)
return resultJo['download_url']
def getMediaSlice(self,shareId,token,fileId):
params = {
"share_id": shareId,
"category": "live_transcoding",
"file_id": fileId,
"template_id": ""
}
customHeader = self.header.copy()
customHeader['x-share-token'] = token
customHeader['authorization'] = self.authorization
url = 'https://api.aliyundrive.com/v2/file/get_share_link_video_preview_play_info'
rsp = requests.post(url,json = params,headers=customHeader)
rspJo = json.loads(rsp.text)
quality = ['FHD','HD','SD']
videoList = rspJo['video_preview_play_info']['live_transcoding_task_list']
highUrl = ''
for q in quality:
if len(highUrl) > 0:
break
for video in videoList:
if(video['template_id'] == q):
highUrl = video['url']
break
if len(highUrl) == 0:
highUrl = videoList[0]['url']
noRsp = requests.get(highUrl,headers=self.header, allow_redirects=False,verify = False)
m3u8Url = ''
if 'Location' in noRsp.headers:
m3u8Url = noRsp.headers['Location']
if 'location' in noRsp.headers and len(m3u8Url) == 0 :
m3u8Url = noRsp.headers['location']
m3u8Rsp = requests.get(m3u8Url,headers=self.header)
m3u8Content = m3u8Rsp.text
tmpArray = m3u8Url.split('/')[0:-1]
host = '/'.join(tmpArray) + '/'
m3u8List = []
mediaMap = {}
slices = m3u8Content.split("\n")
count = 0
for slice in slices:
tmpSlice = slice
if 'x-oss-expires' in tmpSlice:
count = count + 1
mediaMap[str(count)] = host+tmpSlice
tmpSlice = "{0}?do=push_agent&api=python&type=media&share_id={1}&file_id={2}&media_id={3}".format(self.localProxyUrl,shareId,fileId,count)
m3u8List.append(tmpSlice)
self.localMedia[fileId] = mediaMap
return '\n'.join(m3u8List)
def proxyMedia(self,map):
shareId = map['share_id']
fileId = map['file_id']
mediaId = map['media_id']
shareToken = self.getToken(shareId,'')
refresh = False
url = ''
ts = 0
if fileId in self.localMedia:
fileMap = self.localMedia[fileId]
if mediaId in fileMap:
url = fileMap[mediaId]
if len(url) > 0:
ts = int(self.regStr(url,"x-oss-expires=(\\d+)&"))
# url = self.localMedia[fileId][mediaId]
# ts = int(self.regStr(url,"x-oss-expires=(\\d+)&"))
self.localTime = int(time.time())
if ts - self.localTime <= 60:
self.getMediaSlice(shareId,shareToken,fileId)
url = self.localMedia[fileId][mediaId]
action = {
'url':url,
'header':self.header,
'param':'',
'type':'stream',
'after':''
}
print(action)
return [200, "video/MP2T", action, ""]
def proxyM3U8(self,map):
shareId = map['share_id']
fileId = map['file_id']
shareToken = self.getToken(shareId,'')
content = self.getMediaSlice(shareId,shareToken,fileId)
action = {
'url':'',
'header':'',
'param':'',
'type':'string',
'after':''
}
return [200, "application/octet-stream", action, content]
def localProxy(self,param):
typ = param['type']
if typ == "m3u8":
return self.proxyM3U8(param)
if typ == "media":
return self.proxyMedia(param)
return None
def getToken(self,shareId,sharePwd):
self.localTime = int(time.time())
shareToken = ''
if shareId in self.shareTokenMap:
shareToken = self.shareTokenMap[shareId]
# todo
expire = self.expiresMap[shareId]
if len(shareToken) > 0 and expire - self.localTime > 600:
return shareToken
params = {
'share_id':shareId,
'share_pwd':sharePwd
}
url = 'https://api.aliyundrive.com/v2/share_link/get_share_token'
rsp = requests.post(url,json = params,headers=self.header)
jo = json.loads(rsp.text)
newShareToken = jo['share_token']
self.expiresMap[shareId] = self.localTime + int(jo['expires_in'])
self.shareTokenMap[shareId] = newShareToken
print(self.expiresMap)
print(self.shareTokenMap)
return newShareToken
def listFiles(self,map,shareId,shareToken,fileId):
url = 'https://api.aliyundrive.com/adrive/v3/file/list'
newHeader = self.header.copy()
newHeader['x-share-token'] = shareToken
params = {
'image_thumbnail_process':'image/resize,w_160/format,jpeg',
'image_url_process':'image/resize,w_1920/format,jpeg',
'limit':200,
'order_by':'updated_at',
'order_direction':'DESC',
'parent_file_id':fileId,
'share_id':shareId,
'video_thumbnail_process':'video/snapshot,t_1000,f_jpg,ar_auto,w_300'
}
maker = ''
arrayList = []
for i in range(1,51):
if i >= 2 and len(maker) == 0:
break
params['marker'] = maker
rsp = requests.post(url,json = params,headers=newHeader)
jo = json.loads(rsp.text)
ja = jo['items']
for jt in ja:
if jt['type'] == 'folder':
arrayList.append(jt['file_id'])
else:
if 'video' in jt['mime_type'] or 'video' in jt['category']:
repStr = jt['name'].replace("#", "_").replace("$", "_")
map[repStr] = shareId + "+" + shareToken + "+" + jt['file_id'] + "+" + jt['category']
# print(repStr,shareId + "+" + shareToken + "+" + jt['file_id'])
maker = jo['next_marker']
i = i + 1
for item in arrayList:
self.listFiles(map,shareId,shareToken,item)
def login(self):
self.localTime = int(time.time())
url = 'https://api.aliyundrive.com/token/refresh'
if len(self.authorization) == 0 or self.timeoutTick - self.localTime <= 600:
form = {
'refresh_token':'3865f0ab8f124688ad786a262af9b940'
}
rsp = requests.post(url,json = form,headers=self.header)
jo = json.loads(rsp.text)
self.authorization = jo['token_type'] + ' ' + jo['access_token']
self.expiresIn = int(jo['expires_in'])
self.timeoutTick = self.localTime + self.expiresIn
# print(self.authorization)
# print(self.timeoutTick)
# print(self.localTime)
# print(self.expiresIn)
#coding=utf-8
#!/usr/bin/python
import sys
sys.path.append('..')
from base.spider import Spider
import json
import requests
import time
import re
class Spider(Spider): # 元类 默认的元类 type
def getName(self):
return "阿里云盘"
def init(self,extend=""):
print("============{0}============".format(extend))
pass
def homeContent(self,filter):
result = {}
return result
def homeVideoContent(self):
result = {}
return result
def categoryContent(self,tid,pg,filter,extend):
result = {}
return result
def searchContent(self,key,quick):
result = {}
return result
def isVideoFormat(self,url):
pass
def manualVideoCheck(self):
pass
def playerContent(self,flag,id,vipFlags):
if flag == 'AliYun':
return self.originContent(flag,id,vipFlags)
elif flag == 'AliYun原画':
return self.fhdContent(flag,id,vipFlags)
else:
return {}
def fhdContent(self,flag,id,vipFlags):
if not self.login():
return {}
ids = id.split('+')
shareId = ids[0]
shareToken = ids[1]
fileId = ids[2]
category = ids[3]
subtitle = ids[4]
url = self.getDownloadUrl(shareId,shareToken,fileId,category)
noRsp = requests.get(url,headers=self.header, allow_redirects=False,verify = False)
realUrl = ''
if 'Location' in noRsp.headers:
realUrl = noRsp.headers['Location']
if 'location' in noRsp.headers and len(realUrl) == 0 :
realUrl = noRsp.headers['location']
newHeader = {
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36",
"referer":"https://www.aliyundrive.com/",
}
subtitleUrl = self.subtitleContent(id)
result = {
'parse':'0',
'playUrl':'',
'url':realUrl,
'header':newHeader,
'subt':subtitleUrl
}
return result
def subtitleContent(self,id):
ids = id.split('+')
shareId = ids[0]
shareToken = ids[1]
fileId = ids[2]
category = ids[3]
subtitle = ids[4]
if len(subtitle) == 0:
return ""
customHeader = self.header.copy()
customHeader['x-share-token'] = shareToken
customHeader['authorization'] = self.authorization
jo = {
"expire_sec": 600,
"share_id": shareId,
"file_id": subtitle,
"image_url_process": "image/resize,w_1920/format,jpeg",
"image_thumbnail_process": "image/resize,w_1920/format,jpeg",
"get_streams_url": True
# ,
# "drive_id": "183237630"
}
downloadUrl = 'https://api.aliyundrive.com/v2/file/get_share_link_download_url'
resultJo = requests.post(downloadUrl,json = jo,headers=customHeader).json()
print(resultJo)
noRsp = requests.get(resultJo['download_url'],headers=self.header, allow_redirects=False,verify = False)
realUrl = ''
if 'Location' in noRsp.headers:
realUrl = noRsp.headers['Location']
if 'location' in noRsp.headers and len(realUrl) == 0 :
realUrl = noRsp.headers['location']
return realUrl
def originContent(self,flag,id,vipFlags):
if not self.login():
return {}
ids = id.split('+')
shareId = ids[0]
shareToken = ids[1]
fileId = ids[2]
subtitle = ids[4]
url = '{0}?do=push_agent&api=python&type=m3u8&share_id={1}&file_id={2}'.format(self.localProxyUrl,shareId,fileId)
subtitleUrl = self.subtitleContent(id)
newHeader = {
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36",
"referer":"https://www.aliyundrive.com/",
}
result = {
'parse':'0',
'playUrl':'',
'url':url,
'header':newHeader,
'subt':subtitleUrl
}
return result
def detailContent(self,array):
tid = array[0]
m = re.search('www.aliyundrive.com\\/s\\/([^\\/]+)(\\/folder\\/([^\\/]+))?', tid)
col = m.groups()
shareId = col[0]
fileId = col[2]
infoUrl = 'https://api.aliyundrive.com/adrive/v3/share_link/get_share_by_anonymous'
infoForm = {'share_id':shareId}
infoRsp = requests.post(infoUrl,json = infoForm,headers=self.header)
infoJo = json.loads(infoRsp.text)
infoJa = []
if 'file_infos' in infoJo:
infoJa = infoJo['file_infos']
if len(infoJa) <= 0 :
return ''
fileInfo = {}
fileInfo = infoJa[0]
if fileId == None or len(fileId) <= 0:
fileId = fileInfo['file_id']
vodList = {
'vod_id':tid,
'vod_name':infoJo['share_name'],
'vod_pic':infoJo['avatar'],
'vod_content':tid,
'vod_play_from':'AliYun$$$AliYun原画'
}
fileType = fileInfo['type']
if fileType != 'folder':
if fileType != 'file' or fileInfo['category'] != video:
return ''
fileId = 'root'
shareToken = self.getToken(shareId,'')
hashMap = {}
self.listFiles(hashMap,shareId,shareToken,fileId)
sortedMap = sorted(hashMap.items(), key=lambda x: x[0])
arrayList = []
playList = []
for sm in sortedMap:
arrayList.append(sm[0]+'$'+sm[1])
playList.append('#'.join(arrayList))
playList.append('#'.join(arrayList))
vodList['vod_play_url'] = '$$$'.join(playList)
result = {
'list':[vodList]
}
return result
authorization = ''
timeoutTick = 0
localTime = 0
expiresIn = 0
shareTokenMap = {}
expiresMap = {}
localMedia = {}
header = {
"Referer":"https://www.aliyundrive.com/",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36"
}
localProxyUrl = 'http://127.0.0.1:UndCover/proxy'
def redirectResponse(tUrl):
rsp = requests.get(tUrl, allow_redirects=False,verify = False)
if 'Location' in rsp.headers:
return redirectResponse(rsp.headers['Location'])
else:
return rsp
def getDownloadUrl(self,shareId,token,fileId,category):
lShareId = shareId
lFileId = fileId
params = {
"share_id": lShareId,
"category": "live_transcoding",
"file_id": lFileId,
"template_id": ""
}
customHeader = self.header.copy()
customHeader['x-share-token'] = token
customHeader['authorization'] = self.authorization
url = 'https://api.aliyundrive.com/v2/file/get_share_link_video_preview_play_info'
if category == 'video':
rsp = requests.post(url,json = params,headers=customHeader)
rspJo = json.loads(rsp.text)
lShareId = rspJo['share_id']
lFileId = rspJo['file_id']
jo = {
}
if category == 'video':
jo['share_id'] = lShareId
jo['file_id'] = lFileId
jo['expire_sec'] = 600
if category == 'audio':
jo['share_id'] = lShareId
jo['file_id'] = lFileId
jo['get_audio_play_info'] = True
downloadUrl = 'https://api.aliyundrive.com/v2/file/get_share_link_download_url'
downloadRsp = requests.post(downloadUrl,json = jo,headers=customHeader)
resultJo = json.loads(downloadRsp.text)
return resultJo['download_url']
def getMediaSlice(self,shareId,token,fileId):
params = {
"share_id": shareId,
"category": "live_transcoding",
"file_id": fileId,
"template_id": ""
}
customHeader = self.header.copy()
customHeader['x-share-token'] = token
customHeader['authorization'] = self.authorization
url = 'https://api.aliyundrive.com/v2/file/get_share_link_video_preview_play_info'
rsp = requests.post(url,json = params,headers=customHeader)
rspJo = json.loads(rsp.text)
quality = ['FHD','HD','SD']
videoList = rspJo['video_preview_play_info']['live_transcoding_task_list']
highUrl = ''
for q in quality:
if len(highUrl) > 0:
break
for video in videoList:
if(video['template_id'] == q):
highUrl = video['url']
break
if len(highUrl) == 0:
highUrl = videoList[0]['url']
noRsp = requests.get(highUrl,headers=self.header, allow_redirects=False,verify = False)
m3u8Url = ''
if 'Location' in noRsp.headers:
m3u8Url = noRsp.headers['Location']
if 'location' in noRsp.headers and len(m3u8Url) == 0 :
m3u8Url = noRsp.headers['location']
m3u8Rsp = requests.get(m3u8Url,headers=self.header)
m3u8Content = m3u8Rsp.text
tmpArray = m3u8Url.split('/')[0:-1]
host = '/'.join(tmpArray) + '/'
m3u8List = []
mediaMap = {}
slices = m3u8Content.split("\n")
count = 0
for slice in slices:
tmpSlice = slice
if 'x-oss-expires' in tmpSlice:
count = count + 1
mediaMap[str(count)] = host+tmpSlice
tmpSlice = "{0}?do=push_agent&api=python&type=media&share_id={1}&file_id={2}&media_id={3}".format(self.localProxyUrl,shareId,fileId,count)
m3u8List.append(tmpSlice)
self.localMedia[fileId] = mediaMap
return '\n'.join(m3u8List)
def proxyMedia(self,map):
shareId = map['share_id']
fileId = map['file_id']
mediaId = map['media_id']
shareToken = self.getToken(shareId,'')
refresh = False
url = ''
ts = 0
if fileId in self.localMedia:
fileMap = self.localMedia[fileId]
if mediaId in fileMap:
url = fileMap[mediaId]
if len(url) > 0:
ts = int(self.regStr(url,"x-oss-expires=(\\d+)&"))
self.localTime = int(time.time())
if ts - self.localTime <= 60:
self.getMediaSlice(shareId,shareToken,fileId)
url = self.localMedia[fileId][mediaId]
action = {
'url':url,
'header':self.header,
'param':'',
'type':'stream',
'after':''
}
return [200, "video/MP2T", action, ""]
def proxyM3U8(self,map):
shareId = map['share_id']
fileId = map['file_id']
shareToken = self.getToken(shareId,'')
content = self.getMediaSlice(shareId,shareToken,fileId)
action = {
'url':'',
'header':'',
'param':'',
'type':'string',
'after':''
}
return [200, "application/octet-stream", action, content]
def localProxy(self,param):
if not self.login():
return {}
typ = param['type']
if typ == "m3u8":
return self.proxyM3U8(param)
if typ == "media":
return self.proxyMedia(param)
return None
def getToken(self,shareId,sharePwd):
self.localTime = int(time.time())
shareToken = ''
if shareId in self.shareTokenMap:
shareToken = self.shareTokenMap[shareId]
# todo
expire = self.expiresMap[shareId]
if len(shareToken) > 0 and expire - self.localTime > 600:
return shareToken
params = {
'share_id':shareId,
'share_pwd':sharePwd
}
url = 'https://api.aliyundrive.com/v2/share_link/get_share_token'
rsp = requests.post(url,json = params,headers=self.header)
jo = json.loads(rsp.text)
newShareToken = jo['share_token']
self.expiresMap[shareId] = self.localTime + int(jo['expires_in'])
self.shareTokenMap[shareId] = newShareToken
# print(self.expiresMap)
# print(self.shareTokenMap)
return newShareToken
def listFiles(self,map,shareId,shareToken,fileId,subtitle={}):
url = 'https://api.aliyundrive.com/adrive/v3/file/list'
newHeader = self.header.copy()
newHeader['x-share-token'] = shareToken
params = {
'image_thumbnail_process':'image/resize,w_160/format,jpeg',
'image_url_process':'image/resize,w_1920/format,jpeg',
'limit':200,
'order_by':'updated_at',
'order_direction':'DESC',
'parent_file_id':fileId,
'share_id':shareId,
'video_thumbnail_process':'video/snapshot,t_1000,f_jpg,ar_auto,w_300'
}
maker = ''
arrayList = []
for i in range(1,51):
if i >= 2 and len(maker) == 0:
break
params['marker'] = maker
rsp = requests.post(url,json = params,headers=newHeader)
jo = json.loads(rsp.text)
ja = jo['items']
for jt in ja:
if jt['type'] == 'folder':
arrayList.append(jt['file_id'])
else:
if 'video' in jt['mime_type'] or 'video' in jt['category']:
repStr = jt['name'].replace("#", "_").replace("$", "_").replace(jt['file_extension'],'')[0:-1]
map[repStr] = shareId + "+" + shareToken + "+" + jt['file_id'] + "+" + jt['category'] + "+"
elif 'others' == jt['category'] and ('srt' == jt['file_extension'] or 'ass' == jt['file_extension']):
repStr = jt['name'].replace("#", "_").replace("$", "_").replace(jt['file_extension'],'')[0:-1]
subtitle[repStr] = jt['file_id']
maker = jo['next_marker']
i = i + 1
for item in arrayList:
self.listFiles(map,shareId,shareToken,item,subtitle)
for key in map.keys():
for subKey in subtitle.keys():
if key in subKey and map[key][-1] == "+":
map[key]=map[key]+subtitle[subKey]
break
def login(self):
self.localTime = int(time.time())
url = 'https://api.aliyundrive.com/token/refresh'
if len(self.authorization) == 0 or self.timeoutTick - self.localTime <= 600:
form = {
'refresh_token':'ab0b9a7555e84175bbc6f8e60310ae49'
}
rsp = requests.post(url,json = form,headers=self.header)
jo = json.loads(rsp.text)
if rsp.status_code == 200:
self.authorization = jo['token_type'] + ' ' + jo['access_token']
self.expiresIn = int(jo['expires_in'])
self.timeoutTick = self.localTime + self.expiresIn
return True
return False
else:
return True
# print(self.authorization)
# print(self.timeoutTick)
# print(self.localTime)
# print(self.expiresIn)