更新央视筛选

This commit is contained in:
晚风拂柳颜 2024-01-14 13:39:00 +08:00
parent 80d8ec0566
commit 5b4fb26453
3 changed files with 59 additions and 33 deletions

View File

@ -1 +1 @@
3.9.49beta24 3.9.49beta25

View File

@ -12,6 +12,7 @@ except ImportError:
import json import json
import time import time
import base64 import base64
import datetime
import re import re
from urllib import request, parse from urllib import request, parse
from pathlib import Path from pathlib import Path
@ -229,6 +230,24 @@ class Spider(BaseSpider): # 元类 默认的元类 type
ext_file = os.path.join(os.path.dirname(__file__), './' + ext + '.json') ext_file = os.path.join(os.path.dirname(__file__), './' + ext + '.json')
init_file(ext_file) init_file(ext_file)
# ==================== 栏目大全加载年月筛选 ======================
lanmu_list = self.config['filter']['栏目大全']
lanmu_keys_list = [lanmu['key'] for lanmu in lanmu_list]
if 'year' not in lanmu_keys_list:
currentYear = datetime.date.today().year
yearList = [{"n": "全部", "v": ""}]
for year in range(currentYear, currentYear - 10, -1):
yearList.append({"n": year, "v": year})
yearDict = {"key": "year", "name": "年份", "value": yearList}
lanmu_list.append(yearDict)
if 'month' not in lanmu_keys_list:
monthList = [{"n": "全部", "v": ""}]
for month in range(1, 13):
text = str(month).rjust(2, '0')
monthList.append({"n": text, "v": text})
monthDict = {"key": "month", "name": "月份", "value": monthList}
lanmu_list.append(monthDict)
# 装载模块,这里只要一个就够了 # 装载模块,这里只要一个就够了
if isinstance(extend, list): if isinstance(extend, list):
for lib in extend: for lib in extend:
@ -279,6 +298,7 @@ class Spider(BaseSpider): # 元类 默认的元类 type
channel = '' # 频道 channel = '' # 频道
datafl = '' # 类型 datafl = '' # 类型
letter = '' # 字母 letter = '' # 字母
year_prefix = '' # 栏目大全的年月筛选过滤
pagecount = 24 pagecount = 24
if tid == '动画片': if tid == '动画片':
id = urllib.parse.quote(tid) id = urllib.parse.quote(tid)
@ -332,6 +352,10 @@ class Spider(BaseSpider): # 元类 默认的元类 type
fl = '' # 字母 fl = '' # 字母
if 'fl' in extend.keys(): if 'fl' in extend.keys():
fl = extend['fl'] fl = extend['fl']
year = extend.get('year') or ''
month = extend.get('month') or ''
if year:
year_prefix = year + month
url = 'https://api.cntv.cn/lanmu/columnSearch?&fl={0}&fc={1}&cid={2}&p={3}&n=20&serviceId=tvcctv&t=json&cb=ko'.format( url = 'https://api.cntv.cn/lanmu/columnSearch?&fl={0}&fc={1}&cid={2}&p={3}&n=20&serviceId=tvcctv&t=json&cb=ko'.format(
fl, fc, cid, pg) fl, fc, cid, pg)
pagecount = 20 pagecount = 20
@ -349,7 +373,7 @@ class Spider(BaseSpider): # 元类 默认的元类 type
index = htmlText.rfind(');') index = htmlText.rfind(');')
if index > -1: if index > -1:
htmlText = htmlText[3:index] htmlText = htmlText[3:index]
videos = self.get_list1(html=htmlText, tid=tid) videos = self.get_list1(html=htmlText, tid=tid, year_prefix=year_prefix)
elif tid == '4K专区': elif tid == '4K专区':
index = htmlText.rfind(');') index = htmlText.rfind(');')
if index > -1: if index > -1:
@ -369,7 +393,12 @@ class Spider(BaseSpider): # 元类 默认的元类 type
def detailContent(self, array): def detailContent(self, array):
result = {} result = {}
aid = array[0].split('||') year_prefix = ''
did = array[0]
if '$$$' in did:
year_prefix = did.split('$$$')[0]
did = did.split('$$$')[1]
aid = did.split('||')
tid = aid[0] tid = aid[0]
logo = aid[3] logo = aid[3]
lastVideo = aid[2] lastVideo = aid[2]
@ -385,10 +414,23 @@ class Spider(BaseSpider): # 元类 默认的元类 type
# htmlTxt = self.webReadFile(urlStr=lastUrl, header=self.header) # htmlTxt = self.webReadFile(urlStr=lastUrl, header=self.header)
htmlTxt = self.fetch(lastUrl).text htmlTxt = self.fetch(lastUrl).text
topicId = json.loads(htmlTxt)['ctid'] topicId = json.loads(htmlTxt)['ctid']
Url = "https://api.cntv.cn/NewVideo/getVideoListByColumn?id={0}&d=&p=1&n=100&sort=desc&mode=0&serviceId=tvcctv&t=json".format( url = 'https://api.cntv.cn/NewVideo/getVideoListByColumn'
topicId) # params = {
# htmlTxt = self.webReadFile(urlStr=Url, header=self.header) # 'p': '1',
htmlTxt = self.fetch(Url).text # 'n': '100',
# 't': 'json',
# 'mode': '0',
# 'sort': 'desc',
# 'serviceId': 'tvcctv',
# 'd': year_prefix,
# 'id': topicId
# }
# htmlTxt = self.fetch(url,data=params).text
Url = "{0}?id={1}&d=&p=1&n=100&sort=desc&mode=0&serviceId=tvcctv&t=json&d={2}".format(
url, topicId, year_prefix)
elif tid == "4K专区": elif tid == "4K专区":
Url = 'https://api.cntv.cn/NewVideo/getVideoListByAlbumIdNew?id={0}&serviceId=cctv4k&p=1&n=100&mode=0&pub=1'.format( Url = 'https://api.cntv.cn/NewVideo/getVideoListByAlbumIdNew?id={0}&serviceId=cctv4k&p=1&n=100&mode=0&pub=1'.format(
id) id)
@ -571,17 +613,6 @@ class Spider(BaseSpider): # 元类 默认的元类 type
{"n": "Z", "v": "Z"}, {"n": "0-9", "v": "0-9"}]} {"n": "Z", "v": "Z"}, {"n": "0-9", "v": "0-9"}]}
], ],
"纪录片": [ "纪录片": [
{"key": "datapd-channel", "name": "频道",
"value": [{"n": "全部", "v": ""}, {"n": "CCTV{1 综合", "v": "CCTV{1 综合"},
{"n": "CCTV{2 财经", "v": "CCTV{2 财经"}, {"n": "CCTV{3 综艺", "v": "CCTV{3 综艺"},
{"n": "CCTV{4 中文国际", "v": "CCTV{4 中文国际"}, {"n": "CCTV{5 体育", "v": "CCTV{5 体育"},
{"n": "CCTV{6 电影", "v": "CCTV{6 电影"}, {"n": "CCTV{7 国防军事", "v": "CCTV{7 国防军事"},
{"n": "CCTV{8 电视剧", "v": "CCTV{8 电视剧"}, {"n": "CCTV{9 纪录", "v": "CCTV{9 纪录"},
{"n": "CCTV{10 科教", "v": "CCTV{10 科教"}, {"n": "CCTV{11 戏曲", "v": "CCTV{11 戏曲"},
{"n": "CCTV{12 社会与法", "v": "CCTV{12 社会与法"},
{"n": "CCTV{13 新闻", "v": "CCTV{13 新闻"}, {"n": "CCTV{14 少儿", "v": "CCTV{14 少儿"},
{"n": "CCTV{15 音乐", "v": "CCTV{15 音乐"},
{"n": "CCTV{17 农业农村", "v": "CCTV{17 农业农村"}]},
{"key": "datafl-sc", "name": "类型", {"key": "datafl-sc", "name": "类型",
"value": [{"n": "全部", "v": ""}, {"n": "人文历史", "v": "人文历史"}, {"n": "人物", "v": "人物"}, "value": [{"n": "全部", "v": ""}, {"n": "人文历史", "v": "人文历史"}, {"n": "人物", "v": "人物"},
{"n": "军事", "v": "军事"}, {"n": "探索", "v": "探索"}, {"n": "社会", "v": "社会"}, {"n": "军事", "v": "军事"}, {"n": "探索", "v": "探索"}, {"n": "社会", "v": "社会"},
@ -604,17 +635,6 @@ class Spider(BaseSpider): # 元类 默认的元类 type
{"n": "Z", "v": "Z"}, {"n": "0-9", "v": "0-9"}]} {"n": "Z", "v": "Z"}, {"n": "0-9", "v": "0-9"}]}
], ],
"特别节目": [ "特别节目": [
{"key": "datapd-channel", "name": "频道",
"value": [{"n": "全部", "v": ""}, {"n": "CCTV{1 综合", "v": "CCTV{1 综合"},
{"n": "CCTV{2 财经", "v": "CCTV{2 财经"}, {"n": "CCTV{3 综艺", "v": "CCTV{3 综艺"},
{"n": "CCTV{4 中文国际", "v": "CCTV{4 中文国际"}, {"n": "CCTV{5 体育", "v": "CCTV{5 体育"},
{"n": "CCTV{6 电影", "v": "CCTV{6 电影"}, {"n": "CCTV{7 国防军事", "v": "CCTV{7 国防军事"},
{"n": "CCTV{8 电视剧", "v": "CCTV{8 电视剧"}, {"n": "CCTV{9 纪录", "v": "CCTV{9 纪录"},
{"n": "CCTV{10 科教", "v": "CCTV{10 科教"}, {"n": "CCTV{11 戏曲", "v": "CCTV{11 戏曲"},
{"n": "CCTV{12 社会与法", "v": "CCTV{12 社会与法"},
{"n": "CCTV{13 新闻", "v": "CCTV{13 新闻"}, {"n": "CCTV{14 少儿", "v": "CCTV{14 少儿"},
{"n": "CCTV{15 音乐", "v": "CCTV{15 音乐"},
{"n": "CCTV{17 农业农村", "v": "CCTV{17 农业农村"}]},
{"key": "datafl-sc", "name": "类型", {"key": "datafl-sc", "name": "类型",
"value": [{"n": "全部", "v": ""}, {"n": "全部", "v": "全部"}, {"n": "新闻", "v": "新闻"}, "value": [{"n": "全部", "v": ""}, {"n": "全部", "v": "全部"}, {"n": "新闻", "v": "新闻"},
{"n": "经济", "v": "经济"}, {"n": "综艺", "v": "综艺"}, {"n": "体育", "v": "体育"}, {"n": "经济", "v": "经济"}, {"n": "综艺", "v": "综艺"}, {"n": "体育", "v": "体育"},
@ -810,7 +830,7 @@ class Spider(BaseSpider): # 元类 默认的元类 type
}) })
return videos return videos
def get_list1(self, html, tid): def get_list1(self, html, tid, year_prefix=None):
jRoot = json.loads(html) jRoot = json.loads(html)
videos = [] videos = []
data = jRoot['response'] data = jRoot['response']
@ -832,7 +852,7 @@ class Spider(BaseSpider): # 元类 默认的元类 type
guid = "||".join(guids) guid = "||".join(guids)
# print(vod_id) # print(vod_id)
videos.append({ videos.append({
"vod_id": guid, "vod_id": year_prefix + '$$$' + guid if year_prefix else guid,
"vod_name": title, "vod_name": title,
"vod_pic": img, "vod_pic": img,
"vod_remarks": desc.split('')[1].strip() if '' in desc else desc.strip() "vod_remarks": desc.split('')[1].strip() if '' in desc else desc.strip()
@ -915,7 +935,8 @@ if __name__ == '__main__':
spider = Spider() spider = Spider()
t4_spider_init(spider) t4_spider_init(spider)
print(spider.homeVideoContent()) # print(spider.homeContent(True))
# print(spider.homeVideoContent())
# spider.init_api_ext_file() # spider.init_api_ext_file()
# url = 'https://api.cntv.cn/lanmu/columnSearch?&fl=&fc=%E6%96%B0%E9%97%BB&cid=&p=1&n=20&serviceId=tvcctv&t=jsonp&cb=Callback' # url = 'https://api.cntv.cn/lanmu/columnSearch?&fl=&fc=%E6%96%B0%E9%97%BB&cid=&p=1&n=20&serviceId=tvcctv&t=jsonp&cb=Callback'
# url = 'https://api.cntv.cn/lanmu/columnSearch?&fl=&fc=&cid=&p=1&n=20&serviceId=tvcctv&t=json&cb=ko' # url = 'https://api.cntv.cn/lanmu/columnSearch?&fl=&fc=&cid=&p=1&n=20&serviceId=tvcctv&t=json&cb=ko'

View File

@ -8,6 +8,8 @@
import os.path import os.path
import sys import sys
import requests
sys.path.append('..') sys.path.append('..')
try: try:
# from base.spider import Spider as BaseSpider # from base.spider import Spider as BaseSpider
@ -449,7 +451,10 @@ if __name__ == '__main__':
# spider.log('====文本内容====') # spider.log('====文本内容====')
# print(spider.homeContent(True)) # print(spider.homeContent(True))
# print(spider.homeVideoContent()) # print(spider.homeVideoContent())
print(spider.categoryContent('0', 1, False, None)) r = requests.head(
'http://192.168.31.49:5707/api/v1/vod/%E5%93%94%E6%BB%B4%E5%BD%B1%E8%A7%86?proxy=1&do=py&url=https://www.bde4.cc/10E79044B82A84F70BE1308FFA5232E4DC3D0CA9EC2BF6B1D4EF56B2CE5B67CF238965CCAE17F859665B7E166720986D.m3u8')
print(r.headers, r.content)
# print(spider.categoryContent('0', 1, False, None))
# print(spider.detailContent([24420])) # print(spider.detailContent([24420]))
# spider.searchContent('斗罗大陆') # spider.searchContent('斗罗大陆')
# print(spider.playerContent('至尊线路', 'vip://https://www.bdys03.com/api/v1/playurl/174296?type=1', None)) # print(spider.playerContent('至尊线路', 'vip://https://www.bdys03.com/api/v1/playurl/174296?type=1', None))