mirror of https://github.com/FongMi/TV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.2 KiB
109 lines
2.2 KiB
import os
|
|
import requests
|
|
from importlib.machinery import SourceFileLoader
|
|
import json
|
|
|
|
|
|
def spider(cache, api):
|
|
name = os.path.basename(api)
|
|
path = cache + '/' + name
|
|
download(path, api)
|
|
name = name.split('.')[0]
|
|
return SourceFileLoader(name, path).load_module().Spider()
|
|
|
|
|
|
def download(path, api):
|
|
if api.startswith('http'):
|
|
writeFile(path, redirect(api).content)
|
|
else:
|
|
writeFile(path, str.encode(api))
|
|
|
|
|
|
def writeFile(path, content):
|
|
with open(path, 'wb') as f:
|
|
f.write(content)
|
|
|
|
|
|
def redirect(url):
|
|
rsp = requests.get(url, allow_redirects=False, verify=False)
|
|
if 'Location' in rsp.headers:
|
|
return redirect(rsp.headers['Location'])
|
|
else:
|
|
return rsp
|
|
|
|
|
|
def str2json(content):
|
|
return json.loads(content)
|
|
|
|
|
|
def getDependence(ru):
|
|
result = ru.getDependence()
|
|
return result
|
|
|
|
|
|
def getName(ru):
|
|
result = ru.getName()
|
|
return result
|
|
|
|
|
|
def init(ru, extend):
|
|
ru.init(extend)
|
|
|
|
|
|
def homeContent(ru, filter):
|
|
result = ru.homeContent(filter)
|
|
formatJo = json.dumps(result, ensure_ascii=False)
|
|
return formatJo
|
|
|
|
|
|
def homeVideoContent(ru):
|
|
result = ru.homeVideoContent()
|
|
formatJo = json.dumps(result, ensure_ascii=False)
|
|
return formatJo
|
|
|
|
|
|
def categoryContent(ru, tid, pg, filter, extend):
|
|
result = ru.categoryContent(tid, pg, filter, str2json(extend))
|
|
formatJo = json.dumps(result, ensure_ascii=False)
|
|
return formatJo
|
|
|
|
|
|
def detailContent(ru, array):
|
|
result = ru.detailContent(str2json(array))
|
|
formatJo = json.dumps(result, ensure_ascii=False)
|
|
return formatJo
|
|
|
|
|
|
def playerContent(ru, flag, id, vipFlags):
|
|
result = ru.playerContent(flag, id, str2json(vipFlags))
|
|
formatJo = json.dumps(result, ensure_ascii=False)
|
|
return formatJo
|
|
|
|
|
|
def searchContent(ru, key, quick):
|
|
result = ru.searchContent(key, quick)
|
|
formatJo = json.dumps(result, ensure_ascii=False)
|
|
return formatJo
|
|
|
|
|
|
def searchContentPage(ru, key, quick, pg):
|
|
result = ru.searchContentPage(key, quick, pg)
|
|
formatJo = json.dumps(result, ensure_ascii=False)
|
|
return formatJo
|
|
|
|
|
|
def localProxy(ru, param):
|
|
result = ru.localProxy(str2json(param))
|
|
return result
|
|
|
|
|
|
def destroy(ru):
|
|
ru.destroy()
|
|
|
|
|
|
def run():
|
|
pass
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run()
|
|
|