forked from heroaku/TVboxo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy_cyys.py
242 lines (227 loc) · 9.36 KB
/
py_cyys.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# coding=utf-8
# !/usr/bin/python
import sys
import re
sys.path.append('..')
from base.spider import Spider
import urllib.parse
import base64
from Crypto.Cipher import AES
class Spider(Spider): # 元类 默认的元类 type
def getName(self):
return "创艺影视"
def init(self, extend=""):
print("============{0}============".format(extend))
pass
def homeContent(self, filter):
result = {}
cateManual = {
"电影": "1",
"剧集": "2",
"动漫": "4",
"综艺": "3",
"纪录片": "30"
}
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 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"}
url = 'https://www.30dian.cn/vodtype/{0}-{1}.html'.format(tid, pg)
rsp = self.fetch(url,headers=header)
root = self.html(self.cleanText(rsp.text))
aList = root.xpath("//div[@class='myui-panel myui-panel-bg clearfix']/div/div/ul/li")
videos = []
for a in aList:
name = a.xpath('./div/a/@title')[0]
pic = a.xpath('./div/a/@data-original')[0]
mark = a.xpath("./div/a/span/span[@class='tag']/text()")[0]
sid = a.xpath("./div/a/@href")[0].replace("/", "").replace("voddetail", "").replace(".html", "")
videos.append({
"vod_id": sid,
"vod_name": name,
"vod_pic": pic,
"vod_remarks": mark
})
result['list'] = videos
result['page'] = pg
result['pagecount'] = 999
result['limit'] = 5
result['total'] = 9999
return result
def detailContent(self, array):
tid = array[0]
url = 'https://www.30dian.cn/voddetail/{0}.html'.format(tid)
header = {"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"}
rsp = self.fetch(url,headers=header)
root = self.html(self.cleanText(rsp.text))
divContent = root.xpath("//div[@class='col-lg-wide-75 col-md-wide-7 col-xs-1 padding-0']")[0]
title = divContent.xpath(".//div[@class='myui-content__detail']/h1/text()")[0]
pic = divContent.xpath(".//div[@class='myui-content__thumb']/a/img/@data-original")[0]
det = divContent.xpath(".//div[@class='col-pd text-collapse content']/span[@class='data']")[0]
if det.text is None:
detail = det.xpath(".//p/text()")[0]
else:
detail = det.text
vod = {
"vod_id": tid,
"vod_name": title,
"vod_pic": pic,
"type_name": "",
"vod_year": "",
"vod_area": "",
"vod_remarks": "",
"vod_actor": "",
"vod_director": "",
"vod_content": detail
}
infoArray = divContent.xpath(".//div[@class='myui-content__detail']/p[contains(@class,'data')]")
for info in infoArray:
content = info.xpath('string(.)')
flag = "分类" in content
if flag == True:
infon = content.replace("\t","").replace("\n","").strip().split('\r')
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_year'] = inf.replace("年份:", "")
if content.startswith('主演'):
vod['vod_actor'] = content.replace("\xa0", "/").replace("主演:", "").strip('/')
if content.startswith('更新'):
vod['vod_remarks'] = content.replace("更新:", "")
if content.startswith('导演'):
vod['vod_director'] = content.replace("\xa0", "").replace("导演:", "").strip('/')
vod_play_from = '$$$'
playFrom = []
vodHeader = divContent.xpath(".//div[@class='myui-panel_hd']/div/ul/li/a[contains(@href,'playlist')]/text()")
for v in vodHeader:
playFrom.append(v.replace(" ", ""))
vod_play_from = vod_play_from.join(playFrom)
vod_play_url = '$$$'
playList = []
vodList = divContent.xpath(".//div[contains(@id,'playlist')]")
for vl in vodList:
vodItems = []
aList = vl.xpath('./ul/li/a')
if len(aList) <= 0:
name = '无法找到播放源'
tId = '00000'
vodItems.append(name + "$" + tId)
else:
for tA in aList:
href = tA.xpath('./@href')[0]
name = tA.xpath("./text()")[0].replace(" ", "")
tId = self.regStr(href, '/vodplay/(\\S+).html')
vodItems.append(name + "$" + tId)
joinStr = '#'
joinStr = joinStr.join(vodItems)
playList.append(joinStr)
vod_play_url = vod_play_url.join(playList)
vod['vod_play_from'] = vod_play_from
vod['vod_play_url'] = vod_play_url
result = {
'list': [
vod
]
}
return result
def searchContent(self, key, quick):
url = 'https://www.30dian.cn/vodsearch/-------------.html?wd={0}'.format(key)
header = {
"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"}
rsp = self.fetch(url, headers=header)
root = self.html(self.cleanText(rsp.text))
aList = root.xpath("//ul[contains(@class,'myui-vodlist__media clearfix')]/li")
videos = []
for a in aList:
name = a.xpath(".//div[@class='detail']/h4/a/text()")[0]
pic = a.xpath(".//a[contains(@class,'myui-vodlist__thumb')]//@data-original")[0]
mark = a.xpath(".//span[@class='tag']/text()")[0]
sid = a.xpath(".//div[@class='detail']/h4/a/@href")[0]
sid = self.regStr(sid,'/voddetail/(\\S+).html')
videos.append({
"vod_id": sid,
"vod_name": name,
"vod_pic": pic,
"vod_remarks": mark
})
result = {
'list': videos
}
return result
def parseCBC(self, enc, key, iv):
keyBytes = key.encode("utf-8")
ivBytes = iv.encode("utf-8")
cipher = AES.new(keyBytes, AES.MODE_CBC, ivBytes)
msg = cipher.decrypt(enc)
paddingLen = msg[len(msg) - 1]
return msg[0:-paddingLen]
def playerContent(self, flag, id, vipFlags):
result = {}
header = {
"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"}
if id == '00000':
return {}
url = 'https://www.30dian.cn/vodplay/{0}.html'.format(id)
rsp = self.fetch(url,headers=header)
root = self.html(self.cleanText(rsp.text))
scripts = root.xpath("//div[@class='embed-responsive clearfix']/script[@type='text/javascript']/text()")[0]
ukey = re.findall(r"url(.*)url_next", scripts)[0].replace('"', "").replace(',', "").replace(':', "")
pf = re.findall(r'\"from\":\"(.*?)\"', scripts)[0]
purl = urllib.parse.unquote(ukey)
if purl.startswith('http'):
purl = purl
if pf == 'wjm3u8':
prsp = self.fetch(purl, headers=header)
purle = prsp.text.strip('\n').split('\n')[-1]
purls = re.findall(r"http.*://.*?/", purl)[0].strip('/')
purl = purls + purle
else:
scrurl = 'https://vip.30dian.cn/?url={0}'.format(purl)
script = self.fetch(scrurl,headers=header)
html = script.text
pat = 'var le_token = \\"([\\d\\w]+)\\"'
cpat = 'getVideoInfo\\(\\"(.*)\\"\\)'
content = self.regStr(html, cpat)
iv = self.regStr(html, pat)
key = 'A42EAC0C2B408472'
purl = self.parseCBC(base64.b64decode(content), key, iv).decode()
result["parse"] = 0
result["playUrl"] = ''
result["url"] = purl
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, ""]