-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4KAV.py
More file actions
130 lines (111 loc) · 4.38 KB
/
4KAV.py
File metadata and controls
130 lines (111 loc) · 4.38 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
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
# -*- coding: utf-8 -*-
# by @嗷呜
import sys
from pyquery import PyQuery as pq
sys.path.append('..')
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
headers = {
'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',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="134", "Google Chrome";v="134"',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'document',
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.8 Mobile/15E148 Safari/604.1'
}
host = "https://4k-av.com"
def homeContent(self, filter):
data=self.getpq()
result = {}
classes = []
for k in list(data('#category ul li').items())[:-1]:
classes.append({
'type_name': k.text(),
'type_id': k('a').attr('href')
})
result['class'] = classes
result['list'] = self.getlist(data('#MainContent_scrollul ul li'),'.poster span')
return result
def homeVideoContent(self):
pass
def categoryContent(self, tid, pg, filter, extend):
data=self.getpq(f"{tid}page-{pg}.html")
result = {}
result['list'] = self.getlist(data('#MainContent_newestlist .virow .NTMitem'))
result['page'] = pg
result['pagecount'] = 9999
result['limit'] = 90
result['total'] = 999999
return result
def detailContent(self, ids):
data = self.getpq(ids[0])
v = data('#videoinfo')
vod = {
'vod_name': data('#tophead h1').text().split(' ')[0],
'type_name': v('#MainContent_tags.tags a').text(),
'vod_year': v('#MainContent_videodetail.videodetail a').text(),
'vod_remarks': v('#MainContent_titleh12 h2').text(),
'vod_content': v('p.cnline').text(),
'vod_play_from': '4KAV',
'vod_play_url': ''
}
vlist = data('#rtlist li')
jn = f"{vod['vod_name']}_" if 'EP0' in vlist.eq(0)('span').text() else ''
if vlist:
c = [f"{jn}{i('span').text()}${i('a').attr('href')}" for i in list(vlist.items())[1:]]
c.insert(0, f"{jn}{vlist.eq(0)('span').text()}${ids[0]}")
vod['vod_play_url'] = '#'.join(c)
else:
vod['vod_play_url'] = f"{vod['vod_name']}${ids[0]}"
return {'list': [vod]}
def searchContent(self, key, quick, pg="1"):
data=self.getpq(f"/s?k={key}")
return {'list':self.getlist(data('#MainContent_newestlist .virow.search .NTMitem.Main'))}
def playerContent(self, flag, id, vipFlags):
try:
data=self.getpq(id)
p,url=0,data('#MainContent_videowindow source').attr('src')
if not url:raise Exception("未找到播放地址")
except Exception as e:
p,url=1,f"{self.host}{id}"
headers = {
'origin': self.host,
'referer': f'{self.host}/',
'sec-ch-ua-platform': '"macOS"',
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.8 Mobile/15E148 Safari/604.1',
}
return {'parse': p, 'url': url, 'header': headers}
def localProxy(self, param):
pass
def liveContent(self, url):
pass
def getlist(self,data,y='.resyear label[title="分辨率"]'):
videos = []
for i in data.items():
ns = i('.title h2').text().split(' ')
videos.append({
'vod_id': i('.title a').attr('href'),
'vod_name': ns[0],
'vod_pic': i('.poster img').attr('src'),
'vod_remarks': ns[-1] if len(ns) > 1 else '',
'vod_year': i(y).text()
})
return videos
def getpq(self, path=''):
url=f"{self.host}{path}"
data=self.fetch(url,headers=self.headers).text
try:
return pq(data)
except Exception as e:
print(f"{str(e)}")
return pq(data.encode('utf-8'))