上传文件至 'plugin'

This commit is contained in:
comeonbaby0122 2022-09-27 11:00:33 +00:00
parent db048b5c97
commit 28f341423e

View File

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