forked from Dong-learn9/TVBox-zyjk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy_cyys.py
216 lines (200 loc) · 8.22 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
# coding=utf-8
# !/usr/bin/python
import sys
import re
sys.path.append('..')
from base.spider import Spider
import urllib.parse
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 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(':', "")
purl = urllib.parse.unquote(ukey)
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, ""]