-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy_hsck.py
More file actions
97 lines (84 loc) · 3.58 KB
/
py_hsck.py
File metadata and controls
97 lines (84 loc) · 3.58 KB
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
# -*- coding: utf-8 -*-
import json
import re
import sys
from urllib.parse import quote
from pyquery import PyQuery as pq
sys.path.append('..')
from base.spider import Spider
class Spider(Spider):
def init(self, extend='{}'):
self.host=self.getHost()
pass
def destroy(self):
pass
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8"
}
def getHost(self):
url="http://www.hsck.net/"
html=self.fetch(url,headers=self.headers)
script=pq(html.content)("script").text()
match = re.search(r'=[^=]*?"([^"]*)"', script)
if match:
ref = match.group(1)
resp=self.fetch(f"{ref}{url}&p=/",headers=self.headers,allow_redirects=False)
return resp.headers.get("Location")
return "http://1964ck.cc"
def buildVods(self, its):
vods=[]
for item in its.items():
a=item("h4 > a")
if "/vodplay/" not in a.attr("href"):continue
vods.append({
'vod_id': a.attr("href"),
'vod_name': a.text(),
'vod_pic': item("a").attr("data-original"),
'vod_remark': item(".pic-text.text-right").text(),
})
return vods
def homeContent(self, filter):
resp=self.fetch(self.host,headers=self.headers)
doc=pq(resp.content)
c1=doc("ul.stui-header__menu.clearfix > li")
c2=doc("ul.stui-pannel__menu.clearfix > li")
classes,t = [],set()
for j in (c1+c2).items():
a=j("a")
a.remove("span")
href=a.attr("href")
match=re.search(r'\d+', href)
if not match or match.group() in t:continue
t.add(match.group())
classes.append({
'type_name': a.text(),
'type_id': match.group()
})
result = {'class': classes, 'list': self.buildVods(doc("ul.stui-vodlist.clearfix > li"))}
return result
def categoryContent(self, tid, pg, filter, extend):
resp=self.fetch(f"{self.host}/vodtype/{tid}-{pg}.html",headers=self.headers)
doc=pq(resp.content)
result = {'list': self.buildVods(doc("ul.stui-vodlist.clearfix > li")), 'page': pg, 'pagecount': 9999,'limit': 90, 'total': 999999}
return result
def detailContent(self, ids):
url=f"{self.host}{ids[0]}"
resp=self.fetch(url,headers=self.headers)
doc=pq(resp.content)
data=doc(".stui-player__video.clearfix > script").eq(0).text()
script=json.loads(data.split("aaa=",1)[-1])
play=script.get("url") or url
vod = {
'vod_content': doc(".stui-player__foot").text(),
'vod_play_from': 'Hsck',
'vod_play_url': f'{doc(".stui-pannel__head.clearfix > h3").eq(1).text()}${play}'
}
return {'list':[vod]}
def searchContent(self, key, quick, pg="1"):
resp=self.fetch(f"{self.host}/vodsearch/{quote(key)}----------{pg}---.html",headers=self.headers)
doc=pq(resp.content)
return {'list': self.buildVods(doc("ul.stui-vodlist.clearfix > li"))}
def playerContent(self, flag, id, vipFlags):
return {'parse': 0 if ".m3u" in id else 1, 'url': id}