box/js/采集转换器.py
dongtian d14c82cf42 Update 0831/布卡影院.json, 0831/电视剧网.json, 0831/理理影院.json, 0831/小坝影视.json, 0831/94影院.json, 0831/999影视.json, 0930/评书.json, 0930/blifun影院.json, 0930/xbpq_韩迷TV.json, drpy_libs/模板老.js, drpy_libs/模板.js, drpy_libs/crypto-hiker.js, drpy_libs/crypto-js.js, drpy_libs/cheerio.min.js, drpy_libs/drpy2.js, drpy_libs/drpy2.min.js, drpy_libs/gbk.js, drpy_libs/jinja.js, drpy_libs/jsencrypt.js, drpy_libs/json5.js, drpy_libs/node-rsa.js, drpy_libs/pako.min.js, jar/o.jar, jar/spider.jar, jar/wencai.jar, jar/wogg.jar, jar/xm.jar, jar/xyqxbpq.jar, js/采集分类生成器.py, js/采集之王[合].js, js/采集转换器.py, js/采集[密]静态.json, js/采集[zy]静态.json, js/一曲肝肠断.js, js/一支穿云箭.js, js/有声绘本网[听].js, js/有声听书网[听].js, js/中华听书网[听].js, js/种子音乐[听].js, js/HDmoli.js, js/i275听书[听].js, js/KTV歌厅[听].js, dongtian.json, xmbjm.jar, lib/爱看机器人[虫].js, lib/爱你短剧.json, lib/爱奇艺.js, lib/爱优影视.js, lib/贝乐虎[儿].js, lib/哔哩合集.txt, lib/哔哩戏曲.json, lib/哔哩相声.json, lib/哔哩影视[官].js, lib/哔哩综合.json, lib/播视童趣.json, lib/博看听书.js, lib/采集静态.json, lib/采集之王.js, lib/采集之王[合].js, lib/茶狐杯.json, lib/畅梦.js, lib/初中课堂.json, lib/大全央视.js, lib/电影先生.js, lib/斗鱼直播.js, lib/短剧屋.json, lib/多多追剧[优].js, lib/高中课堂.json, lib/好趣网.js, lib/河马短剧.json, lib/即看影视.js, lib/极光.js, lib/剧圈圈.json, lib/酷奇MV.js, lib/蓝莓短剧.js, lib/六月听书.js, lib/芒果.js, lib/美柏.json, lib/南瓜.js, lib/农民影视.json, lib/女团热舞.json, lib/七新影视.json, lib/奇珍异兽[官].js, lib/企鹅直播.json, lib/搜狗.js, lib/素白白[优].js, lib/腾讯VIP.js, lib/兔小贝.json, lib/兔小贝2.json, lib/小学课堂.json, lib/新视觉.json, lib/星芽短剧.js, lib/学外语.json, lib/学习园地.json, lib/演唱会.json, lib/优酷视频.js, lib/子子.json, lib/4k剧院.js, lib/4kav.json, lib/88看球.js, lib/98影视.json, lib/310直播.js, lib/348.json, lib/360吧[球].js, lib/360影视[官].js, lib/a8yy.js, lib/bl.js, lib/blzb.js, lib/cheerio.min.js, lib/crypto-js.js, lib/DJyyyyw.json, lib/douban.js, lib/drpy2.min.js, lib/fgys.json, lib/guangun.json, lib/guoguo.js, lib/gz.js, lib/HDmoli.json, lib/huyazhibo.js, lib/jp.js, lib/jrk.js, lib/lf_search3_min.js, lib/live.txt, lib/live2.txt, lib/miaiys.json, lib/MTV.json, lib/nfzw.json, lib/qyg0.js, lib/qyg1.js, lib/qyg2.js, lib/qyg3.js, lib/qyg4.js, lib/qyg5.js, lib/rebozj.json, lib/sc1080.json, lib/sdtv.jar, lib/sdtv.js, lib/Vidhub.json, lib/voflix.json, lib/xcys.json, lib/xm.jar, lib/ynfys.json, lib/ysdq.json, lib/zb.txt files
2024-11-03 05:14:53 +00:00

89 lines
2.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : 采集转换器.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2024/7/4
import json
import requests
from urllib.parse import urlsplit
from collections import OrderedDict
def get_host(url):
"""
获取主页地址
@param url:
@return:
"""
ret = urlsplit(url)
return f'{ret.scheme}://{ret.netloc}'
def get_sid(url):
"""
获取id主页
@param url:
@return:
"""
ret = urlsplit(url)
return ret.netloc
def get_api(url):
"""
获取接口api
@param url:
@return:
"""
ret = urlsplit(url)
return ret.path.rstrip('/') + '/'
def delete_same(data, key='url'):
"""
字典列表去重按字典的某个key
@param data:
@param key:
@return:
"""
unique_data = list(OrderedDict((d[key], d) for d in data).values())
if key == 'sid':
for site in unique_data:
del site['sid']
return unique_data
def main(zy_url="https://cdn.jsdelivr.net/gh/waifu-project/v1@latest/zy.json"):
r = requests.get(zy_url)
ret = r.json()
sites = ret['sites']['data']
sites = [site for site in sites if site.get('type') and site['type'] == 1]
print(f'共计发现type1的站点:{len(sites)}条记录')
covert_sites = []
for site in sites:
if site.get("name") and site.get("api"):
surl = site['api']
host = get_host(surl)
api = get_api(surl)
sid = get_sid(surl)
cvalue = {
"sid": sid,
"name": site["name"],
"url": host,
"parse_url": "",
"cate_exclude": ""
}
if api != '/api.php/provide/vod/':
cvalue["api"] = api
covert_sites.append(cvalue)
print(f'转换完成采集之王的站点:{len(covert_sites)}条记录')
covert_sites = delete_same(covert_sites, 'sid')
print(f'去重后的采集之王的站点:{len(covert_sites)}条记录')
with open('采集[zy].json', mode='w+', encoding='utf-8') as f:
f.write(json.dumps(covert_sites, ensure_ascii=False, indent=4))
if __name__ == '__main__':
main()