mirror of
https://github.com/qist/tvbox.git
synced 2025-10-26 09:42:24 +00:00
潇洒更新 202507260047
This commit is contained in:
169
xiaosa/py/想看影视.py
Normal file
169
xiaosa/py/想看影视.py
Normal file
@@ -0,0 +1,169 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# by @嗷呜
|
||||
import re
|
||||
import sys
|
||||
from Crypto.Hash import MD5
|
||||
sys.path.append("..")
|
||||
import json
|
||||
import time
|
||||
from pyquery import PyQuery as pq
|
||||
from base.spider import Spider
|
||||
|
||||
|
||||
class Spider(Spider):
|
||||
|
||||
def init(self, extend=""):
|
||||
pass
|
||||
|
||||
def getName(self):
|
||||
pass
|
||||
|
||||
def isVideoFormat(self, url):
|
||||
pass
|
||||
|
||||
def manualVideoCheck(self):
|
||||
pass
|
||||
|
||||
def action(self, action):
|
||||
pass
|
||||
|
||||
def destroy(self):
|
||||
pass
|
||||
|
||||
host = 'https://www.lreeok.vip'
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36',
|
||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||
'sec-ch-ua-platform': '"macOS"',
|
||||
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="134", "Google Chrome";v="134"',
|
||||
'Origin': host,
|
||||
'Referer': f"{host}/",
|
||||
}
|
||||
|
||||
def homeContent(self, filter):
|
||||
data = self.getpq(self.fetch(self.host, headers=self.headers).text)
|
||||
result = {}
|
||||
classes = []
|
||||
for k in data('.head-more.box a').items():
|
||||
i = k.attr('href')
|
||||
if i and '/vod' in i:
|
||||
classes.append({
|
||||
'type_name': k.text(),
|
||||
'type_id': re.search(r'\d+', i).group(0)
|
||||
})
|
||||
result['class'] = classes
|
||||
result['list'] = self.getlist(data('.border-box.diy-center .public-list-div'))
|
||||
return result
|
||||
|
||||
def homeVideoContent(self):
|
||||
pass
|
||||
|
||||
def categoryContent(self, tid, pg, filter, extend):
|
||||
body = {'type': tid, 'class': '', 'area': '', 'lang': '', 'version': '', 'state': '', 'letter': '', 'page': pg}
|
||||
data = self.post(f"{self.host}/index.php/api/vod", headers=self.headers, data=self.getbody(body)).json()
|
||||
result = {}
|
||||
result['list'] = data['list']
|
||||
result['page'] = pg
|
||||
result['pagecount'] = 9999
|
||||
result['limit'] = 90
|
||||
result['total'] = 999999
|
||||
return result
|
||||
|
||||
def detailContent(self, ids):
|
||||
data = self.getpq(self.fetch(f"{self.host}/voddetail/{ids[0]}.html", headers=self.headers).text)
|
||||
v = data('.detail-info.lightSpeedIn .slide-info')
|
||||
vod = {
|
||||
'vod_year': v.eq(-1).text(),
|
||||
'vod_remarks': v.eq(0).text(),
|
||||
'vod_actor': v.eq(3).text(),
|
||||
'vod_director': v.eq(2).text(),
|
||||
'vod_content': data('.switch-box #height_limit').text()
|
||||
}
|
||||
np = data('.anthology.wow.fadeInUp')
|
||||
ndata = np('.anthology-tab .swiper-wrapper .swiper-slide')
|
||||
pdata = np('.anthology-list .anthology-list-box ul')
|
||||
play, names = [], []
|
||||
for i in range(len(ndata)):
|
||||
n = ndata.eq(i)('a')
|
||||
n('span').remove()
|
||||
names.append(n.text())
|
||||
vs = []
|
||||
for v in pdata.eq(i)('li').items():
|
||||
vs.append(f"{v.text()}${v('a').attr('href')}")
|
||||
play.append('#'.join(vs))
|
||||
vod["vod_play_from"] = "$$$".join(names)
|
||||
vod["vod_play_url"] = "$$$".join(play)
|
||||
result = {"list": [vod]}
|
||||
return result
|
||||
|
||||
def searchContent(self, key, quick, pg="1"):
|
||||
# data = self.getpq(self.fetch(f"{self.host}/vodsearch/{key}----------{pg}---.html", headers=self.headers).text)
|
||||
# return {'list': self.getlist(data('.row-right .search-box .public-list-bj')), 'page': pg}
|
||||
data = self.fetch(
|
||||
f"{self.host}/index.php/ajax/suggest?mid={pg}&wd={key}&limit=999×tamp={int(time.time() * 1000)}",
|
||||
headers=self.headers).json()
|
||||
videos = []
|
||||
for i in data['list']:
|
||||
videos.append({
|
||||
'vod_id': i['id'],
|
||||
'vod_name': i['name'],
|
||||
'vod_pic': i['pic']
|
||||
})
|
||||
return {'list': videos, 'page': pg}
|
||||
|
||||
def playerContent(self, flag, id, vipFlags):
|
||||
h, p = {"User-Agent": "okhttp/3.14.9"}, 1
|
||||
url = f"{self.host}{id}"
|
||||
data = self.getpq(self.fetch(url, headers=self.headers).text)
|
||||
try:
|
||||
jstr = data('.player .player-left script').eq(0).text()
|
||||
jsdata = json.loads(jstr.split('aaa=')[-1])
|
||||
body = {'url': jsdata['url']}
|
||||
if not re.search(r'\.m3u8|\.mp4', body['url']):
|
||||
data = self.post(f"{self.host}/okplay/api_config.php", headers=self.headers,
|
||||
data=self.getbody(body)).json()
|
||||
url = data.get('url') or data.get('data', {}).get('url')
|
||||
p = 0
|
||||
except Exception as e:
|
||||
print('错误信息:', e)
|
||||
pass
|
||||
result = {}
|
||||
result["parse"] = p
|
||||
result["url"] = url
|
||||
result["header"] = h
|
||||
return result
|
||||
|
||||
def localProxy(self, param):
|
||||
pass
|
||||
|
||||
def getbody(self, params):
|
||||
t = int(time.time())
|
||||
h = MD5.new()
|
||||
h.update(f"DS{t}DCC147D11943AF75".encode('utf-8'))
|
||||
key = h.hexdigest()
|
||||
params.update({'time': t, 'key': key})
|
||||
return params
|
||||
|
||||
def getlist(self, data):
|
||||
videos = []
|
||||
for i in data.items():
|
||||
id = i('a').attr('href')
|
||||
if id:
|
||||
id = re.search(r'\d+', id).group(0)
|
||||
img = i('img').attr('data-src')
|
||||
if img and 'url=' in img: img = f'{self.host}{img}'
|
||||
videos.append({
|
||||
'vod_id': id,
|
||||
'vod_name': i('img').attr('alt'),
|
||||
'vod_pic': img,
|
||||
'vod_remarks': i('.public-prt').text() or i('.public-list-prb').text()
|
||||
})
|
||||
return videos
|
||||
|
||||
def getpq(self, data):
|
||||
try:
|
||||
return pq(data)
|
||||
except Exception as e:
|
||||
print(f"{str(e)}")
|
||||
return pq(data.encode('utf-8'))
|
||||
182
xiaosa/py/追星影视.py
Normal file
182
xiaosa/py/追星影视.py
Normal file
@@ -0,0 +1,182 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# by @嗷呜
|
||||
import json
|
||||
import random
|
||||
import string
|
||||
import sys
|
||||
from base64 import b64decode, b64encode
|
||||
from urllib.parse import quote, unquote
|
||||
sys.path.append('..')
|
||||
import concurrent.futures
|
||||
from base.spider import Spider
|
||||
|
||||
|
||||
class Spider(Spider):
|
||||
|
||||
def init(self, extend=""):
|
||||
pass
|
||||
|
||||
def getName(self):
|
||||
pass
|
||||
|
||||
def isVideoFormat(self, url):
|
||||
pass
|
||||
|
||||
def manualVideoCheck(self):
|
||||
pass
|
||||
|
||||
def destroy(self):
|
||||
pass
|
||||
|
||||
host='https://xy.51gy.top'
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'okhttp/4.9.1',
|
||||
'mark-time': 'null',
|
||||
'fn-api-version': '3.1.9',
|
||||
'versionCode': '19',
|
||||
'product': 'gysg',
|
||||
'sg': '22664e555e0015684f988833803b3055',
|
||||
}
|
||||
|
||||
def homeContent(self, filter):
|
||||
data=self.fetch(f"{self.host}/api.php/vod/type", headers=self.headers).json()
|
||||
result,filters,videos = {},{},[]
|
||||
classes = [{'type_id': i['type_name'], 'type_name': i['type_name']} for i in data['list'][1:]]
|
||||
body={'token':'', 'type_id':data['list'][0]['type_id']}
|
||||
ldata=self.post(f"{self.host}/api.php/vod/category", data=body, headers=self.headers).json()
|
||||
for i in ldata['data']['banner']:
|
||||
videos.append({
|
||||
'vod_id':i.get('vod_id'),
|
||||
'vod_name':i.get('vod_name'),
|
||||
'vod_pic':i.get('vod_pic_thumb')
|
||||
})
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=len(classes)) as executor:
|
||||
future_to_aid = {executor.submit(self.fts, aid): aid for aid in classes}
|
||||
for future in concurrent.futures.as_completed(future_to_aid):
|
||||
aid = future_to_aid[future]
|
||||
try:
|
||||
aid_id, fts = future.result()
|
||||
filters[aid_id] = fts
|
||||
except Exception as e:
|
||||
print(f"Error processing aid {aid}: {e}")
|
||||
result['class'] = classes
|
||||
result['filters'] = filters
|
||||
result['list'] = videos
|
||||
return result
|
||||
|
||||
def homeVideoContent(self):
|
||||
pass
|
||||
|
||||
def categoryContent(self, tid, pg, filter, extend):
|
||||
params={'state':extend.get('state',tid) or tid,'class':extend.get('classes','全部'),'area':extend.get('area','全部'),'year':extend.get('year','全部'),'lang':extend.get('lang','全部'),'version':extend.get('version','全部'),'pg':pg}
|
||||
data=self.fetch(f"{self.host}/api.php/vod/list", params=params, headers=self.headers).json()
|
||||
result = {}
|
||||
videos = []
|
||||
for i in data['data']['list']:
|
||||
if str(i.get('vod_id', 0)) != '0':
|
||||
videos.append({
|
||||
'vod_id': i.get('vod_id'),
|
||||
'vod_name': i.get('vod_name'),
|
||||
'vod_pic': i.get('vod_pic'),
|
||||
'vod_year': f"{i.get('vod_score')}分",
|
||||
'vod_remarks': i.get('vod_remarks')
|
||||
})
|
||||
result['list'] = videos
|
||||
result['page'] = pg
|
||||
result['pagecount'] = 9999
|
||||
result['limit'] = 90
|
||||
result['total'] = 999999
|
||||
return result
|
||||
|
||||
def detailContent(self, ids):
|
||||
body={'ids':ids[0],'uni_code':self.getunc(),'ac':'detail','token':''}
|
||||
data=self.post(f"{self.host}/api.php/vod/detail2", data=body, headers=self.headers).json()
|
||||
v=data['data']
|
||||
vod = {
|
||||
'type_name': v.get('type_name'),
|
||||
'vod_year': v.get('vod_year'),
|
||||
'vod_area': v.get('vod_area'),
|
||||
'vod_lang': v.get('vod_lang'),
|
||||
'vod_remarks': v.get('vod_remarks'),
|
||||
'vod_actor': v.get('vod_actor'),
|
||||
'vod_director': v.get('vod_director'),
|
||||
'vod_content': v.get('vod_content')
|
||||
}
|
||||
n,p=[],[]
|
||||
for i in v['vod_play_list']:
|
||||
pp=i['player_info']
|
||||
n.append(pp['show'])
|
||||
np=[]
|
||||
for j in i['urls']:
|
||||
cd={'parse':pp.get('parse'),'url':j['url'],'headers':pp.get('headers')}
|
||||
np.append(f"{j['name']}${self.e64(json.dumps(cd))}")
|
||||
p.append('#'.join(np))
|
||||
vod.update({'vod_play_from':'$$$'.join(n),'vod_play_url':'$$$'.join(p)})
|
||||
return {'list':[vod]}
|
||||
|
||||
def searchContent(self, key, quick, pg="1"):
|
||||
data=self.fetch(f"{self.host}/api.php/vod/search", params={'keywords':key,'type':'1','pg':pg}, headers=self.headers).json()
|
||||
return {'list':data['list'],'page':pg}
|
||||
|
||||
def playerContent(self, flag, id, vipFlags):
|
||||
ids=json.loads(self.d64(id))
|
||||
headers = {}
|
||||
urls=ids['url']
|
||||
if ids.get('headers'):
|
||||
hs=ids['headers'].split('=>',1)
|
||||
headers[hs[0].strip()]=hs[-1].strip()
|
||||
if isinstance(ids.get('parse'), list) and len(ids['parse']) > 0:
|
||||
urls=[]
|
||||
for i,x in enumerate(ids['parse']):
|
||||
su=f"{self.getProxyUrl()}&url={quote(x+ids['url'])}"
|
||||
urls.extend([f'解析{i+1}',su])
|
||||
return {'parse': 0, 'url': urls, 'header': headers}
|
||||
|
||||
def localProxy(self, param):
|
||||
try:
|
||||
body = {'url':unquote(param['url'])}
|
||||
data=self.post(f"{self.host}/api.php/vod/m_jie_xi", data=body, headers=self.headers).json()
|
||||
url=data.get('url') or data['data'].get('url')
|
||||
return [302,'video/MP2T',None,{'Location':url}]
|
||||
except:
|
||||
return []
|
||||
|
||||
def liveContent(self, url):
|
||||
pass
|
||||
|
||||
def fts(self, tdata):
|
||||
params={'state':tdata['type_id'],'pg':'1'}
|
||||
data = self.fetch(f"{self.host}/api.php/vod/list", params=params, headers=self.headers).json()
|
||||
ftks = ["classes", "area", "lang", "year", "version", "state"]
|
||||
filter = [
|
||||
{
|
||||
'name': k,
|
||||
'key': k,
|
||||
'value': [{'n': i, 'v': i} for i in v.split(',')]
|
||||
}
|
||||
for k, v in data['data']['classes']["type_extend"].items()
|
||||
if k in ftks and v
|
||||
]
|
||||
return tdata['type_id'],filter
|
||||
|
||||
def getunc(self):
|
||||
chars = string.ascii_lowercase + string.digits
|
||||
data = ''.join(random.choice(chars) for _ in range(16))
|
||||
return self.e64(data)
|
||||
|
||||
def e64(self, text):
|
||||
try:
|
||||
text_bytes = text.encode('utf-8')
|
||||
encoded_bytes = b64encode(text_bytes)
|
||||
return encoded_bytes.decode('utf-8')
|
||||
except Exception as e:
|
||||
return ""
|
||||
|
||||
def d64(self,encoded_text):
|
||||
try:
|
||||
encoded_bytes = encoded_text.encode('utf-8')
|
||||
decoded_bytes = b64decode(encoded_bytes)
|
||||
return decoded_bytes.decode('utf-8')
|
||||
except Exception as e:
|
||||
return ""
|
||||
Reference in New Issue
Block a user