forked from Dong-learn9/TVBox-zyjk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy_3qu.py
191 lines (178 loc) · 6.66 KB
/
py_3qu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# coding=utf-8
# !/usr/bin/python
import sys
import re
sys.path.append('..')
from base.spider import Spider
import urllib.parse
import json
class Spider(Spider): # 元类 默认的元类 type
def getName(self):
return "快播影视"
def init(self, extend=""):
print("============{0}============".format(extend))
pass
def homeContent(self, filter):
result = {}
cateManual = {
"电影": "movie",
"剧集": "serie",
"综艺": "variety",
"动漫": "anime"
}
classes = []
for k in cateManual:
classes.append({
'type_name': k,
'type_id': cateManual[k]
})
result['class'] = classes
if (filter):
result['filters'] = self.config['filter']
return result
def homeVideoContent(self):
result = {
'list': []
}
return result
def categoryContent(self, tid, pg, filter, extend):
result = {}
header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"}
url = 'https://www.3qu.live/videos/{0}?page={1}'.format(tid, pg)
rsp = self.fetch(url,headers=header)
root = self.html(self.cleanText(rsp.text))
aList = root.xpath("//div[@class='main-content-box']/div/div/div/div/div/div/a")
videos = []
for a in aList:
name = a.xpath('./@title')[0]
picl = a.xpath('./@style')[0]
pica = re.findall(r"url\(\'(.*)\'\);", picl)[0]
pic = 'https://www.3qu.live{0}'.format(pica)
sidh = a.xpath("./@href")[0]
sid = self.regStr(sidh,'/videos/(\\S+).html')
videos.append({
"vod_id": sid,
"vod_name": name,
"vod_pic": pic,
"vod_remarks": ""
})
result['list'] = videos
result['page'] = pg
result['pagecount'] = 9999
result['limit'] = 100
result['total'] = 99999
return result
def detailContent(self, array):
tid = array[0]
url = 'https://www.3qu.live/videos/{0}.html'.format(tid)
header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"}
rsp = self.fetch(url,headers=header)
root = self.html(self.cleanText(rsp.text))
divContent = root.xpath("//div[@class='video-detail row']")[0]
title = divContent.xpath(".//div[@class='info-box']/a/h1/text()")[0]
pica = divContent.xpath(".//div[@class='thumb-box']/img/@src")[0]
pic = 'https://www.3qu.live{0}'.format(pica)
vod = {
"vod_id": tid,
"vod_name": title,
"vod_pic": pic,
"type_name": "",
"vod_year": "",
"vod_area": "",
"vod_remarks": "",
"vod_actor": "",
"vod_director": "",
"vod_content": ""
}
infoArray = divContent.xpath(".//div[@class='info-box']/ul/li")
for info in infoArray:
content = info.xpath('string(.)')
flag = "类型" in content
if flag == True:
infon = content.strip().split(' ')
for inf in infon:
if inf.startswith('类型'):
vod['type_name'] = inf.replace("类型:", "")
if inf.startswith('地区'):
vod['vod_area'] = inf.replace("地区:", "")
if inf.startswith('语言'):
vod['vod_remarks'] = inf.replace("语言:", "")
if content.startswith('演员'):
vod['vod_actor'] = content.replace("演员:", "")
if content.startswith('年份'):
yearl = content.split(' ')
year = yearl[0].replace("年份:", "")
vod['vod_year'] = year
if content.startswith('导演'):
vod['vod_director'] = content.replace("导演:", "")
if content.startswith('简介'):
vod['vod_content'] = content.replace("简介:", "")
vodList = root.xpath(".//div[@class='tab-content']/div[@id='playlist']/a")
playUrl = ''
for vl in vodList:
name = vl.xpath("./text()")[0]
did = vl.xpath("./@data-id")[0]
playUrl = playUrl + '{0}${1}_{2}#'.format(name,tid,did)
vod['vod_play_from'] = '快播影视'
vod['vod_play_url'] = playUrl
result = {
'list': [
vod
]
}
return result
def searchContent(self, key, quick):
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"}
url = 'https://www.3qu.live/api/v1/search?page=1&q={0}&type=all&period=0'.format(key)
rsp = self.fetch(url, headers=header)
jRoot = json.loads(rsp.text)
videos = []
vodList = jRoot['data']['videos']
for vod in vodList:
id = vod['id']
title = vod['name']
img = vod['coverURL']
pic = 'https://www.3qu.live{0}'.format(img)
videos.append({
"vod_id": id,
"vod_name": title,
"vod_pic": pic,
"vod_remarks": ""
})
result = {
'list': videos
}
return result
def playerContent(self, flag, id, vipFlags):
result = {}
ids = id.split("_")
header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"}
url = 'https://www.3qu.live/api/v1/videos/{0}/{1}/playUrl'.format(ids[0],ids[1])
rsp = self.fetch(url,headers=header)
jRoot = json.loads(rsp.text)
apiurl = jRoot['data']['url']
url = 'https://www.3qu.live{0}'.format(apiurl)
result["parse"] = 0
result["playUrl"] = ''
result["url"] =url
result["header"] = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"}
return result
config = {
"player": {},
"filter": {}
}
header = {}
def isVideoFormat(self, url):
pass
def manualVideoCheck(self):
pass
def localProxy(self, param):
action = {
'url': '',
'header': '',
'param': '',
'type': 'string',
'after': ''
}
return [200, "video/MP2T", action, ""]