From d6fb43eb3f6688adf5160ffe7bfb2394d4e41b3e Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Tue, 6 Sep 2022 17:48:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "py/360\344\272\214\347\272\247.min.js" | 1 + "py/\345\271\262\351\245\255.min.js" | 1 + "py/\350\223\235\350\216\223.min.js" | 1 + templates/{rules.html => rules_to_clear.html} | 6 +- templates/{raw.html => rules_to_view.html} | 6 +- utils/files.py | 54 +++++++++++++++++ utils/system.py | 58 +++++++++++++++++++ 7 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 "py/360\344\272\214\347\272\247.min.js" create mode 100644 "py/\345\271\262\351\245\255.min.js" create mode 100644 "py/\350\223\235\350\216\223.min.js" rename templates/{rules.html => rules_to_clear.html} (93%) rename templates/{raw.html => rules_to_view.html} (93%) create mode 100644 utils/files.py create mode 100644 utils/system.py diff --git "a/py/360\344\272\214\347\272\247.min.js" "b/py/360\344\272\214\347\272\247.min.js" new file mode 100644 index 0000000..3d954be --- /dev/null +++ "b/py/360\344\272\214\347\272\247.min.js" @@ -0,0 +1 @@ +js:let html=JSON.parse(fetch(input,fetch_params));let data=html.data;let tilte=data.title;let img=data.cdncover;let vod_type=data.moviecategory.join(",");let area=data.area.join(",");let director=data.director.join(",");let actor=data.actor.join(",");let content=data.description;base_vod={vod_id:input,vod_name:tilte,type_name:vod_type,vod_actor:actor,vod_director:director,vod_content:content,vod_remarks:area,vod_pic:urljoin2(input,img)};let delta=200;let vod_play={};let sites=data.playlink_sites;for(let i in sites){let site=sites[i];let playList="";let vodItems=[];if(data.allupinfo){let total=parseInt(data.allupinfo[site]);for(let j=1;j0){playList=vodItems.join("#")}if(playList.length<1){continue}vod_play[site]=playList}let tabs=Object.keys(vod_play);let playUrls=[];for(let id in tabs){playUrls.push(vod_play[tabs[id]])}if(tabs.length>0){vod_play_from=tabs.join("$$$");vod_play_url=playUrls.join("$$$");base_vod.vod_play_from=vod_play_from;base_vod.vod_play_url=vod_play_url}vod=base_vod; \ No newline at end of file diff --git "a/py/\345\271\262\351\245\255.min.js" "b/py/\345\271\262\351\245\255.min.js" new file mode 100644 index 0000000..6ccb4e0 --- /dev/null +++ "b/py/\345\271\262\351\245\255.min.js" @@ -0,0 +1 @@ +js:cacheUrl=getParse(input);if(cacheUrl){input=cacheUrl}else{try{let html=fetch(input,fetch_params);let ret=html.match(/var player_(.*?)=(.*?)10){real_url="https://player.buyaotou.xyz/?url="+url;saveParse(input,real_url);input=real_url}}catch(e){print("网络请求发生错误:"+e.message)}} \ No newline at end of file diff --git "a/py/\350\223\235\350\216\223.min.js" "b/py/\350\223\235\350\216\223.min.js" new file mode 100644 index 0000000..0eaa11d --- /dev/null +++ "b/py/\350\223\235\350\216\223.min.js" @@ -0,0 +1 @@ +js:var MY_HOME="http://lanmeiguojiang.com:5244/d/%E8%93%9D%E8%8E%93%E4%BA%91%E7%9B%98";print(fetch_params);let html=fetch(input,fetch_params);var player=JSON.parse(html.match(/r player_.*?=(.*?) -

缓存规则列表

+

缓存规则列表-{{rules.count}}

{% if rules.count < 1 %}

暂无已缓存的规则

{% endif %} @@ -79,7 +79,7 @@ {% endfor %} -

缓存分类列表

+

缓存分类列表-{{classes|length}}

{% if classes|length < 1 %}

暂无已缓存的分类

{% endif %} diff --git a/templates/raw.html b/templates/rules_to_view.html similarity index 93% rename from templates/raw.html rename to templates/rules_to_view.html index acea3f4..ba8fe2d 100644 --- a/templates/raw.html +++ b/templates/rules_to_view.html @@ -35,12 +35,12 @@ $(".cls").click(function(){ // location.reload(); let cls = this.innerText.trim(); - location.href = '/cls/'+cls; + location.href = '/cls/get/'+cls; }); }); -

缓存规则列表

+

缓存规则列表-{{rules.count}}

{% if rules.count < 1 %}

暂无已缓存的规则

{% endif %} @@ -64,7 +64,7 @@ {% endfor %} -

缓存分类列表

+

缓存分类列表-{{ classes|length }}

{% if classes|length < 1 %}

暂无已缓存的分类

{% endif %} diff --git a/utils/files.py b/utils/files.py new file mode 100644 index 0000000..a027bf5 --- /dev/null +++ b/utils/files.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# File : files.py +# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ +# Date : 2022/9/6 + +import os +from utils.system import getHost +from utils.encode import base64Encode +from controllers.service import storage_service + +def getPics(path='images'): + base_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) # 上级目录 + img_path = os.path.join(base_path, f'{path}') + os.makedirs(img_path,exist_ok=True) + file_name = os.listdir(img_path) + # file_name = list(filter(lambda x: str(x).endswith('.js') and str(x).find('模板') < 0, file_name)) + # print(file_name) + pic_list = [base_path+file for file in file_name] + # pic_list = file_name + # print(type(pic_list)) + return pic_list + +def get_live_url(new_conf,mode): + host = getHost(mode) + lsg = storage_service() + # t1 = time() + live_url = host + '/lives' if new_conf.get('LIVE_MODE',1) == 0 else lsg.getItem('LIVE_URL',getHost(2)+'/lives') + live_url = base64Encode(live_url) + # print(f'{get_interval(t1)}毫秒') + return live_url + +def getAlist(): + base_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) # 上级目录 + alist_path = os.path.join(base_path, 'js/alist.conf') + with open(alist_path,encoding='utf-8') as f: + data = f.read().strip() + alists = [] + for i in data.split('\n'): + i = i.strip() + dt = i.split(',') + if not i.strip().startswith('#'): + obj = { + 'name': dt[0], + 'server': dt[1], + 'type':"alist", + } + if len(dt) > 2: + obj.update({ + 'password': dt[2] + }) + alists.append(obj) + print(f'共计{len(alists)}条alist记录') + return alists \ No newline at end of file diff --git a/utils/system.py b/utils/system.py new file mode 100644 index 0000000..a6db1a9 --- /dev/null +++ b/utils/system.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# File : system.py +# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ +# Date : 2022/9/6 + +from werkzeug.utils import import_string +from base import config +from flask import request +import psutil +import sys +from easydict import EasyDict as edict + +def get_conf(obj): + new_conf = {} + if isinstance(obj, str): + obj = import_string(obj) + for key in dir(obj): + if key.isupper(): + new_conf[key] = getattr(obj, key) + return new_conf + +cfg = edict(get_conf(config)) + +def get_wlan_info(): + info = psutil.net_if_addrs() + # print(info) + netcard_info = [] + ips = [] + for k, v in info.items(): + for item in v: + if item[0] == 2: + netcard_info.append((k, item[1])) + ips.append(item[1]) + return netcard_info,ips + +def get_host_ip(): # 获取局域网ip + netcard_info,ips = get_wlan_info() + # print(netcard_info) + real_ips = list(filter(lambda x: x and x != '127.0.0.1', ips)) + jyw = list(filter(lambda x: str(x).startswith('192.168'), real_ips)) + return real_ips[-1] if len(jyw) < 1 else jyw[0] + +def getHost(mode=0,port=None): + port = port or request.environ.get('SERVER_PORT') + # mode 为0是本地,1是局域网 2是线上 + if mode == 0: + host = f'http://localhost:{port}' + elif mode == 1: + REAL_IP = get_host_ip() + ip = REAL_IP + host = f'http://{ip}:{port}' + else: + host = cfg.get('PLAY_URL','http://cms.nokia.press') + return host + +def is_linux(): + return not 'win' in sys.platform \ No newline at end of file -- GitLab