Sync all projects
This commit is contained in:
+31
-115
@@ -36,14 +36,19 @@
|
||||
"api": "csp_YGP",
|
||||
"searchable": 0
|
||||
},
|
||||
{
|
||||
"key": "飞娱影视",
|
||||
"name": "飞鱼 |秒播",
|
||||
"type": 3,
|
||||
"jar": "./xiaosa.jar",
|
||||
"api": "csp_Feiyu"
|
||||
},
|
||||
{
|
||||
"key": "兄弟影视js",
|
||||
"name": "兄弟影视|秒播",
|
||||
"api": "./js/兄弟影视.js",
|
||||
"searchable": 1,
|
||||
"quickSearch": 1,
|
||||
"filterable": 1,
|
||||
"type": 3
|
||||
"key": "山楂影视",
|
||||
"name": "山楂 |影视(ok壳子用)",
|
||||
"type": 3,
|
||||
"jar": "./xiaosa.jar",
|
||||
"api": "csp_PianKu8"
|
||||
},
|
||||
{
|
||||
"key": "马猴影视",
|
||||
@@ -81,7 +86,7 @@
|
||||
"quickSearch": 1,
|
||||
"filterable": 0
|
||||
},
|
||||
{
|
||||
{
|
||||
"key": "高清",
|
||||
"name": "高清 |秒播",
|
||||
"type": 3,
|
||||
@@ -96,20 +101,6 @@
|
||||
"ua": "okhttp/3.10.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "魔方",
|
||||
"name": "魔方 |秒播",
|
||||
"type": 3,
|
||||
"api": "csp_AppGet",
|
||||
"searchable": 1,
|
||||
"changeable": 1,
|
||||
"ext": {
|
||||
"url": "https://www.douy32mf.top",
|
||||
"dataKey": "1234567887654321",
|
||||
"dataIv": "1234567887654321"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"key": "4k",
|
||||
"name": "4k视频|秒播",
|
||||
@@ -170,33 +161,7 @@
|
||||
"filterable": 1,
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"key": "ddys_js",
|
||||
"name": "滴滴|秒播",
|
||||
"api": "./js/ddys.js",
|
||||
"searchable": 1,
|
||||
"quickSearch": 1,
|
||||
"filterable": 1,
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"key": "iysdqjs_js",
|
||||
"name": "山地|秒播",
|
||||
"api": "./js/iysdq.js",
|
||||
"searchable": 1,
|
||||
"quickSearch": 1,
|
||||
"filterable": 1,
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"key": "绿色影视_js",
|
||||
"name": "绿色影视|秒播",
|
||||
"api": "./js/绿色影视.js",
|
||||
"searchable": 1,
|
||||
"quickSearch": 1,
|
||||
"filterable": 1,
|
||||
"type": 3
|
||||
},
|
||||
|
||||
{
|
||||
"key": "小鸭子看看_js",
|
||||
"name": "小鸭子看看|秒播",
|
||||
@@ -206,15 +171,6 @@
|
||||
"filterable": 1,
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"key": "飞鱼",
|
||||
"name": "飞鱼|秒播",
|
||||
"type": 3,
|
||||
"api": "./py/飞鱼.py",
|
||||
"searchable": 1,
|
||||
"quickSearch": 1,
|
||||
"filterable": 0
|
||||
},
|
||||
{
|
||||
"key": "BT",
|
||||
"name": "两个BT|影视",
|
||||
@@ -380,28 +336,6 @@
|
||||
"changeable": 1,
|
||||
"filterable": 1
|
||||
},
|
||||
{
|
||||
"key": "山楂影视",
|
||||
"name": "山楂|影视(ok壳子用)",
|
||||
"type": 3,
|
||||
"api": "./py/山楂影视.py",
|
||||
"searchable": 1,
|
||||
"quickSearch": 1,
|
||||
"changeable": 1,
|
||||
"filterable": 1
|
||||
},
|
||||
{
|
||||
"key": "茶杯狐",
|
||||
"name": "茶杯狐|秒播",
|
||||
"type": 3,
|
||||
"api": "csp_XBPQ",
|
||||
"jar": "https://pan.szfx.top/down.php/a81c03da23212c9ffc8a699465dedc8b.jar",
|
||||
"quickSearch": 1,
|
||||
"ext": {
|
||||
"分类url": "https://www.china-itrade.com/zform-list/{cateId}-----------.html",
|
||||
"分类": "电影$1#剧集$2#动漫$4#综艺$3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "爱影视",
|
||||
"name": "爱影视|秒播",
|
||||
@@ -745,25 +679,6 @@
|
||||
"api": "csp_XBPQ",
|
||||
"ext": "./js/先生.js"
|
||||
},
|
||||
{
|
||||
"key": "威武┃影视",
|
||||
"name": "威武|秒播",
|
||||
"type": 3,
|
||||
"api": "./py/威武.py",
|
||||
"ext": "http://43.248.117.123:4680",
|
||||
"quickSearch": 1
|
||||
},
|
||||
{
|
||||
"key": "布布┃影视",
|
||||
"name": "布布|秒播",
|
||||
"type": 3,
|
||||
"api": "./py/布布.py",
|
||||
"style": {
|
||||
"type": "rect",
|
||||
"ratio": 1.33
|
||||
},
|
||||
"quickSearch": 1
|
||||
},
|
||||
{
|
||||
"key": "裤佬独家免扫4K",
|
||||
"name": "独家|秒播",
|
||||
@@ -1312,11 +1227,11 @@
|
||||
},
|
||||
"timeout": 60
|
||||
},
|
||||
{
|
||||
"key": "河马短剧",
|
||||
"name": "河马|短剧",
|
||||
{
|
||||
"key": "笒鬼短剧",
|
||||
"name": "笒鬼 | 短剧",
|
||||
"type": 3,
|
||||
"api": "csp_HemaDJ",
|
||||
"api": "csp_CenguiDJ",
|
||||
"searchable": 1,
|
||||
"changeable": 1,
|
||||
"quickSearch": 1,
|
||||
@@ -1325,7 +1240,7 @@
|
||||
},
|
||||
{
|
||||
"key": "好看短剧",
|
||||
"name": "好看|短剧",
|
||||
"name": "好看 | 短剧",
|
||||
"type": 3,
|
||||
"api": "csp_HaokanDJ",
|
||||
"searchable": 1,
|
||||
@@ -1335,10 +1250,10 @@
|
||||
"genre": "shortdrama"
|
||||
},
|
||||
{
|
||||
"key": "围观短剧",
|
||||
"name": "围观|短剧",
|
||||
"key": "星芽短剧",
|
||||
"name": "星芽 | 短剧",
|
||||
"type": 3,
|
||||
"api": "csp_WeiguanDJ",
|
||||
"api": "./lib/XYDJ.py",
|
||||
"searchable": 1,
|
||||
"changeable": 1,
|
||||
"quickSearch": 1,
|
||||
@@ -1346,15 +1261,16 @@
|
||||
"genre": "shortdrama"
|
||||
},
|
||||
{
|
||||
"key": "星芽短剧",
|
||||
"name": "星芽|短剧",
|
||||
"key": "果果短剧",
|
||||
"name": "果果 | 短剧",
|
||||
"type": 3,
|
||||
"api": "./lib/星芽短剧.py",
|
||||
"searchable": 1,
|
||||
"changeable": 1,
|
||||
"quickSearch": 1,
|
||||
"filterable": 1,
|
||||
"genre": "shortdrama"
|
||||
"api": "csp_XBPQ",
|
||||
"ext": {
|
||||
"请求头": "User-Agent$MOBILE_UA",
|
||||
"编码": "UTF-8",
|
||||
"分类": "重生$1#穿越$2#爽剧$3#言情$4#都市$5#古装$6#悬疑$7#剧情$8",
|
||||
"分类url": "https://www.mochadj.com/i/{cateId}-{catePg}.html"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
@@ -1 +1 @@
|
||||
http://110.42.67.221:9004
|
||||
http://110.42.67.221:8004
|
||||
@@ -1 +1 @@
|
||||
http://43.251.227.45:3688
|
||||
http://103.236.72.182:3688
|
||||
@@ -0,0 +1,81 @@
|
||||
{
|
||||
"规则名": "动漫巴士",
|
||||
"规则作者": "",
|
||||
"请求头参数": "User-Agent$MOBILE_UA#Accept$text/html#accept-language$zh-CN,zh;q=0.8",
|
||||
"网页编码格式": "UTF-8",
|
||||
"图片是否需要代理": "0",
|
||||
"是否开启获取首页数据": "1",
|
||||
"首页推荐链接": "https://dm84.net",
|
||||
"首页列表数组规则": "body&&.v_list",
|
||||
"首页片单列表数组规则": "li",
|
||||
"首页片单是否Jsoup写法": "1",
|
||||
"分类起始页码": "1",
|
||||
"分类链接": "https://dm84.net/list-{cateId}-{catePg}.html[firstPage=https://dm84.net/list-{cateId}.html]",
|
||||
"分类名称": "国产动漫&日本动漫&欧美动漫&动漫电影",
|
||||
"分类名称替换词": "1&2&3&4",
|
||||
"筛选数据": {},
|
||||
//"筛选数据": "ext",
|
||||
//{cateId}
|
||||
"筛选子分类名称": "",
|
||||
"筛选子分类替换词": "",
|
||||
//{class}
|
||||
"筛选类型名称": "",
|
||||
"筛选类型替换词": "*",
|
||||
//{area}
|
||||
"筛选地区名称": "",
|
||||
"筛选地区替换词": "*",
|
||||
//{year}
|
||||
"筛选年份名称": "",
|
||||
"筛选年份替换词": "*",
|
||||
//{lang}
|
||||
"筛选语言名称": "",
|
||||
"筛选语言替换词": "*",
|
||||
//{by}
|
||||
"筛选排序名称": "时间&人气&评分",
|
||||
"筛选排序替换词": "time&hits&score",
|
||||
"分类截取模式": "1",
|
||||
"分类列表数组规则": ".v_list&&li",
|
||||
"分类片单是否Jsoup写法": "1",
|
||||
"分类片单标题": "a&&title!在线观看",
|
||||
"分类片单链接": "a&&href",
|
||||
"分类片单图片": ".lazy&&data-bg",
|
||||
"分类片单副标题": ".desc&&Text",
|
||||
"分类片单链接加前缀": "https://dm84.net",
|
||||
"分类片单链接加后缀": "",
|
||||
"搜索请求头参数": "User-Agent$手机#Accept$text/html#accept-language$zh-CN,zh;q=0.8",
|
||||
"搜索链接": "https://dm84.net/s-{wd}---------{SearchPg}.html",
|
||||
"POST请求数据": "",
|
||||
"搜索截取模式": "1",
|
||||
"搜索列表数组规则": ".v_list&&li",
|
||||
"搜索片单是否Jsoup写法": "1",
|
||||
"搜索片单图片": ".lazy&&data-bg",
|
||||
"搜索片单标题": "a&&title!在线观看",
|
||||
"搜索片单链接": "a&&href",
|
||||
"搜索片单副标题": ".desc&&Text",
|
||||
"搜索片单链接加前缀": "https://dm84.net",
|
||||
"搜索片单链接加后缀": "",
|
||||
"链接是否直接播放": "0",
|
||||
"直接播放链接加前缀": "",
|
||||
"直接播放链接加后缀": "",
|
||||
"直接播放直链视频请求头": "",
|
||||
"详情是否Jsoup写法": "1",
|
||||
"类型详情": "",
|
||||
"年代详情": "",
|
||||
"地区详情": "",
|
||||
"演员详情": "",
|
||||
"简介详情": ".intro&&-p&&Text",
|
||||
"线路列表数组规则": ".play_from&&li",
|
||||
"线路标题": "Text",
|
||||
"播放列表数组规则": ".tab_content&&.play_list",
|
||||
"选集列表数组规则": "a",
|
||||
"选集标题链接是否Jsoup写法": "1",
|
||||
"选集标题": "a&&Text",
|
||||
"选集链接": "a&&href",
|
||||
"是否反转选集序列": "1",
|
||||
"选集链接加前缀": "https://dm84.net",
|
||||
"选集链接加后缀": "",
|
||||
"分析MacPlayer": "0",
|
||||
"是否开启手动嗅探": "0",
|
||||
"手动嗅探视频链接关键词": ".mp4#.m3u8#.flv#video/tos",
|
||||
"手动嗅探视频链接过滤词": ".html#=http"
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
var rule = {
|
||||
title: "路漫漫",
|
||||
host: "https://www.lmm50.com",
|
||||
host: "https://www.lmm85.com",
|
||||
url: "/vod/show/id/fyclassfyfilter.html",
|
||||
searchUrl: '/vod/search/page/fypage/wd/**.html',
|
||||
searchable: 2,
|
||||
|
||||
@@ -0,0 +1,343 @@
|
||||
# coding = utf-8
|
||||
# !/usr/bin/python
|
||||
|
||||
"""
|
||||
"""
|
||||
|
||||
from Crypto.Util.Padding import unpad
|
||||
from Crypto.Util.Padding import pad
|
||||
from urllib.parse import unquote
|
||||
from Crypto.Cipher import ARC4
|
||||
from urllib.parse import quote
|
||||
from base.spider import Spider
|
||||
from Crypto.Cipher import AES
|
||||
from bs4 import BeautifulSoup
|
||||
from base64 import b64decode
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import binascii
|
||||
import requests
|
||||
import base64
|
||||
import json
|
||||
import time
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
sys.path.append('..')
|
||||
|
||||
xurl = "https://app.whjzjx.cn"
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'Linux; Android 12; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.101 Mobile Safari/537.36'
|
||||
}
|
||||
|
||||
headerf = {
|
||||
"platform": "1",
|
||||
"user_agent": "Mozilla/5.0 (Linux; Android 9; V1938T Build/PQ3A.190705.08211809; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.114 Safari/537.36",
|
||||
"content-type": "application/json; charset=utf-8"
|
||||
}
|
||||
|
||||
times = int(time.time() * 1000)
|
||||
|
||||
data = {
|
||||
"device": "2a50580e69d38388c94c93605241fb306",
|
||||
"package_name": "com.jz.xydj",
|
||||
"android_id": "ec1280db12795506",
|
||||
"install_first_open": True,
|
||||
"first_install_time": 1752505243345,
|
||||
"last_update_time": 1752505243345,
|
||||
"report_link_url": "",
|
||||
"authorization": "",
|
||||
"timestamp": times
|
||||
}
|
||||
|
||||
plain_text = json.dumps(data, separators=(',', ':'), ensure_ascii=False)
|
||||
|
||||
key = "B@ecf920Od8A4df7"
|
||||
key_bytes = key.encode('utf-8')
|
||||
plain_bytes = plain_text.encode('utf-8')
|
||||
cipher = AES.new(key_bytes, AES.MODE_ECB)
|
||||
padded_data = pad(plain_bytes, AES.block_size)
|
||||
ciphertext = cipher.encrypt(padded_data)
|
||||
encrypted = base64.b64encode(ciphertext).decode('utf-8')
|
||||
|
||||
response = requests.post("https://u.shytkjgs.com/user/v3/account/login", headers=headerf, data=encrypted)
|
||||
response_data = response.json()
|
||||
Authorization = response_data['data']['token']
|
||||
|
||||
headerx = {
|
||||
'authorization': Authorization,
|
||||
'platform': '1',
|
||||
'version_name': '3.8.3.1'
|
||||
}
|
||||
|
||||
class Spider(Spider):
|
||||
global xurl
|
||||
global headerx
|
||||
global headers
|
||||
|
||||
def getName(self):
|
||||
return "首页"
|
||||
|
||||
def init(self, extend):
|
||||
pass
|
||||
|
||||
def isVideoFormat(self, url):
|
||||
pass
|
||||
|
||||
def manualVideoCheck(self):
|
||||
pass
|
||||
|
||||
def extract_middle_text(self, text, start_str, end_str, pl, start_index1: str = '', end_index2: str = ''):
|
||||
if pl == 3:
|
||||
plx = []
|
||||
while True:
|
||||
start_index = text.find(start_str)
|
||||
if start_index == -1:
|
||||
break
|
||||
end_index = text.find(end_str, start_index + len(start_str))
|
||||
if end_index == -1:
|
||||
break
|
||||
middle_text = text[start_index + len(start_str):end_index]
|
||||
plx.append(middle_text)
|
||||
text = text.replace(start_str + middle_text + end_str, '')
|
||||
if len(plx) > 0:
|
||||
purl = ''
|
||||
for i in range(len(plx)):
|
||||
matches = re.findall(start_index1, plx[i])
|
||||
output = ""
|
||||
for match in matches:
|
||||
match3 = re.search(r'(?:^|[^0-9])(\d+)(?:[^0-9]|$)', match[1])
|
||||
if match3:
|
||||
number = match3.group(1)
|
||||
else:
|
||||
number = 0
|
||||
if 'http' not in match[0]:
|
||||
output += f"#{match[1]}${number}{xurl}{match[0]}"
|
||||
else:
|
||||
output += f"#{match[1]}${number}{match[0]}"
|
||||
output = output[1:]
|
||||
purl = purl + output + "$$$"
|
||||
purl = purl[:-3]
|
||||
return purl
|
||||
else:
|
||||
return ""
|
||||
else:
|
||||
start_index = text.find(start_str)
|
||||
if start_index == -1:
|
||||
return ""
|
||||
end_index = text.find(end_str, start_index + len(start_str))
|
||||
if end_index == -1:
|
||||
return ""
|
||||
|
||||
if pl == 0:
|
||||
middle_text = text[start_index + len(start_str):end_index]
|
||||
return middle_text.replace("\\", "")
|
||||
|
||||
if pl == 1:
|
||||
middle_text = text[start_index + len(start_str):end_index]
|
||||
matches = re.findall(start_index1, middle_text)
|
||||
if matches:
|
||||
jg = ' '.join(matches)
|
||||
return jg
|
||||
|
||||
if pl == 2:
|
||||
middle_text = text[start_index + len(start_str):end_index]
|
||||
matches = re.findall(start_index1, middle_text)
|
||||
if matches:
|
||||
new_list = [f'{item}' for item in matches]
|
||||
jg = '$$$'.join(new_list)
|
||||
return jg
|
||||
|
||||
def homeContent(self, filter):
|
||||
result = {}
|
||||
result = {"class": [{"type_id": "1", "type_name": "剧场"},
|
||||
{"type_id": "3", "type_name": "新剧"},
|
||||
{"type_id": "2", "type_name": "热播"},
|
||||
{"type_id": "7", "type_name": "星选"},
|
||||
{"type_id": "5", "type_name": "阳光"}],
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
def homeVideoContent(self):
|
||||
videos = []
|
||||
|
||||
url= f'{xurl}/v1/theater/home_page?theater_class_id=1&class2_id=4&page_num=1&page_size=24'
|
||||
detail = requests.get(url=url, headers=headerx)
|
||||
detail.encoding = "utf-8"
|
||||
if detail.status_code == 200:
|
||||
data = detail.json()
|
||||
|
||||
for vod in data['data']['list']:
|
||||
|
||||
name = vod['theater']['title']
|
||||
|
||||
id = vod['theater']['id']
|
||||
|
||||
pic = vod['theater']['cover_url']
|
||||
|
||||
remark = vod['theater']['play_amount_str']
|
||||
|
||||
video = {
|
||||
"vod_id": id,
|
||||
"vod_name": name,
|
||||
"vod_pic": pic,
|
||||
"vod_remarks": remark
|
||||
}
|
||||
videos.append(video)
|
||||
|
||||
result = {'list': videos}
|
||||
return result
|
||||
|
||||
def categoryContent(self, cid, pg, filter, ext):
|
||||
result = {}
|
||||
videos = []
|
||||
|
||||
url = f'{xurl}/v1/theater/home_page?theater_class_id={cid}&page_num={pg}&page_size=24'
|
||||
detail = requests.get(url=url,headers=headerx)
|
||||
detail.encoding = "utf-8"
|
||||
if detail.status_code == 200:
|
||||
data = detail.json()
|
||||
|
||||
for vod in data['data']['list']:
|
||||
|
||||
name = vod['theater']['title']
|
||||
|
||||
id = vod['theater']['id']
|
||||
|
||||
pic = vod['theater']['cover_url']
|
||||
|
||||
remark = vod['theater']['theme']
|
||||
|
||||
video = {
|
||||
"vod_id": id,
|
||||
"vod_name": name,
|
||||
"vod_pic": pic,
|
||||
"vod_remarks": remark
|
||||
}
|
||||
videos.append(video)
|
||||
|
||||
result = {'list': videos}
|
||||
result['page'] = pg
|
||||
result['pagecount'] = 9999
|
||||
result['limit'] = 90
|
||||
result['total'] = 999999
|
||||
return result
|
||||
|
||||
def detailContent(self, ids):
|
||||
did = ids[0]
|
||||
result = {}
|
||||
videos = []
|
||||
xianlu = ''
|
||||
bofang = ''
|
||||
|
||||
url = f'{xurl}/v2/theater_parent/detail?theater_parent_id={did}'
|
||||
detail = requests.get(url=url, headers=headerx)
|
||||
detail.encoding = "utf-8"
|
||||
if detail.status_code == 200:
|
||||
data = detail.json()
|
||||
|
||||
url = 'https://fs-im-kefu.7moor-fs1.com/ly/4d2c3f00-7d4c-11e5-af15-41bf63ae4ea0/1732707176882/jiduo.txt'
|
||||
response = requests.get(url)
|
||||
response.encoding = 'utf-8'
|
||||
code = response.text
|
||||
name = self.extract_middle_text(code, "s1='", "'", 0)
|
||||
Jumps = self.extract_middle_text(code, "s2='", "'", 0)
|
||||
|
||||
content = '剧情:' + data['data']['introduction']
|
||||
|
||||
area = data['data']['desc_tags'][0]
|
||||
|
||||
remarks = data['data']['filing']
|
||||
|
||||
# 修复剧集只有一集的问题 - 检查theaters数据是否存在且不为空
|
||||
if 'theaters' in data['data'] and data['data']['theaters']:
|
||||
for sou in data['data']['theaters']:
|
||||
id = sou['son_video_url']
|
||||
name = sou['num']
|
||||
bofang = bofang + str(name) + '$' + id + '#'
|
||||
|
||||
bofang = bofang[:-1] if bofang.endswith('#') else bofang
|
||||
xianlu = '星芽'
|
||||
else:
|
||||
# 如果没有theaters数据,检查是否有单个视频URL
|
||||
if 'video_url' in data['data'] and data['data']['video_url']:
|
||||
bofang = '1$' + data['data']['video_url']
|
||||
xianlu = '星芽'
|
||||
else:
|
||||
bofang = Jumps
|
||||
xianlu = '1'
|
||||
|
||||
videos.append({
|
||||
"vod_id": did,
|
||||
"vod_content": content,
|
||||
"vod_remarks": remarks,
|
||||
"vod_area": area,
|
||||
"vod_play_from": xianlu,
|
||||
"vod_play_url": bofang
|
||||
})
|
||||
|
||||
result['list'] = videos
|
||||
return result
|
||||
|
||||
def playerContent(self, flag, id, vipFlags):
|
||||
|
||||
result = {}
|
||||
result["parse"] = 0
|
||||
result["playUrl"] = ''
|
||||
result["url"] = id
|
||||
result["header"] = headers
|
||||
return result
|
||||
|
||||
def searchContentPage(self, key, quick, page):
|
||||
result = {}
|
||||
videos = []
|
||||
|
||||
payload = {
|
||||
"text": key
|
||||
}
|
||||
|
||||
url = f"{xurl}/v3/search"
|
||||
detail = requests.post(url=url, headers=headerx, json=payload)
|
||||
if detail.status_code == 200:
|
||||
detail.encoding = "utf-8"
|
||||
data = detail.json()
|
||||
|
||||
for vod in data['data']['theater']['search_data']:
|
||||
|
||||
name = vod['title']
|
||||
|
||||
id = vod['id']
|
||||
|
||||
pic = vod['cover_url']
|
||||
|
||||
remark = vod['score_str']
|
||||
|
||||
video = {
|
||||
"vod_id": id,
|
||||
"vod_name": name,
|
||||
"vod_pic": pic,
|
||||
"vod_remarks": remark
|
||||
}
|
||||
videos.append(video)
|
||||
|
||||
result['list'] = videos
|
||||
result['page'] = page
|
||||
result['pagecount'] = 9999
|
||||
result['limit'] = 90
|
||||
result['total'] = 999999
|
||||
return result
|
||||
|
||||
def searchContent(self, key, quick, pg="1"):
|
||||
return self.searchContentPage(key, quick, '1')
|
||||
|
||||
def localProxy(self, params):
|
||||
if params['type'] == "m3u8":
|
||||
return self.proxyM3u8(params)
|
||||
elif params['type'] == "media":
|
||||
return self.proxyMedia(params)
|
||||
elif params['type'] == "ts":
|
||||
return self.proxyTs(params)
|
||||
return None
|
||||
+502
-240
@@ -1,240 +1,502 @@
|
||||
import re
|
||||
import sys
|
||||
from base64 import b64encode, b64decode
|
||||
from urllib.parse import quote, unquote
|
||||
from pyquery import PyQuery as pq
|
||||
from requests import Session, adapters
|
||||
from urllib3.util.retry import Retry
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
sys.path.append('..')
|
||||
from base.spider import Spider
|
||||
|
||||
class Spider(Spider):
|
||||
def init(self, extend=""):
|
||||
self.host = "https://www.22a5.com"
|
||||
self.session = Session()
|
||||
adapter = adapters.HTTPAdapter(max_retries=Retry(total=3, backoff_factor=0.5, status_forcelist=[429, 500, 502, 503, 504]), pool_connections=20, pool_maxsize=50)
|
||||
self.session.mount("http://", adapter)
|
||||
self.session.mount("https://", adapter)
|
||||
self.headers = {"User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36"}
|
||||
self.session.headers.update(self.headers)
|
||||
|
||||
def getName(self): return "爱听音乐"
|
||||
def isVideoFormat(self, url): return bool(re.search(r'\.(m3u8|mp4|mp3|m4a|flv)(\?|$)', url or "", re.I))
|
||||
def manualVideoCheck(self): return False
|
||||
def destroy(self): self.session.close()
|
||||
|
||||
def homeContent(self, filter):
|
||||
classes = [{"type_name": n, "type_id": i} for n, i in [("歌手","/singerlist/index/index/index/index.html"), ("TOP榜单","/list/top.html"), ("新歌榜","/list/new.html"), ("电台","/radiolist/index.html"), ("高清MV","/mvlist/oumei.html"), ("专辑","/albumlist/index.html"), ("歌单","/playtype/index.html")]]
|
||||
filters = {p: d for p in [c["type_id"] for c in classes if "singer" not in c["type_id"]] if (d := self._fetch_filters(p))}
|
||||
|
||||
if "/radiolist/index.html" not in filters:
|
||||
filters["/radiolist/index.html"] = [{"key": "id", "name": "分类", "value": [{"n": n, "v": v} for n,v in zip(["最新","最热","有声小说","相声","音乐","情感","国漫","影视","脱口秀","历史","儿童","教育","八卦","推理","头条"], ["index","hot","novel","xiangyi","music","emotion","game","yingshi","talkshow","history","children","education","gossip","tuili","headline"])]}]
|
||||
|
||||
filters["/singerlist/index/index/index/index.html"] = [
|
||||
{"key": "area", "name": "地区", "value": [{"n": n, "v": v} for n,v in [("全部","index"),("华语","huayu"),("欧美","oumei"),("韩国","hanguo"),("日本","ribrn")]]},
|
||||
{"key": "sex", "name": "性别", "value": [{"n": n, "v": v} for n,v in [("全部","index"),("男","male"),("女","girl"),("组合","band")]]},
|
||||
{"key": "genre", "name": "流派", "value": [{"n": n, "v": v} for n,v in [("全部","index"),("流行","liuxing"),("电子","dianzi"),("摇滚","yaogun"),("嘻哈","xiha"),("R&B","rb"),("民谣","minyao"),("爵士","jueshi"),("古典","gudian")]]},
|
||||
{"key": "char", "name": "字母", "value": [{"n": n, "v": v} for n,v in [("全部","index")] + [{"n": chr(i), "v": chr(i).lower()} for i in range(65, 91)]]}
|
||||
]
|
||||
return {"class": classes, "filters": filters, "list": []}
|
||||
|
||||
def homeVideoContent(self): return {"list": []}
|
||||
|
||||
def categoryContent(self, tid, pg, filter, extend):
|
||||
pg = int(pg or 1)
|
||||
url = tid
|
||||
if "/singerlist/" in tid:
|
||||
p = tid.split('/')
|
||||
if len(p) >= 6:
|
||||
url = "/".join(p[:2] + [extend.get(k, p[i]) for i, k in enumerate(["area", "sex", "genre"], 2)] + [f"{extend.get('char', 'index')}.html"])
|
||||
elif "id" in extend and extend["id"] not in ["index", "top"]:
|
||||
url = tid.replace("index.html", f"{extend['id']}.html").replace("top.html", f"{extend['id']}.html")
|
||||
if url == tid: url = f"{tid.rsplit('/', 1)[0]}/{extend['id']}.html"
|
||||
|
||||
if pg > 1:
|
||||
sep = "/" if any(x in url for x in ["/singerlist/", "/radiolist/", "/mvlist/", "/playtype/", "/list/"]) else "_"
|
||||
url = re.sub(r'(_\d+|/\d+)?\.html$', f'{sep}{pg}.html', url)
|
||||
|
||||
doc = self.getpq(url)
|
||||
return {"list": self._parse_list(doc(".play_list li, .video_list li, .pic_list li, .singer_list li, .ali li, .layui-row li, .base_l li"), tid), "page": pg, "pagecount": 9999, "limit": 90, "total": 999999}
|
||||
|
||||
def searchContent(self, key, quick, pg="1"):
|
||||
return {"list": self._parse_list(self.getpq(f"/so/{quote(key)}/{pg}.html")(".base_l li, .play_list li"), "search"), "page": int(pg)}
|
||||
|
||||
def detailContent(self, ids):
|
||||
url = self._abs(ids[0])
|
||||
doc = self.getpq(url)
|
||||
vod = {"vod_id": url, "vod_name": self._clean(doc("h1").text() or doc("title").text()), "vod_pic": self._abs(doc(".djpg img, .pic img, .djpic img").attr("src")), "vod_play_from": "爱听音乐", "vod_content": ""}
|
||||
|
||||
if any(x in url for x in ["/playlist/", "/album/", "/list/", "/singer/", "/special/", "/radio/", "/radiolist/"]):
|
||||
eps = self._get_eps(doc)
|
||||
page_urls = {self._abs(a.attr("href")) for a in doc(".page a, .dede_pages a, .pagelist a").items() if a.attr("href") and "javascript" not in a.attr("href")} - {url}
|
||||
if page_urls:
|
||||
with ThreadPoolExecutor(max_workers=5) as ex:
|
||||
for r in as_completed([ex.submit(lambda u: self._get_eps(self.getpq(u)), u) for u in sorted(page_urls, key=lambda x: int(re.search(r'[_\/](\d+)\.html', x).group(1)) if re.search(r'[_\/](\d+)\.html', x) else 0)]):
|
||||
eps.extend(r.result() or [])
|
||||
if eps:
|
||||
vod.update({"vod_play_from": "播放列表", "vod_play_url": "#".join(eps)})
|
||||
return {"list": [vod]}
|
||||
|
||||
play_list = []
|
||||
if mid := re.search(r'/(song|mp3|radio|radiolist|radioplay)/([^/]+)\.html', url):
|
||||
lrc_url = f"{self.host}/plug/down.php?ac=music&lk=lrc&id={mid.group(2)}"
|
||||
play_list = [f"播放${self.e64('0@@@@' + url + '|||' + lrc_url)}"]
|
||||
|
||||
elif vid := re.search(r'/(video|mp4)/([^/]+)\.html', url):
|
||||
with ThreadPoolExecutor(max_workers=3) as ex:
|
||||
fs = {ex.submit(self._api, "/plug/down.php", {"ac": "vplay", "id": vid.group(2), "q": q}): n for n, q in [("蓝光", 1080), ("超清", 720), ("高清", 480)]}
|
||||
play_list = [f"{fs[f]}${self.e64('0@@@@'+u)}" for f in as_completed(fs) if (u := f.result())]
|
||||
play_list.sort(key=lambda x: {"蓝":0, "超":1, "高":2}.get(x[0], 3))
|
||||
|
||||
vod["vod_play_url"] = "#".join(play_list) if play_list else f"解析失败${self.e64('1@@@@'+url)}"
|
||||
return {"list": [vod]}
|
||||
|
||||
def playerContent(self, flag, id, vipFlags):
|
||||
raw = self.d64(id).split("@@@@")[-1]
|
||||
url, subt = raw.split("|||") if "|||" in raw else (raw, "")
|
||||
url = url.replace(r"\/", "/")
|
||||
|
||||
if ".html" in url and not self.isVideoFormat(url):
|
||||
if mid := re.search(r'/(song|mp3|radio|radiolist|radioplay)/([^/]+)\.html', url):
|
||||
if r_url := self._api("/js/play.php", method="POST", data={"id": mid.group(2), "type": "music"}, headers={"Referer": url.replace("http://","https://"), "X-Requested-With": "XMLHttpRequest"}):
|
||||
url = r_url if ".php" not in r_url else url
|
||||
elif vid := re.search(r'/(video|mp4)/([^/]+)\.html', url):
|
||||
with ThreadPoolExecutor(max_workers=3) as ex:
|
||||
for f in as_completed([ex.submit(self._api, "/plug/down.php", {"ac": "vplay", "id": vid.group(2), "q": q}) for q in [1080, 720, 480]]):
|
||||
if v_url := f.result():
|
||||
url = v_url; break
|
||||
|
||||
result = {"parse": 0, "url": url, "header": {"User-Agent": self.headers["User-Agent"]}}
|
||||
if "22a5.com" in url: result["header"]["Referer"] = self.host + "/"
|
||||
|
||||
# OK影视3.6.5+支持LRC格式滚动歌词
|
||||
if subt:
|
||||
try:
|
||||
r = self.session.get(subt, headers={"Referer": self.host + "/"}, timeout=5)
|
||||
lrc_content = r.text
|
||||
if lrc_content:
|
||||
# 过滤广告内容
|
||||
lrc_content = self._filter_lrc_ads(lrc_content)
|
||||
result["lrc"] = lrc_content
|
||||
except:
|
||||
pass
|
||||
|
||||
return result
|
||||
|
||||
def _filter_lrc_ads(self, lrc_text):
|
||||
"""过滤LRC歌词中的广告内容"""
|
||||
lines = lrc_text.splitlines()
|
||||
filtered_lines = []
|
||||
|
||||
# 广告关键词模式
|
||||
ad_patterns = [
|
||||
r'欢迎来访.*',
|
||||
r'本站.*',
|
||||
r'.*广告.*',
|
||||
r'QQ群.*',
|
||||
r'.*www\..*',
|
||||
r'.*http.*',
|
||||
r'.*\.com.*',
|
||||
r'.*\.cn.*',
|
||||
r'.*\.net.*',
|
||||
r'.*音乐网.*',
|
||||
r'.*提供.*',
|
||||
r'.*下载.*',
|
||||
]
|
||||
|
||||
for line in lines:
|
||||
# 保留时间标签行,但过滤掉广告文本
|
||||
if re.match(r'\[\d{2}:\d{2}', line):
|
||||
# 检查是否包含广告
|
||||
is_ad = False
|
||||
for pattern in ad_patterns:
|
||||
if re.search(pattern, line, re.IGNORECASE):
|
||||
is_ad = True
|
||||
break
|
||||
|
||||
if not is_ad:
|
||||
filtered_lines.append(line)
|
||||
else:
|
||||
# 非时间标签行(可能是元数据),保留
|
||||
filtered_lines.append(line)
|
||||
|
||||
return '\n'.join(filtered_lines)
|
||||
|
||||
def localProxy(self, param):
|
||||
url = unquote(param.get("url", ""))
|
||||
type_ = param.get("type")
|
||||
|
||||
if type_ == "img":
|
||||
return [200, "image/jpeg", self.session.get(url, headers={"Referer": self.host + "/"}, timeout=5).content, {}]
|
||||
|
||||
elif type_ == "lrc":
|
||||
try:
|
||||
r = self.session.get(url, headers={"Referer": self.host + "/"}, timeout=5)
|
||||
# 同时过滤代理中的广告
|
||||
lrc_content = r.text
|
||||
lrc_content = self._filter_lrc_ads(lrc_content)
|
||||
return [200, "application/octet-stream", lrc_content.encode('utf-8'), {}]
|
||||
except:
|
||||
return [404, "text/plain", "Error", {}]
|
||||
|
||||
return None
|
||||
|
||||
def _parse_list(self, items, tid=""):
|
||||
res = []
|
||||
for li in items.items():
|
||||
a = li("a").eq(0)
|
||||
if not (href := a.attr("href")) or href == "/" or any(x in href for x in ["/user/", "/login/", "javascript"]): continue
|
||||
if not (name := self._clean(li(".name").text() or a.attr("title") or a.text())): continue
|
||||
pic = self._abs((li("img").attr("src") or "").replace('120', '500'))
|
||||
res.append({"vod_id": self._abs(href), "vod_name": name, "vod_pic": f"{self.getProxyUrl()}&url={pic}&type=img" if pic else "", "style": {"type": "oval" if "/singer/" in href else ("list" if any(x in tid for x in ["/list/", "/playtype/", "/albumlist/"]) else "rect"), "ratio": 1 if "/singer/" in href else 1.33}})
|
||||
return res
|
||||
|
||||
def _get_eps(self, doc):
|
||||
eps = []
|
||||
for li in doc(".play_list li, .song_list li, .music_list li").items():
|
||||
if not (a := li("a").eq(0)).attr("href") or not re.search(r'/(song|mp3|radio|radiolist|radioplay)/([^/]+)\.html', a.attr("href")): continue
|
||||
full_url = self._abs(a.attr("href"))
|
||||
|
||||
lrc_part = ""
|
||||
mid = re.search(r'/(song|mp3|radio|radiolist|radioplay)/([^/]+)\.html', full_url)
|
||||
if mid:
|
||||
lrc_url = f"{self.host}/plug/down.php?ac=music&lk=lrc&id={mid.group(2)}"
|
||||
lrc_part = f"|||{lrc_url}"
|
||||
|
||||
eps.append(f"{self._clean(a.text() or li('.name').text())}${self.e64('0@@@@' + full_url + lrc_part)}")
|
||||
return eps
|
||||
|
||||
def _clean(self, text): return re.sub(r'(爱玩音乐网|视频下载说明|视频下载地址|www\.2t58\.com|MP3免费下载|LRC歌词下载|全部歌曲|\[第\d+页\]|刷新|每日推荐|最新|热门|推荐|MV|高清|无损)', '', text or "", flags=re.I).strip()
|
||||
|
||||
def _fetch_filters(self, url):
|
||||
doc, filters = self.getpq(url), []
|
||||
for i, group in enumerate([doc(s) for s in [".ilingku_fl", ".class_list", ".screen_list", ".box_list", ".nav_list"] if doc(s)]):
|
||||
opts, seen = [{"n": "全部", "v": "top" if "top" in url else "index"}], set()
|
||||
for a in group("a").items():
|
||||
if (v := (a.attr("href") or "").split("?")[0].rstrip('/').split('/')[-1].replace('.html','')) and v not in seen:
|
||||
opts.append({"n": a.text().strip(), "v": v}); seen.add(v)
|
||||
if len(opts) > 1: filters.append({"key": f"id{i}" if i else "id", "name": "分类", "value": opts})
|
||||
return filters
|
||||
|
||||
def _api(self, path, params=None, method="GET", headers=None, data=None):
|
||||
try:
|
||||
h = self.headers.copy()
|
||||
if headers: h.update(headers)
|
||||
r = (self.session.post if method == "POST" else self.session.get)(f"{self.host}{path}", params=params, data=data, headers=h, timeout=10, allow_redirects=False)
|
||||
if loc := r.headers.get("Location"): return self._abs(loc.strip())
|
||||
return self._abs(r.json().get("url", "").replace(r"\/", "/")) or (r.text.strip() if r.text.strip().startswith("http") else "")
|
||||
except: return ""
|
||||
|
||||
def getpq(self, url):
|
||||
import time
|
||||
for _ in range(2):
|
||||
try: return pq(self.session.get(self._abs(url), timeout=5).text)
|
||||
except: time.sleep(0.1)
|
||||
return pq("<html></html>")
|
||||
|
||||
def _abs(self, url): return url if url.startswith("http") else (f"{self.host}{'/' if not url.startswith('/') else ''}{url}" if url else "")
|
||||
def e64(self, text): return b64encode(text.encode("utf-8")).decode("utf-8")
|
||||
def d64(self, text): return b64decode(text.encode("utf-8")).decode("utf-8")
|
||||
# -*- coding: utf-8 -*-
|
||||
# 修复:歌手不显示歌手图片
|
||||
# by:垃圾星河
|
||||
# 代码指导:嗷呜呜呜呜
|
||||
# 增加:自动人机验证绕过
|
||||
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from base64 import b64encode, b64decode
|
||||
from urllib.parse import quote, unquote
|
||||
from pyquery import PyQuery as pq
|
||||
from requests import Session, adapters
|
||||
from urllib3.util.retry import Retry
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
|
||||
sys.path.append('..')
|
||||
from base.spider import Spider
|
||||
|
||||
|
||||
class Spider(Spider):
|
||||
def init(self, extend=""):
|
||||
self.host = "https://www.22a5.com"
|
||||
self.session = Session()
|
||||
adapter = adapters.HTTPAdapter(
|
||||
max_retries=Retry(total=3, backoff_factor=0.5, status_forcelist=[429, 500, 502, 503, 504]),
|
||||
pool_connections=20,
|
||||
pool_maxsize=50
|
||||
)
|
||||
self.session.mount("http://", adapter)
|
||||
self.session.mount("https://", adapter)
|
||||
self.headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36"
|
||||
}
|
||||
self.session.headers.update(self.headers)
|
||||
|
||||
def getName(self):
|
||||
return "爱听音乐"
|
||||
|
||||
def isVideoFormat(self, url):
|
||||
return bool(re.search(r'\.(m3u8|mp4|mp3|m4a|flv)(\?|$)', url or "", re.I))
|
||||
|
||||
def manualVideoCheck(self):
|
||||
return False
|
||||
|
||||
def destroy(self):
|
||||
self.session.close()
|
||||
|
||||
# ==================== 新增人机验证绕过 ====================
|
||||
|
||||
def _bypass_verification(self, url, response_text):
|
||||
"""若当前页面是人机验证,自动提交勾选"""
|
||||
if '安全人机验证' not in response_text and 'human_check' not in response_text:
|
||||
return None
|
||||
|
||||
# 提取 csrf_token(支持多种格式)
|
||||
token_match = re.search(r'name="csrf_token"\s+value="([^"]+)"', response_text)
|
||||
if not token_match:
|
||||
print("[爱听音乐] 未找到 csrf_token,跳过绕过")
|
||||
return None
|
||||
token = token_match.group(1)
|
||||
|
||||
# 构造提交数据
|
||||
data = {
|
||||
'csrf_token': token,
|
||||
'human_check': 'on'
|
||||
}
|
||||
|
||||
try:
|
||||
# 发送 POST 请求,自动跟随重定向
|
||||
post_resp = self.session.post(url, data=data, allow_redirects=True, timeout=10)
|
||||
print("[爱听音乐] 人机验证已绕过")
|
||||
return post_resp
|
||||
except Exception as e:
|
||||
print(f"[爱听音乐] 人机验证提交失败: {e}")
|
||||
return None
|
||||
|
||||
def getpq(self, url):
|
||||
"""获取页面并自动处理人机验证(重试3次)"""
|
||||
full_url = self._abs(url)
|
||||
|
||||
for attempt in range(3):
|
||||
try:
|
||||
resp = self.session.get(full_url, timeout=5)
|
||||
|
||||
# 若遇到验证页,尝试绕过
|
||||
if '安全人机验证' in resp.text or 'human_check' in resp.text:
|
||||
print("[爱听音乐] 检测到人机验证,尝试自动绕过...")
|
||||
bypass_resp = self._bypass_verification(full_url, resp.text)
|
||||
if bypass_resp:
|
||||
# 验证成功后,返回最终页面(可能是重定向后的目标)
|
||||
return pq(bypass_resp.text)
|
||||
else:
|
||||
# 绕过失败,等待后重试
|
||||
time.sleep(1)
|
||||
continue
|
||||
else:
|
||||
# 正常页面直接返回
|
||||
return pq(resp.text)
|
||||
|
||||
except Exception as e:
|
||||
print(f"[爱听音乐] 请求失败 (尝试 {attempt+1}/3): {e}")
|
||||
time.sleep(0.5 * (attempt + 1))
|
||||
|
||||
# 全部失败,返回空文档
|
||||
return pq("<html></html>")
|
||||
|
||||
# ==================== 原有功能(保持不变) ====================
|
||||
|
||||
def homeContent(self, filter):
|
||||
classes = [
|
||||
{"type_name": n, "type_id": i}
|
||||
for n, i in [
|
||||
("歌手", "/singerlist/index/index/index/index.html"),
|
||||
("TOP榜单", "/list/top.html"),
|
||||
("新歌榜", "/list/new.html"),
|
||||
("电台", "/radiolist/index.html"),
|
||||
("高清MV", "/mvlist/oumei.html"),
|
||||
("专辑", "/albumlist/index.html"),
|
||||
("歌单", "/playtype/index.html")
|
||||
]
|
||||
]
|
||||
filters = {}
|
||||
for p in [c["type_id"] for c in classes if "singer" not in c["type_id"]]:
|
||||
d = self._fetch_filters(p)
|
||||
if d:
|
||||
filters[p] = d
|
||||
|
||||
if "/radiolist/index.html" not in filters:
|
||||
filters["/radiolist/index.html"] = [{
|
||||
"key": "id",
|
||||
"name": "分类",
|
||||
"value": [
|
||||
{"n": n, "v": v}
|
||||
for n, v in zip(
|
||||
["最新", "最热", "有声小说", "相声", "音乐", "情感", "国漫", "影视", "脱口秀", "历史", "儿童", "教育", "八卦", "推理", "头条"],
|
||||
["index", "hot", "novel", "xiangyi", "music", "emotion", "game", "yingshi", "talkshow", "history",
|
||||
"children", "education", "gossip", "tuili", "headline"]
|
||||
)
|
||||
]
|
||||
}]
|
||||
|
||||
filters["/singerlist/index/index/index/index.html"] = [
|
||||
{
|
||||
"key": "area",
|
||||
"name": "地区",
|
||||
"value": [
|
||||
{"n": "全部", "v": "index"},
|
||||
{"n": "华语", "v": "huayu"},
|
||||
{"n": "欧美", "v": "oumei"},
|
||||
{"n": "韩国", "v": "hanguo"},
|
||||
{"n": "日本", "v": "ribrn"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "sex",
|
||||
"name": "性别",
|
||||
"value": [
|
||||
{"n": "全部", "v": "index"},
|
||||
{"n": "男", "v": "male"},
|
||||
{"n": "女", "v": "girl"},
|
||||
{"n": "组合", "v": "band"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "genre",
|
||||
"name": "流派",
|
||||
"value": [
|
||||
{"n": "全部", "v": "index"},
|
||||
{"n": "流行", "v": "liuxing"},
|
||||
{"n": "电子", "v": "dianzi"},
|
||||
{"n": "摇滚", "v": "yaogun"},
|
||||
{"n": "嘻哈", "v": "xiha"},
|
||||
{"n": "R&B", "v": "rb"},
|
||||
{"n": "民谣", "v": "minyao"},
|
||||
{"n": "爵士", "v": "jueshi"},
|
||||
{"n": "古典", "v": "gudian"}
|
||||
]
|
||||
}
|
||||
]
|
||||
return {"class": classes, "filters": filters, "list": []}
|
||||
|
||||
def homeVideoContent(self):
|
||||
return {"list": []}
|
||||
|
||||
def categoryContent(self, tid, pg, filter, extend):
|
||||
pg = int(pg or 1)
|
||||
url = tid
|
||||
if "/singerlist/" in tid:
|
||||
parts = tid.split('/')
|
||||
if len(parts) >= 6:
|
||||
url = "/".join(parts[:2] + [extend.get(k, parts[i]) for i, k in enumerate(["area", "sex", "genre"], 2)] +
|
||||
[f"{extend.get('char', 'index')}.html"])
|
||||
elif "id" in extend and extend["id"] not in ["index", "top"]:
|
||||
url = tid.replace("index.html", f"{extend['id']}.html").replace("top.html", f"{extend['id']}.html")
|
||||
if url == tid:
|
||||
url = f"{tid.rsplit('/', 1)[0]}/{extend['id']}.html"
|
||||
|
||||
if pg > 1:
|
||||
sep = "/" if any(x in url for x in ["/singerlist/", "/radiolist/", "/mvlist/", "/playtype/", "/list/"]) else "_"
|
||||
url = re.sub(r'(_\d+|/\d+)?\.html$', f'{sep}{pg}.html', url)
|
||||
|
||||
doc = self.getpq(url)
|
||||
items = doc(".play_list li, .video_list li, .pic_list li, .singer_list li, .ali li, .layui-row li, .base_l li")
|
||||
return {
|
||||
"list": self._parse_list(items, tid),
|
||||
"page": pg,
|
||||
"pagecount": 9999,
|
||||
"limit": 90,
|
||||
"total": 999999
|
||||
}
|
||||
|
||||
def searchContent(self, key, quick, pg="1"):
|
||||
doc = self.getpq(f"/so/{quote(key)}/{pg}.html")
|
||||
items = doc(".base_l li, .play_list li")
|
||||
return {
|
||||
"list": self._parse_list(items, "search"),
|
||||
"page": int(pg)
|
||||
}
|
||||
|
||||
def detailContent(self, ids):
|
||||
url = self._abs(ids[0])
|
||||
doc = self.getpq(url)
|
||||
vod = {
|
||||
"vod_id": url,
|
||||
"vod_name": self._clean(doc("h1").text() or doc("title").text()),
|
||||
"vod_pic": self._abs(doc(".djpg img, .pic img, .djpic img").attr("src")),
|
||||
"vod_play_from": "爱听音乐",
|
||||
"vod_content": ""
|
||||
}
|
||||
|
||||
if any(x in url for x in ["/playlist/", "/album/", "/list/", "/singer/", "/special/", "/radio/", "/radiolist/"]):
|
||||
eps = self._get_eps(doc)
|
||||
page_urls = {
|
||||
self._abs(a.attr("href"))
|
||||
for a in doc(".page a, .dede_pages a, .pagelist a").items()
|
||||
if a.attr("href") and "javascript" not in a.attr("href")
|
||||
} - {url}
|
||||
if page_urls:
|
||||
with ThreadPoolExecutor(max_workers=5) as ex:
|
||||
futures = []
|
||||
for u in sorted(page_urls, key=lambda x: int(re.search(r'[_/](\d+)\.html', x).group(1)) if re.search(
|
||||
r'[_/](\d+)\.html', x) else 0):
|
||||
futures.append(ex.submit(lambda uu: self._get_eps(self.getpq(uu)), u))
|
||||
for f in as_completed(futures):
|
||||
eps.extend(f.result() or [])
|
||||
if eps:
|
||||
vod.update({
|
||||
"vod_play_from": "播放列表",
|
||||
"vod_play_url": "#".join(eps)
|
||||
})
|
||||
return {"list": [vod]}
|
||||
|
||||
play_list = []
|
||||
if mid := re.search(r'/(song|mp3|radio|radiolist|radioplay)/([^/]+)\.html', url):
|
||||
lrc_url = f"{self.host}/plug/down.php?ac=music&lk=lrc&id={mid.group(2)}"
|
||||
play_list = [f"播放${self.e64('0@@@@' + url + '|||' + lrc_url)}"]
|
||||
|
||||
elif vid := re.search(r'/(video|mp4)/([^/]+)\.html', url):
|
||||
with ThreadPoolExecutor(max_workers=3) as ex:
|
||||
fs = {
|
||||
ex.submit(self._api, "/plug/down.php", {"ac": "vplay", "id": vid.group(2), "q": q}): n
|
||||
for n, q in [("蓝光", 1080), ("超清", 720), ("高清", 480)]
|
||||
}
|
||||
play_list = [f"{fs[f]}${self.e64('0@@@@'+u)}" for f in as_completed(fs) if (u := f.result())]
|
||||
play_list.sort(key=lambda x: {"蓝": 0, "超": 1, "高": 2}.get(x[0], 3))
|
||||
|
||||
vod["vod_play_url"] = "#".join(play_list) if play_list else f"解析失败${self.e64('1@@@@'+url)}"
|
||||
return {"list": [vod]}
|
||||
|
||||
def playerContent(self, flag, id, vipFlags):
|
||||
raw = self.d64(id).split("@@@@")[-1]
|
||||
url, subt = raw.split("|||") if "|||" in raw else (raw, "")
|
||||
url = url.replace(r"\/", "/")
|
||||
|
||||
if ".html" in url and not self.isVideoFormat(url):
|
||||
if mid := re.search(r'/(song|mp3|radio|radiolist|radioplay)/([^/]+)\.html', url):
|
||||
if r_url := self._api("/js/play.php", method="POST", data={"id": mid.group(2), "type": "music"},
|
||||
headers={"Referer": url.replace("http://", "https://"),
|
||||
"X-Requested-With": "XMLHttpRequest"}):
|
||||
url = r_url if ".php" not in r_url else url
|
||||
elif vid := re.search(r'/(video|mp4)/([^/]+)\.html', url):
|
||||
with ThreadPoolExecutor(max_workers=3) as ex:
|
||||
for f in as_completed(
|
||||
[ex.submit(self._api, "/plug/down.php", {"ac": "vplay", "id": vid.group(2), "q": q}) for q in
|
||||
[1080, 720, 480]]):
|
||||
if v_url := f.result():
|
||||
url = v_url
|
||||
break
|
||||
|
||||
result = {"parse": 0, "url": url, "header": {"User-Agent": self.headers["User-Agent"]}}
|
||||
if "22a5.com" in url:
|
||||
result["header"]["Referer"] = self.host + "/"
|
||||
|
||||
# OK影视3.6.5+支持LRC格式滚动歌词
|
||||
if subt:
|
||||
try:
|
||||
r = self.session.get(subt, headers={"Referer": self.host + "/"}, timeout=5)
|
||||
lrc_content = r.text
|
||||
if lrc_content:
|
||||
lrc_content = self._filter_lrc_ads(lrc_content)
|
||||
result["lrc"] = lrc_content
|
||||
except:
|
||||
pass
|
||||
|
||||
return result
|
||||
|
||||
def _filter_lrc_ads(self, lrc_text):
|
||||
"""过滤LRC歌词中的广告内容"""
|
||||
lines = lrc_text.splitlines()
|
||||
filtered_lines = []
|
||||
|
||||
# 广告关键词模式
|
||||
ad_patterns = [
|
||||
r'欢迎来访.*',
|
||||
r'本站.*',
|
||||
r'.*广告.*',
|
||||
r'QQ群.*',
|
||||
r'.*www\..*',
|
||||
r'.*http.*',
|
||||
r'.*\.com.*',
|
||||
r'.*\.cn.*',
|
||||
r'.*\.net.*',
|
||||
r'.*音乐网.*',
|
||||
r'.*提供.*',
|
||||
r'.*下载.*',
|
||||
]
|
||||
|
||||
for line in lines:
|
||||
if re.match(r'\[\d{2}:\d{2}', line):
|
||||
is_ad = False
|
||||
for pattern in ad_patterns:
|
||||
if re.search(pattern, line, re.IGNORECASE):
|
||||
is_ad = True
|
||||
break
|
||||
if not is_ad:
|
||||
filtered_lines.append(line)
|
||||
else:
|
||||
filtered_lines.append(line)
|
||||
|
||||
return '\n'.join(filtered_lines)
|
||||
|
||||
def localProxy(self, param):
|
||||
url = unquote(param.get("url", ""))
|
||||
type_ = param.get("type")
|
||||
|
||||
if type_ == "img":
|
||||
try:
|
||||
headers = {
|
||||
"Referer": "https://www.baidu.com/",
|
||||
"User-Agent": self.headers["User-Agent"],
|
||||
"Accept": "image/webp,image/apng,image/*,*/*;q=0.8",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9"
|
||||
}
|
||||
resp = self.session.get(url, headers=headers, timeout=10)
|
||||
return [200, "image/jpeg", resp.content, {}]
|
||||
except Exception as e:
|
||||
print(f"图片代理失败: {e}")
|
||||
return [404, "text/plain", b"", {}]
|
||||
|
||||
elif type_ == "lrc":
|
||||
try:
|
||||
r = self.session.get(url, headers={"Referer": self.host + "/"}, timeout=5)
|
||||
lrc_content = r.text
|
||||
lrc_content = self._filter_lrc_ads(lrc_content)
|
||||
return [200, "application/octet-stream", lrc_content.encode('utf-8'), {}]
|
||||
except:
|
||||
return [404, "text/plain", "Error", {}]
|
||||
|
||||
return None
|
||||
|
||||
# ==================== 辅助方法 ====================
|
||||
|
||||
def _parse_list(self, items, tid=""):
|
||||
"""解析列表项,修复歌手头像 - 直接返回原始图片URL"""
|
||||
res = []
|
||||
for li in items.items():
|
||||
a = li("a").eq(0)
|
||||
if not (href := a.attr("href")) or href == "/" or any(x in href for x in ["/user/", "/login/", "javascript"]):
|
||||
continue
|
||||
if not (name := self._clean(li(".name").text() or a.attr("title") or a.text())):
|
||||
continue
|
||||
|
||||
is_singer = "/singer/" in href or "/singerlist" in tid
|
||||
|
||||
pic = ""
|
||||
src = ""
|
||||
|
||||
if is_singer:
|
||||
img = li(".pic img").eq(0)
|
||||
src = img.attr("src") or ""
|
||||
if not src:
|
||||
img = li("img").eq(0)
|
||||
src = img.attr("src") or ""
|
||||
else:
|
||||
img = li("img").eq(0)
|
||||
src = img.attr("src") or ""
|
||||
if not src:
|
||||
img = li(".pic img").eq(0)
|
||||
src = img.attr("src") or ""
|
||||
|
||||
if src:
|
||||
if src.startswith('//'):
|
||||
src = 'https:' + src
|
||||
elif src.startswith('/'):
|
||||
src = self.host + src
|
||||
pic = src
|
||||
|
||||
res.append({
|
||||
"vod_id": self._abs(href),
|
||||
"vod_name": name,
|
||||
"vod_pic": pic,
|
||||
"style": {
|
||||
"type": "oval" if is_singer else ("list" if any(
|
||||
x in tid for x in ["/list/", "/playtype/", "/albumlist/"]) else "rect"),
|
||||
"ratio": 1 if is_singer else 1.33
|
||||
}
|
||||
})
|
||||
return res
|
||||
|
||||
def _get_eps(self, doc):
|
||||
eps = []
|
||||
for li in doc(".play_list li, .song_list li, .music_list li").items():
|
||||
a = li("a").eq(0)
|
||||
href = a.attr("href")
|
||||
if not href or not re.search(r'/(song|mp3|radio|radiolist|radioplay)/([^/]+)\.html', href):
|
||||
continue
|
||||
full_url = self._abs(href)
|
||||
|
||||
lrc_part = ""
|
||||
mid = re.search(r'/(song|mp3|radio|radiolist|radioplay)/([^/]+)\.html', full_url)
|
||||
if mid:
|
||||
lrc_url = f"{self.host}/plug/down.php?ac=music&lk=lrc&id={mid.group(2)}"
|
||||
lrc_part = f"|||{lrc_url}"
|
||||
|
||||
eps.append(f"{self._clean(a.text() or li('.name').text())}${self.e64('0@@@@' + full_url + lrc_part)}")
|
||||
return eps
|
||||
|
||||
def _clean(self, text):
|
||||
return re.sub(
|
||||
r'(爱玩音乐网|视频下载说明|视频下载地址|www\.2t58\.com|MP3免费下载|LRC歌词下载|全部歌曲|\[第\d+页\]|刷新|每日推荐|最新|热门|推荐|MV|高清|无损)',
|
||||
'',
|
||||
text or '',
|
||||
flags=re.I
|
||||
).strip()
|
||||
|
||||
def _fetch_filters(self, url):
|
||||
doc = self.getpq(url)
|
||||
filters = []
|
||||
for i, group in enumerate([
|
||||
doc(".ilingku_fl"),
|
||||
doc(".class_list"),
|
||||
doc(".screen_list"),
|
||||
doc(".box_list"),
|
||||
doc(".nav_list")
|
||||
]):
|
||||
if group:
|
||||
opts = [{"n": "全部", "v": "top" if "top" in url else "index"}]
|
||||
seen = set()
|
||||
for a in group("a").items():
|
||||
v = (a.attr("href") or "").split("?")[0].rstrip('/').split('/')[-1].replace('.html', '')
|
||||
if v and v not in seen:
|
||||
opts.append({"n": a.text().strip(), "v": v})
|
||||
seen.add(v)
|
||||
if len(opts) > 1:
|
||||
filters.append({"key": f"id{i}" if i else "id", "name": "分类", "value": opts})
|
||||
return filters
|
||||
|
||||
def _api(self, path, params=None, method="GET", headers=None, data=None):
|
||||
try:
|
||||
h = self.headers.copy()
|
||||
if headers:
|
||||
h.update(headers)
|
||||
r = (self.session.post if method == "POST" else self.session.get)(
|
||||
f"{self.host}{path}",
|
||||
params=params,
|
||||
data=data,
|
||||
headers=h,
|
||||
timeout=10,
|
||||
allow_redirects=False
|
||||
)
|
||||
if loc := r.headers.get("Location"):
|
||||
return self._abs(loc.strip())
|
||||
return self._abs(r.json().get("url", "").replace(r"\/", "/")) or (r.text.strip() if r.text.strip().startswith(
|
||||
"http") else "")
|
||||
except:
|
||||
return ""
|
||||
|
||||
def _abs(self, url):
|
||||
if not url:
|
||||
return ""
|
||||
if url.startswith("http"):
|
||||
return url
|
||||
if url.startswith("//"):
|
||||
return "https:" + url
|
||||
return f"{self.host}{'/' if not url.startswith('/') else ''}{url}"
|
||||
|
||||
def e64(self, text):
|
||||
return b64encode(text.encode("utf-8")).decode("utf-8")
|
||||
|
||||
def d64(self, text):
|
||||
return b64decode(text.encode("utf-8")).decode("utf-8")
|
||||
Binary file not shown.
Reference in New Issue
Block a user