def write_custom_message(): lazh_TW = {'ViewChangelog': '檢視更新紀錄檔', 'bilischeme': '將bili URI協定添加到登錄檔'} laen = getdict('innosetup', 'en') laja = getdict('innosetup', 'ja') lazh_CN = getdict('innosetup', 'zh_CN') with open('../bilibin/custommessage.iss', 'w', encoding='utf8') as f: f.write('\ufeff[CustomMessages]\n') li = [('en', laen), ('ja', laja), ('zh_CN', lazh_CN), ('zh_TW', lazh_TW)] for i, la in li: for k in la.keys(): ke = k if i != "en": ke = f"{i}.{k}" f.write(f"{ke}={la[k]}\n")
def GET(self, n: str): web.header('Content-Type', 'text/json; charset=utf-8') et = web.ctx.env.get('HTTP_IF_NONE_MATCH') l = n.split('.', 1) # noqa: E741 la2 = None hl = web.input().get('hl') if hl is not None and hl in lan: la2 = hl elif 'lan' in ip or 'lan' in se: la2 = getlan(se, ip) acl = getacceptlanguage(web.ctx.env.get('HTTP_ACCEPT_LANGUAGE')) if la2 is None and acl is not None: for q in acl.keys(): acl2 = acl[q] ia = False for la3 in acl2: la4 = islanin(la3) if la4 is not None: la2 = la4 ia = True break if ia: break if la2 is None: la2 = getlan(se, ip) if len(l) == 1: et2 = getlanEtag(l[0], la2) else: et2 = getlanEtag(l[1], la2, l[0]) if et == et2 and et2 is not None: web.HTTPError('304') t = '' else: if et2 is not None: web.header('Etag', et2) r = {} if len(l) == 1: la = getdict(l[0], la2) else: la = getdict(l[1], la2, l[0]) if la == -1: r['code'] = -1 else: r['code'] = 0 r['dict'] = la t = dumps(r, ensure_ascii=False) return t
def gopt(args): re = getopt(args, 'h?s:p:', ['help', 'lan=', 'host=', 'port=', 'sslc=', 'sslp=', 'pas='******'-h' or i[0] == '-?' or i[0] == '--help': h = True if i[0] == '--lan' and 'lan' not in r and (i[1] == 'null' or i[1] in lan): r['lan'] = i[1] if (i[0] == '-s' or i[0] == '--host') and 's' not in r: r['s'] = i[1] if (i[0] == '-p' or i[0] == '--port') and 'p' not in r: r['p'] = int(i[1]) if i[0] == '--sslc' and 'sslc' not in r: r['sslc'] = i[1] if i[0] == '--sslp' and 'sslp' not in r: r['sslp'] = i[1] if i[0] == '--sslcc' and 'sslcc' not in r: r['sslcc'] = i[1] if i[0] == '--pas' and 'pas' not in r: r['pas'] = i[1] global la if h: la = getdict('command', getlan(se, r), 'webui') ph() exit(0) if 'sslc' in r or 'sslp' in r: if 'sslc' in r and 'sslp' in r: pass else: la = getdict('command', getlan(se, r), 'webui') print(la['O8']) exit(0) if 'pas' in r: if len(r['pas']) >= 8 and len(r['pas']) <= 20: r['pas'] = sha256(r['pas']) else: la = getdict('command', getlan(se, r), 'webui') print(la['O11'].replace('<min>', '8').replace('<max>', '20')) exit(0) return r
def GET(self): te = getT("sendMsgToMe.html") se = settings() se.ReadSettings() sitekey = se.captcha2sitekey if te is None or sitekey is None: web.HTTPError('500 Internal Server Error') return 'Error' lan = getlang() i18n = getdict('basic', lan) i18n2 = getdict('sendMsgToMe', lan) i18n3 = {} mapToDict(i18n2, i18n3, ['OK', 'FAILED', 'NEEDCON', 'NEEDN']) mapToDict(i18n, i18n3, ['NETERR', 'RECAP2']) i18n3 = dictToJSON(i18n3) trans = getTranslator(basic=i18n, sendMsgToMe=i18n2) web.header('Content-Language', lan) if web.input().get('hl') is None: web.header('Vary', 'Accept-Language') if se.webpageCacheTime is not None: setCacheControl(se.webpageCacheTime) return te(sitekey, lan, i18n, i18n2, i18n3, embScr, trans)
def GET(self): te = getTemplate("tools/clearBlankLines.html") if te is None: web.HTTPError('500 Internal Server Error') return 'Error' lan = getlang() i18n = getdict('tools/clearBlankLines', lan) trans = getTranslator(clearBlankLines=i18n) web.header('Content-Language', lan) if web.input().get('hl') is None: web.header('Vary', 'Accept-Language') s = settings() s.ReadSettings() if s.webpageCacheTime is not None: setCacheControl(s.webpageCacheTime) return te(lan, i18n, trans, embScr, genLangLink)
def POST(self): se = settings() se.ReadSettings() lan = getlang() web.header('Content-Language', lan) web.header('Content-Type', 'application/json; charset=UTF-8') i18n = getdict('sendMsgToMe', lan) inp = web.input() content = inp.get("content") if content is None or len(content) == 0: inf = {'code': -3, 'msg': i18n['NEEDCON']} return dumps(inf, ensure_ascii=False, separators=sep) name = inp.get("name") if name is None or len(name) == 0: inf = {'code': -4, 'msg': i18n['NEEDN']} return dumps(inf, ensure_ascii=False, separators=sep) checked, info = checkCaptcha2() inf = {} inf['code'] = 0 if checked else -1 if se.debug: inf['debugInfo'] = info if not checked: inf['msg'] = info['msg'] if checked: if se.telegramchatid is None: inf['code'] = -2 inf['debugInfo2'] = {'code': -1, 'msg': 'No Chat Id.'} else: try: ip = web.ctx['ip'] if ip is None: ip = '' except: ip = '' ilan = web.input().get("lan") if ilan is None: ilan = 'Unknown' addt = f' ({ilan})' if ip == '' else f' ({ip}, {ilan})' text = f"{name}{addt}: {content}" sended, info = sendMessage(se.telegramchatid, text) inf['code'] = 0 if sended else -4 if not sended: inf['msg'] = info['msg'] if se.debug: inf['debugInfo2'] = info return dumps(inf, ensure_ascii=False, separators=sep)
def GET(self): te = getTemplate("pixiv/pixivgen.html") if te is None: web.HTTPError('500 Internal Server Error') return 'Error' lan = getlang() i18n = getdict('pixiv/pixivgen', lan) i18n2 = {} mapToDict(i18n, i18n2, ['ND']) trans = getTranslator(manage=i18n) web.header('Content-Language', lan) if web.input().get('hl') is None: web.header('Vary', 'Accept-Language') s = settings() s.ReadSettings() if s.webpageCacheTime is not None: setCacheControl(s.webpageCacheTime) return te(lan, trans, i18n, embScr, genLangLink, dictToJSON(i18n2))
def GET(self): te = getTemplate("tools/mdToHtml.html") if te is None: web.HTTPError('500 Internal Server Error') return 'Error' lan = getlang() i18n = getdict('tools/mdToHtml', lan) trans = getTranslator(mdToHtml=i18n) i18n2 = {} mapToDict(i18n, i18n2, ['SOPTIONS', 'HOPTIONS', 'SEXT', 'HEXT', 'UF', 'UT']) # noqa: E501 i18n2 = dictToJSON(i18n2) web.header('Content-Language', lan) if web.input().get('hl') is None: web.header('Vary', 'Accept-Language') s = settings() s.ReadSettings() if s.webpageCacheTime is not None: setCacheControl(s.webpageCacheTime) return te(lan, i18n, trans, embScr, genLangLink, i18n2)
def gopt(args: List[str]): re = getopt(args, 'h?ucj:', ['help', 'lan=']) rr = re[0] r = {} h = False for i in rr: if i[0] == '-h' or i[0] == '-?' or i[0] == '--help': h = True if i[0] == '--lan' and not 'lan' in r and (i[1] == 'null' or i[1] in lan): r['lan'] = i[1] if i[0] == '-u': r['u'] = True if i[0] == '-c': r['c'] = True if i[0] == '-j' and not 'j' in r: r['j'] = i[1] if h: global la la = getdict('command', getlan(se, r)) ph() exit() return r, re[1]
def GET(self): te = getTemplate("proxy/manage.html") if te is None: web.HTTPError('500 Internal Server Error') return 'Error' lan = getlang() i18n = getdict('proxy/manage', lan) trans = getTranslator(manage=i18n) i18n2 = {} mapToDict(i18n, i18n2, [ 'SEVERR', 'UNAUTH', 'REQ', 'OR', 'PN', 'SUCDEL', 'FADEL', 'COADD', 'SUCADD', 'UNDOW', 'CODEL', 'CODEA', 'SC', 'HC' ]) # noqa: E501 i18n2 = dictToJSON(i18n2) web.header('Content-Language', lan) if web.input().get('hl') is None: web.header('Vary', 'Accept-Language') s = settings() s.ReadSettings() if s.webpageCacheTime is not None: setCacheControl(s.webpageCacheTime) return te(lan, trans, i18n, embScr, genLangLink, i18n2)
def checkCaptcha2(i18n: LanDict = None) -> (bool, dict): """判断验证是否通过""" if i18n is None: lan = getlang() i18n = getdict('basic', lan) rekey = web.input().get("g-recaptcha-response") if rekey is None: return False, {'code': -1, 'msg': i18n['RECAP2']} r = Session() se = settings() se.ReadSettings() sercet = se.captcha2sercetkey if sercet is None: return False, {'code': -2, 'msg': 'No sercet key to verify reCAPTCHA.\n' + i18n['SITEERR']} # noqa: E501 data = {'secret': sercet, 'response': rekey} url = "https://www.recaptcha.net/recaptcha/api/siteverify" re = r.post(url, data=data) re = re.json() if re['success']: return True, {'code': 0, 'result': re} else: return False, {'code': -3, 'msg': i18n['RECAP2VE'], 'info': re}
def GET(self): te = getTemplate("salt.html") if te is None: web.HTTPError('500 Internal Server Error') return 'Error' lan = getlang() i18n = getdict('salt', lan) trans = getTranslator(salt=i18n) i18n2 = {} mapToDict(i18n, i18n2, ["UKNHASH", "NOSKEY", "SHOWX", "HIDEX", "SEK", "PAS"]) i18n2 = dictToJSON(i18n2) s = settings() s.ReadSettings() web.header('Content-Language', lan) vary = 'User-Agent' if web.input().get('hl') is None: vary += ',Accept-Language' web.header('Vary', vary) if s.webpageCacheTime is not None: setCacheControl(s.webpageCacheTime) return te(lan, trans, i18n, embScr, addWikiLinkToText, i18n2, isIE, genLangLink)
chdir(abspath(split(sys.argv[0])[0])) except: traceback.print_exc() input() from platform import system from JSONParser import loadset from lang import getdict, getlan if system() == "Windows": import winreg import ctypes lan = None se = loadset() if se == -1 or se == -2: se = {} lan = getdict('bilischeme', getlan(se, {})) def is_admin(): try: return ctypes.windll.shell32.IsUserAnAdmin() except: return False def DeleteKey(key, sub_key): k = winreg.OpenKey(key, sub_key, access=winreg.KEY_ALL_ACCESS) i = 0 while True: try: v = winreg.EnumKey(k, i)
def crf(fn: str, od: str, l: list): if exists(fn): try: remove(fn) except: return -1 f = open(fn, 'w', encoding='utf8') v = '%s, %s, %s, %s' % (l[1], l[2], l[3], l[4]) if l[4] > 0: z = '%s.%s.%s.%s(%s%s)' % (l[1], l[2], l[3], l[4], l[6], l[5]) else: z = '%s.%s.%s' % (l[1], l[2], l[3]) if l[6] != '': z = '%s(dirty)' % (z) laen = getdict('exeinfo', 'en') lazh_CN = getdict('exeinfo', 'zh_CN') laja = getdict('exeinfo', 'ja') s = f"""VSVersionInfo( ffi=FixedFileInfo( filevers=({v}), prodvers=({v}), mask=0x3f, flags=0x0, OS=0x40004, fileType=0x1, subtype=0x0, date=(0, 0) ), kids=[ StringFileInfo( [ StringTable( u'080403A8', [StringStruct(u'CompanyName', u'lifegpc'), StringStruct(u'FileDescription', u'{lazh_CN[od]}'), StringStruct(u'FileVersion', u'{z}'), StringStruct(u'InternalName', u'{od}'), StringStruct(u'LegalCopyright', u'Copyright 2019-2020 lifegpc'), StringStruct(u'OriginalFilename', u'{od}.py'), StringStruct(u'ProductName', u'bili'), StringStruct(u'ProductVersion', u'{z}')]) ]), VarFileInfo([VarStruct(u'Translation', [0x804, 0x3a8])]), StringFileInfo( [ StringTable( u'040904E4', [StringStruct(u'CompanyName', u'lifegpc'), StringStruct(u'FileDescription', u'{laen[od]}'), StringStruct(u'FileVersion', u'{z}'), StringStruct(u'InternalName', u'{od}'), StringStruct(u'LegalCopyright', u'Copyright 2019-2020 lifegpc'), StringStruct(u'OriginalFilename', u'{od}.py'), StringStruct(u'ProductName', u'bili'), StringStruct(u'ProductVersion', u'{z}')]) ]), VarFileInfo([VarStruct(u'Translation', [0x409, 0x4e4])]), StringFileInfo( [ StringTable( u'041103A4', [StringStruct(u'CompanyName', u'lifegpc'), StringStruct(u'FileDescription', u'{laja[od]}'), StringStruct(u'FileVersion', u'{z}'), StringStruct(u'InternalName', u'{od}'), StringStruct(u'LegalCopyright', u'Copyright 2019-2020 lifegpc'), StringStruct(u'OriginalFilename', u'{od}.py'), StringStruct(u'ProductName', u'bili'), StringStruct(u'ProductVersion', u'{z}')]) ]), VarFileInfo([VarStruct(u'Translation', [0x411, 0x3a4])]) ] ) """ f.write(s) f.close() return 0
print(f""" bili Copyright (C) 2019-2020 lifegpc This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. {lan['O42']} """) def prc(): try: f = open("LICENSE", "r", encoding="utf8") t = f.readline() while t: print(t) t = f.readline() f.close() except: print(lan['O43'] ) #找不到GNU GPL3 LICENSE文件,请看<http://www.gnu.org/licenses/>。 from command import gopt lan = None se = loadset() if se == -1 or se == -2: se = {} ip = {} if len(sys.argv) > 1: ip = gopt(sys.argv[1:]) lan = getdict('PrintInfo', getlan(se, ip))
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from JSONParser import loadset import sys from lang import getdict, getlan lan = None se = loadset() if se == -1 or se == -2: se = {} ip = {} la = getlan(se, ip) lan = getdict('all', la, 'file') from file.info import getinfo, getinfox, printinfo, spfn, spfln from file.dir import getinfod, printinfod, listd from file.filter import listf, listfd, listff, filtern, filterd from file.get import getfilen from file.info import geturlfe from file.str import cml from file.md import mkdir #对后缀名过滤 LX_FILTER = 0 #对文件名进行正则过滤 TEXT_FILTER = 1 #对后缀名进行过滤时,保留无后缀名名文件 ILX_FILTER = 2
import requests from JSONParser import loadset import sys from lang import getlan, getdict from command import gopt from traceback import format_exc from inspect import currentframe lan = None se = loadset() if se == -1 or se == -2: se = {} ip = {} if len(sys.argv) > 1: ip = gopt(sys.argv[1:]) lan = getdict('biliVersion', getlan(se, ip)) uri = "https://raw.githubusercontent.com/lifegpc/bili/master/version.txt" # 检测更新用URI backup_uri = "https://cdn.jsdelivr.net/gh/lifegpc/bili@master/version.txt" # 备用URI class UnknownVersionString(Exception): def __init__(self, s: str): self.s = s Exception.__init__(self, f"{lan['UNKNOWN_VER_STR']}{s}") class version: def __init__(self, s: str): self.s = s r = search(
from JSONParser import loadset,saveset,getset from re import search from PrintInfo import pr from file import filterd from lang import lan,getlan,getdict import sys from command import gopt from JSONParser import loadset la=None se=loadset() if se==-1 or se==-2 : se={} ip={} if len(sys.argv)>1 : ip=gopt(sys.argv[1:]) la=getdict('setsettings',getlan(se,ip)) l1=['x','',''] l2=['','x',''] l3=['','','x'] def print2(s:str,l:list) : t=search('%s',s) u=len(l) i=0 while t : s=s.replace('%s',str(l[i]),1) t=search('%s',s) i=i+1 if i==u : i=0 print(s) def gk(se:dict,key:str) :
if (sslcc is not None or 'sslc' in ip) and 'sslcc' in ip: sslcc = se['sslcc'] if sslc is not None and sslcc is not None: HTTPServer.ssl_adapter = BuiltinSSLAdapter(certificate=sslc, private_key=sslp, certificate_chain=sslcc) pa.https = True elif sslc is not None: HTTPServer.ssl_adapter = BuiltinSSLAdapter(certificate=sslc, private_key=sslp) pa.https = True if 'pas' in se: pa.pas = True re = pa.setpassword(se['pas']) if re == -1: print(lan['INVALPAS']) return -1 if 'pas' in ip: pa.pas = True re = pa.setpassword(ip['pas']) if re == -1: print(lan['INVALPAS']) return -1 app.add_processor(server_ver) app.run(host, port) if __name__ == "__main__": lan = getdict('startwebui', getlan(se, ip), "webui") main(ip)
from command import gopt import JSONParser from ASSWriter import ASSScript, parsefromCSSHex, ASSScriptEvent import traceback from iso639 import languages from bstr import lg lan=None se=JSONParser.loadset() if se==-1 or se==-2 : se={} ip={} if len(sys.argv)>1 : ip=gopt(sys.argv[1:]) lan=getdict('biliSub',getlan(se,ip)) def getiso6392t(s: str) -> str: t = s.split('_')[0] t = s.split('-')[0] try: return languages.get(alpha2=t).part2t except: return s def downsub(r: Session,fn: str,i: dict,ip: dict,se: dict,data: dict,pr: bool = False,pi: int = 1, width: int = None, height: int = None): "下载字幕" ass = False if JSONParser.getset(se, 'ass') == True:
from urllib.parse import quote_plus, parse_qsl, urlsplit from qrcode import QRCode, constants as qrconst from qrcode.image.svg import SvgImage from platform import system from Logger import Logger from HTMLParser import NicoUserParser from JSParser import getNicoUser lan = None se = JSONParser.loadset() if se == -1 or se == -2: se = {} ip = {} if len(sys.argv) > 1: ip = gopt(sys.argv[1:]) lan = getdict('biliLogin', getlan(se, ip)) def login(r, ud: dict, ip: dict, logg=None): '登录至B站' global lan url = "https://passport.bilibili.com/ajax/miniLogin/minilogin" try: option = webdriver.ChromeOptions() option.add_argument("disable-logging") option.add_argument('log-level=3') driver = webdriver.Chrome(options=option) if logg is not None: logg.write(f"OEPN {url} in ChromeDriver", currentframe(), "OPEN WEB") driver.get(url)
r['sslcc'] = i[1] if i[0] == '--pas' and 'pas' not in r: r['pas'] = i[1] global la if h: la = getdict('command', getlan(se, r), 'webui') ph() exit(0) if 'sslc' in r or 'sslp' in r: if 'sslc' in r and 'sslp' in r: pass else: la = getdict('command', getlan(se, r), 'webui') print(la['O8']) exit(0) if 'pas' in r: if len(r['pas']) >= 8 and len(r['pas']) <= 20: r['pas'] = sha256(r['pas']) else: la = getdict('command', getlan(se, r), 'webui') print(la['O11'].replace('<min>', '8').replace('<max>', '20')) exit(0) return r la = None se = loadset() if se == -1 or se == -2: se = {} la = getdict('command', getlan(se, {}), 'webui')
import sys from lang import getdict, getlan from command import gopt from inspect import currentframe from traceback import format_exc from typing import Callable, List StrList = List[str] lan = None se = loadset() if se == -1 or se == -2: se = {} ip = {} if len(sys.argv) > 1: ip = gopt(sys.argv[1:]) lan = getdict('JSONParser2', getlan(se, ip)) def getplinfo(d: dict): t = d['data']['info'] r = {} r['id'] = t['id'] r['fid'] = t['fid'] r['uid'] = t['mid'] r['title'] = t['title'] r['author'] = t['upper']['name'] r['ctime'] = t['ctime'] r['mtime'] = t['mtime'] r['count'] = t['media_count'] return r
def gopt(args, d: bool = False): re = getopt(args, 'h?i:d:p:m:r:ynFv:a:o:scb:V:', [ 'help', 'ac=', 'dm=', 'ad=', 'yf', 'nf', 'mc=', 'ar', 'nar', 'ax=', 'as=', 'ak=', 'ab', 'nab', 'fa=', 'sv=', 'ma=', 'ms=', 'da=', 'httpproxy=', 'httpsproxy=', 'jt=', 'jts=', 'af', 'naf', 'afp=', 'slt', 'nslt', 'te', 'nte', 'bd', 'nbd', 'cad', 'ncad', 'lrh', 'nlrh', 'ym', 'nm', 'yac', 'nac', 'ydm', 'ndm', 'yad', 'nad', 'yr', 'nr', 'ysv', 'nsv', 'yma', 'nma', 'yda', 'nda', 'ahttpproxy=', 'ahttpsproxy=', 'lan=', 'bp', 'nbp', 'in', 'nin', 'mt', 'nmt', 'vi=', 'uc', 'nuc', 'ass', 'nass', 'dmp', 'ndmp', 'vf=', 'lmd=', 'ynal', 'nnal', 'log', 'nlog', 'yauf', 'nauf', 'ydwa', 'ndwa', 'yol', 'nol', 'ltid', 'ncc', 'ycc', 'nfo', 'nnfo', 'anopro', 'mxd=', 'imn', 'nimn', 'nlt=', 'nsp=', 'fnl=', 'lp', 'nlp' ]) if d: print(re) rr = re[0] r = {} h = False for i in rr: if i[0] == '-h' or i[0] == '-?' or i[0] == '--help': h = True if i[0] == '-i' and 'i' not in r: r['i'] = i[1] if i[0] == '-d' and 'd' not in r and i[1].isnumeric() and int( i[1]) > 0 and int(i[1]) < 9: r['d'] = int(i[1]) if i[0] == '-p' and 'p' not in r: r['p'] = i[1] if i[0] == '-m' and 'm' not in r: if i[1].lower() == 'true': r['m'] = True elif i[1].lower() == 'false': r['m'] = False if i[0] == '--ym' and 'm' not in r: r['m'] = True if i[0] == '--nm' and 'm' not in r: r['m'] = False if i[0] == '--ac' and 'ac' not in r: if i[1].lower() == 'true': r['ac'] = True elif i[1].lower() == 'false': r['ac'] = False if i[0] == '--yac' and 'ac' not in r: r['ac'] = True if i[0] == '--nac' and 'ac' not in r: r['ac'] = False if i[0] == '--dm' and 'dm' not in r: if i[1].lower() == 'true': r['dm'] = True elif i[1].lower() == 'false': r['dm'] = False if i[0] == '--ydm' and 'dm' not in r: r['dm'] = True if i[0] == '--ndm' and 'dm' not in r: r['dm'] = False if i[0] == '--ad' and 'ad' not in r: if i[1].lower() == 'true': r['ad'] = True elif i[1].lower() == 'false': r['ad'] = False if i[0] == '--yad' and 'ad' not in r: r['ad'] = True if i[0] == '--nad' and 'ad' not in r: r['ad'] = False if i[0] == '-r' and 'r' not in r: if i[1].lower() == 'true': r['r'] = True elif i[1].lower() == 'false': r['r'] = False if i[0] == '--yr' and 'r' not in r: r['r'] = True if i[0] == '--nr' and 'r' not in r: r['r'] = False if i[0] == '-y' and 'y' not in r: r['y'] = True if i[0] == '-n' and 'y' not in r: r['y'] = False if i[0] == '--yf' and 'yf' not in r: r['yf'] = True if i[0] == '--nf' and 'yf' not in r: r['yf'] = False if i[0] == '--mc' and 'mc' not in r: if i[1].lower() == 'avc': r['mc'] = True elif i[1].lower() == 'hev': r['mc'] = False if i[0] == '--ar' and 'ar' not in r: r['ar'] = True if i[0] == '--nar' and 'ar' not in r: r['ar'] = False if i[0] == '--ax' and 'ax' not in r: if i[1].isnumeric(): i2 = int(i[1]) if i2 < 17 and i2 > 0: r['ax'] = i2 if i[0] == '--as' and 'as' not in r: if i[1].isnumeric(): i2 = int(i[1]) if i2 > 0: r['as'] = i2 if i[0] == '--ak' and 'ak' not in r: if i[1].isnumeric(): i2 = int(i[1]) if i2 > 0 and i2 < 1025: r['ak'] = i2 if i[0] == '--ab' and 'ab' not in r: r['ab'] = True if i[0] == '--nab' and 'ab' not in r: r['ab'] = False if i[0] == '--fa' and 'fa' not in r: if i[1].lower() == 'none' or i[1].lower() == 'prealloc' or i[ 1].lower() == 'trunc' or i[1].lower() == 'falloc': r['fa'] = i[1].lower() if i[0] == '--sv' and 'sv' not in r: if i[1].lower() == 'true': r['sv'] = True elif i[1].lower() == 'false': r['sv'] = False if i[0] == '--ysv' and 'sv' not in r: r['sv'] = True if i[0] == '--nsv' and 'sv' not in r: r['sv'] = False if i[0] == '--ma' and 'ma' not in r: if i[1].lower() == 'true': r['ma'] = True elif i[1].lower() == 'false': r['ma'] = False if i[0] == '--yma' and 'ma' not in r: r['ma'] = True if i[0] == '--nma' and 'ma' not in r: r['ma'] = False if i[0] == '--ms' and 'ms' not in r: t = search("^[0-9]+[MK]?$", i[1]) if t is not None: r['ms'] = i[1] if i[0] == '--da' and 'da' not in r: if i[1].lower() == 'true': r['da'] = True elif i[1].lower() == 'false': r['da'] = False if i[0] == '--yda' and 'da' not in r: r['da'] = True if i[0] == '--nda' and 'da' not in r: r['da'] = False if i[0] == '--httpproxy' and 'httpproxy' not in r: r['httpproxy'] = i[1] if i[0] == '--httpsproxy' and 'httpsproxy' not in r: r['httpsproxy'] = i[1] if i[0] == "--jt" and 'jt' not in r: if i[1].lower() == 'a' or i[1].lower() == 'b' or i[1].isnumeric(): r['jt'] = i[1].lower() if i[0] == '--jts' and 'jts' not in r: if checktime(i[1]): r['jts'] = i[1] if i[0] == '-F' and 'F' not in r: r['F'] = True if i[0] == '-v' and 'v' not in r: if i[1].isnumeric(): if int(i[1]) > 0: r['v'] = i[1] if i[0] == '-a' and 'a' not in r: if i[1].isnumeric(): if int(i[1]) > 0: r['a'] = i[1] if i[0] == '-o' and 'o' not in r: r['o'] = filterd(i[1]) if i[0] == '--af' and 'af' not in r: r['af'] = False if i[0] == '--naf' and 'af' not in r: r['af'] = True if i[0] == '--afp' and 'afp' not in r: r['afp'] = i[1] if i[0] == '-s' and 's' not in r: r['s'] = True if i[0] == '--slt' and 'slt' not in r: r['slt'] = True if i[0] == '--nslt' and 'slt' not in r: r['slt'] = False if i[0] == '--te' and 'te' not in r: r['te'] = True if i[0] == '--nte' and 'te' not in r: r['te'] = False if i[0] == '--bd' and 'bd' not in r: r['bd'] = True if i[0] == '--nbd' and 'bd' not in r: r['bd'] = False if i[0] == '--cad' and 'cad' not in r: r['cad'] = True if i[0] == '--ncad' and 'cad' not in r: r['cad'] = False if i[0] == '--lrh' and 'lrh' not in r: r['lrh'] = True if i[0] == '--nlrh' and 'lrh' not in r: r['lrh'] = False if i[0] == '--ahttpproxy' and 'ahttpproxy' not in r: r['ahttpproxy'] = i[1] if i[0] == '--ahttpsproxy' and 'ahttpsproxy' not in r: r['ahttpsproxy'] = i[1] if i[0] == '--lan' and 'lan' not in r and (i[1] == 'null' or i[1] in lan): r['lan'] = i[1] if i[0] == '--bp' and 'bp' not in r: r['bp'] = True if i[0] == '--nbp' and 'bp' not in r: r['bp'] = False if i[0] == '--in' and 'in' not in r: r['in'] = True if i[0] == '--nin' and 'in' not in r: r['in'] = False if i[0] == '--mt' and 'mt' not in r: r['mt'] = True if i[0] == '--nmt' and 'mt' not in r: r['mt'] = False if i[0] == '--vi' and 'vi' not in r: if i[1].isnumeric(): r['vi'] = int(i[1]) if i[0] == '--uc' and 'uc' not in r: r['uc'] = True if i[0] == '--nuc' and 'uc' not in r: r['uc'] = False if i[0] == '--ass' and 'ass' not in r: r['ass'] = True if i[0] == '--nass' and 'ass' not in r: r['ass'] = False if i[0] == '--dmp' and 'dmp' not in r: r['dmp'] = True if i[0] == '--ndmp' and 'dmp' not in r: r['dmp'] = False if i[0] == '--vf' and 'vf' not in r and i[1] in ['mkv', 'mp4']: r['vf'] = i[1] if i[0] == '--lmd' and 'lmd' not in r and i[1].isnumeric(): if int(i[1]) >= 0: r['lmd'] = int(i[1]) if i[0] == '--ynal' and 'nal' not in r: r['nal'] = True if i[0] == '--nnal' and 'nal' not in r: r['nal'] = False if i[0] == '--log' and 'log' not in r: r['log'] = True if i[0] == '--nlog' and 'log' not in r: r['log'] = False if i[0] == '--yauf' and 'auf' not in r: r['auf'] = True if i[0] == '--nauf' and 'auf' not in r: r['auf'] = False if i[0] == '--ydwa' and 'dwa' not in r: r['dwa'] = True if i[0] == '--ndwa' and 'dwa' not in r: r['dwa'] = False if i[0] == '--yol' and 'ol' not in r: r['ol'] = True if i[0] == '--nol' and 'ol' not in r: r['ol'] = False if i[0] == '--ltid': r['ltid'] = True if i[0] == '--ycc' and 'cc' not in r: r['cc'] = True if i[0] == '--ncc' and 'cc' not in r: r['cc'] = False if i[0] == '--nfo' and 'nfo' not in r: r['nfo'] = True if i[0] == '--nnfo' and 'nfo' not in r: r['nfo'] = False if i[0] == '-V' and 'V' not in r: rs = search(r'^([0-9]+)(avc|hev)?$', i[1]) if rs is not None: vid = int(rs.groups()[0]) if vid in [16, 32, 64, 74, 80, 112, 116, 120, 125]: r['V'] = {'id': vid, 'codec': rs.groups()[1]} elif vid in range(1, 12): r['V'] = {'id': vid, 'codec': rs.groups()[1]} if i[0] == '--anopro' and 'anopro' not in r: r['anopro'] = True if i[0] == '--mxd' and 'mxd' not in r: if i[1].isnumeric(): if int(i[1]) >= 0: r['mxd'] = int(i[1]) if i[0] == '--imn' and 'imn' not in r: r['imn'] = True if i[0] == '--nimn' and 'imn' not in r: r['imn'] = False if i[0] == '--nlt' and search(r'^\+?\d+(\.\d+)?$', i[1]) and 'nlt' not in r: r['nlt'] = float(i[1]) if i[0] == '--nsp' and search(r'^\+?\d+(\.\d+)?$', i[1]) and 'nsp' not in r: t = float(i[1]) t = min(max(round(t * 4), 1), 8) / 4 if t in [1, 2]: t = round(t) r['nsp'] = t if i[0] == '--fnl' and i[1].isnumeric() and 'fnl' not in r: r['fnl'] = int(i[1]) if i[0] == '--lp' and 'lp' not in r: r['lp'] = True if i[0] == '--nlp' and 'lp' not in r: r['lp'] = False if i[0] == '-b': ree = urlsplit(i[1]) if ree.scheme == "bili": pat = f"{ree.netloc}{ree.path}" if ree.path == "/" and i[1].find("://") > -1: pat = ree.netloc argv = ['-i', unquote_plus(pat)] getp = parse_qs(ree.query, True) for key in getp.keys(): if key == 'b': continue val = getp[key] if len(key) == 1: key = f"-{key}" elif len(key) > 1: key = f"--{key}" else: continue if len(val) == 1 and val[0] == "": argv.append(key) else: for v in val: argv.append(key) argv.append(v) if d: print(argv) try: return gopt(argv) except GetoptError: t = i[1][5:] if t.startswith('//'): t = t[2:] argv = ['-i', t] if d: print(argv) return gopt(argv) if h: global la la = getdict('command', getlan(se, r)) ph() sys.exit(0) for i in re[1]: if i.lower() == "show": r['SHOW'] = True return r
r['dwa'] = False if i[0] == '--yol' and not 'ol' in r: r['ol'] = True if i[0] == '--nol' and not 'ol' in r: r['ol'] = False if i[0] == '--ltid': r['ltid'] = True if h: global la la = getdict('command', getlan(se, r)) ph() exit() for i in re[1]: if i.lower() == "show": r['SHOW'] = True return r la = None se = loadset() if se == -1 or se == -2: se = {} la = getdict('command', getlan(se, {})) if __name__ == "__main__": import sys print(sys.argv) if len(sys.argv) == 1: print('该文件仅供测试命令行输入使用,请运行start.py') else: print(gopt(sys.argv[1:], True))
# This file is part of bili. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from JSONParser import loadset import sys from command import gopt from lang import getdict, getlan lan = None se = loadset() if se == -1 or se == -2: se = {} ip = {} if len(sys.argv) > 1: ip = gopt(sys.argv[1:]) lan = getdict('biliext', getlan(se, ip)) XMLFILE = (lan['XML'], "*.xml") ALLFILE = (lan['ALL'], "*")
def gopt(args, d: bool = False): re = getopt(args, 'h?i:d:p:m:r:ynFv:a:o:s', [ 'help', 'ac=', 'dm=', 'ad=', 'yf', 'nf', 'mc=', 'ar', 'nar', 'ax=', 'as=', 'ak=', 'ab', 'nab', 'fa=', 'sv=', 'ma=', 'ms=', 'da=', 'httpproxy=', 'httpsproxy=', 'jt=', 'jts=', 'af', 'naf', 'afp=', 'slt', 'nslt', 'te', 'nte', 'bd', 'nbd', 'cad', 'ncad', 'lrh', 'nlrh', 'ym', 'nm', 'yac', 'nac', 'ydm', 'ndm', 'yad', 'nad', 'yr', 'nr', 'ysv', 'nsv', 'yma', 'nma', 'yda', 'nda', 'ahttpproxy=', 'ahttpsproxy=', 'lan=', 'bp', 'nbp', 'in', 'nin', 'mt', 'nmt', 'vi=', 'uc', 'nuc', 'ass', 'nass', 'dmp', 'ndmp', 'vf=', 'lmd=', 'ynal', 'nnal', 'log', 'nlog', 'yauf', 'nauf', 'ydwa', 'ndwa', 'yol', 'nol', 'ltid' ]) if d: print(re) rr = re[0] r = {} h = False for i in rr: if i[0] == '-h' or i[0] == '-?' or i[0] == '--help': h = True if i[0] == '-i' and not 'i' in r: r['i'] = i[1] if i[0] == '-d' and not 'd' in r and i[1].isnumeric() and int( i[1]) > 0 and int(i[1]) < 9: r['d'] = int(i[1]) if i[0] == '-p' and not 'p' in r: r['p'] = i[1] if i[0] == '-m' and not 'm' in r: if i[1].lower() == 'true': r['m'] = True elif i[1].lower() == 'false': r['m'] = False if i[0] == '--ym' and not 'm' in r: r['m'] = True if i[0] == '--nm' and not 'm' in r: r['m'] = False if i[0] == '--ac' and not 'ac' in r: if i[1].lower() == 'true': r['ac'] = True elif i[1].lower() == 'false': r['ac'] = False if i[0] == '--yac' and not 'ac' in r: r['ac'] = True if i[0] == '--nac' and not 'ac' in r: r['ac'] = False if i[0] == '--dm' and not 'dm' in r: if i[1].lower() == 'true': r['dm'] = True elif i[1].lower() == 'false': r['dm'] = False if i[0] == '--ydm' and not 'dm' in r: r['dm'] = True if i[0] == '--ndm' and not 'dm' in r: r['dm'] = False if i[0] == '--ad' and not 'ad' in r: if i[1].lower() == 'true': r['ad'] = True elif i[1].lower() == 'false': r['ad'] = False if i[0] == '--yad' and not 'ad' in r: r['ad'] = True if i[0] == '--nad' and not 'ad' in r: r['ad'] = False if i[0] == '-r' and not 'r' in r: if i[1].lower() == 'true': r['r'] = True elif i[1].lower() == 'false': r['r'] = False if i[0] == '--yr' and not 'r' in r: r['r'] = True if i[0] == '--nr' and not 'r' in r: r['r'] = False if i[0] == '-y' and not 'y' in r: r['y'] = True if i[0] == '-n' and not 'y' in r: r['y'] = False if i[0] == '--yf' and not 'yf' in r: r['yf'] = True if i[0] == '--nf' and not 'yf' in r: r['yf'] = False if i[0] == '--mc' and not 'mc' in r: if i[1].lower() == 'avc': r['mc'] = True elif i[1].lower() == 'hev': r['mc'] = False if i[0] == '--ar' and not 'ar' in r: r['ar'] = True if i[0] == '--nar' and not 'ar' in r: r['ar'] = False if i[0] == '--ax' and not 'ax' in r: if i[1].isnumeric(): i2 = int(i[1]) if i2 < 17 and i2 > 0: r['ax'] = i2 if i[0] == '--as' and not 'as' in r: if i[1].isnumeric(): i2 = int(i[1]) if i2 > 0: r['as'] = i2 if i[0] == '--ak' and not 'ak' in r: if i[1].isnumeric(): i2 = int(i[1]) if i2 > 0 and i2 < 1025: r['ak'] = i2 if i[0] == '--ab' and not 'ab' in r: r['ab'] = True if i[0] == '--nab' and not 'ab' in r: r['ab'] = False if i[0] == '--fa' and not 'fa' in r: if i[1].lower() == 'none' or i[1].lower() == 'prealloc' or i[ 1].lower() == 'trunc' or i[1].lower() == 'falloc': r['fa'] = i[1].lower() if i[0] == '--sv' and not 'sv' in r: if i[1].lower() == 'true': r['sv'] = True elif i[1].lower() == 'false': r['sv'] = False if i[0] == '--ysv' and not 'sv' in r: r['sv'] = True if i[0] == '--nsv' and not 'sv' in r: r['sv'] = False if i[0] == '--ma' and not 'ma' in r: if i[1].lower() == 'true': r['ma'] = True elif i[1].lower() == 'false': r['ma'] = False if i[0] == '--yma' and not 'ma' in r: r['ma'] = True if i[0] == '--nma' and not 'ma' in r: r['ma'] = False if i[0] == '--ms' and not 'ms' in r: t = search("^[0-9]+[MK]?$", i[1]) if t != None: r['ms'] = i[1] if i[0] == '--da' and not 'da' in r: if i[1].lower() == 'true': r['da'] = True elif i[1].lower() == 'false': r['da'] = False if i[0] == '--yda' and not 'da' in r: r['da'] = True if i[0] == '--nda' and not 'da' in r: r['da'] = False if i[0] == '--httpproxy' and not 'httpproxy' in r: r['httpproxy'] = i[1] if i[0] == '--httpsproxy' and not 'httpsproxy' in r: r['httpsproxy'] = i[1] if i[0] == "--jt" and not 'jt' in r: if i[1].lower() == 'a' or i[1].lower() == 'b' or i[1].isnumeric(): r['jt'] = i[1].lower() if i[0] == '--jts' and not 'jts' in r: if checktime(i[1]): r['jts'] = i[1] if i[0] == '-F' and not 'F' in r: r['F'] = True if i[0] == '-v' and not 'v' in r: if i[1].isnumeric(): if int(i[1]) > 0: r['v'] = i[1] if i[0] == '-a' and not 'a' in r: if i[1].isnumeric(): if int(i[1]) > 0: r['a'] = i[1] if i[0] == '-o' and not 'o' in r: r['o'] = filterd(i[1]) if i[0] == '--af' and not 'af' in r: r['af'] = False if i[0] == '--naf' and not 'af' in r: r['af'] = True if i[0] == '--afp' and not 'afp' in r: r['afp'] = i[1] if i[0] == '-s' and not 's' in r: r['s'] = True if i[0] == '--slt' and not 'slt' in r: r['slt'] = True if i[0] == '--nslt' and not 'slt' in r: r['slt'] = False if i[0] == '--te' and not 'te' in r: r['te'] = True if i[0] == '--nte' and not 'te' in r: r['te'] = False if i[0] == '--bd' and not 'bd' in r: r['bd'] = True if i[0] == '--nbd' and not 'bd' in r: r['bd'] = False if i[0] == '--cad' and not 'cad' in r: r['cad'] = True if i[0] == '--ncad' and not 'cad' in r: r['cad'] = False if i[0] == '--lrh' and not 'lrh' in r: r['lrh'] = True if i[0] == '--nlrh' and not 'lrh' in r: r['lrh'] = False if i[0] == '--ahttpproxy' and not 'ahttpproxy' in r: r['ahttpproxy'] = i[1] if i[0] == '--ahttpsproxy' and not 'ahttpsproxy' in r: r['ahttpsproxy'] = i[1] if i[0] == '--lan' and not 'lan' in r and (i[1] == 'null' or i[1] in lan): r['lan'] = i[1] if i[0] == '--bp' and not 'bp' in r: r['bp'] = True if i[0] == '--nbp' and not 'bp' in r: r['bp'] = False if i[0] == '--in' and not 'in' in r: r['in'] = True if i[0] == '--nin' and not 'in' in r: r['in'] = False if i[0] == '--mt' and not 'mt' in r: r['mt'] = True if i[0] == '--nmt' and not 'mt' in r: r['mt'] = False if i[0] == '--vi' and not 'vi' in r: if i[1].isnumeric(): r['vi'] = int(i[1]) if i[0] == '--uc' and not 'uc' in r: r['uc'] = True if i[0] == '--nuc' and not 'uc' in r: r['uc'] = False if i[0] == '--ass' and not 'ass' in r: r['ass'] = True if i[0] == '--nass' and not 'ass' in r: r['ass'] = False if i[0] == '--dmp' and not 'dmp' in r: r['dmp'] = True if i[0] == '--ndmp' and not 'dmp' in r: r['dmp'] = False if i[0] == '--vf' and not 'vf' in r and i[1] in ['mkv', 'mp4']: r['vf'] = i[1] if i[0] == '--lmd' and not 'lmd' in r and i[1].isnumeric(): if int(i[1]) >= 0: r['lmd'] = int(i[1]) if i[0] == '--ynal' and not 'nal' in r: r['nal'] = True if i[0] == '--nnal' and not 'nal' in r: r['nal'] = False if i[0] == '--log' and not 'log' in r: r['log'] = True if i[0] == '--nlog' and not 'log' in r: r['log'] = False if i[0] == '--yauf' and not 'auf' in r: r['auf'] = True if i[0] == '--nauf' and not 'auf' in r: r['auf'] = False if i[0] == '--ydwa' and not 'dwa' in r: r['dwa'] = True if i[0] == '--ndwa' and not 'dwa' in r: r['dwa'] = False if i[0] == '--yol' and not 'ol' in r: r['ol'] = True if i[0] == '--nol' and not 'ol' in r: r['ol'] = False if i[0] == '--ltid': r['ltid'] = True if h: global la la = getdict('command', getlan(se, r)) ph() exit() for i in re[1]: if i.lower() == "show": r['SHOW'] = True return r
import file import sys from command import gopt from lang import getdict,getlan from inspect import currentframe from traceback import format_exc lan=None se=loadset() if se==-1 or se==-2 : se={} ip={} if len(sys.argv)>1 : ip=gopt(sys.argv[1:]) lan=getdict('biliDanmu',getlan(se,ip)) def lrdownload(data:dict,r:Session,ip:dict,se:dict,xml,xmlc:list) : """下载直播回放弹幕 -1 文件夹创建失败 -2 API解析失败 -3 打开文件失败""" log = False logg = None if 'logg' in ip: log = True logg = ip['logg'] ns=True if 's' in ip : ns=False o="Download/" read=getset(se,'o')
import biliPlayerXmlParser from os.path import exists import biliDanmuXmlParser from os import remove import biliDanmuXmlFilter import biliDanmuCreate from PrintInfo import pr from JSONParser import loadset, getset import sys from lang import getdict, getlan lan = None se = loadset() if se == -1 or se == -2: se = {} ip = {} lan = getdict('filter', getlan(se, ip)) if __name__ != "__main__": print(lan['OUTPUT1']) #请运行"filter.py"。 else: pr() read = biliPlayerXmlParser.loadXML() xml = read #弹幕过滤列表 if read == -1: print(lan['OUTPUT2'].replace( '<filename>', 'tv.bilibili.plater.xml')) #找不到文件"<filename>"。 exit(-1) se = loadset() if not isinstance(se, dict): se = None o = 'Download/' read = getset(se, 'o')
def parsefromCSSHex(s: str) -> ASSScriptColor: re = search(r'^#([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})?$', s, I) if re is not None: re = re.groups() r = ASSScriptColor(int(re[0], 16), int(re[1], 16), int(re[2], 16)) if re[3]: r.set_color(alpha=int(re[3], 16)) return r re = search(r'^#([0-9A-F])([0-9A-F])([0-9A-F])([0-9A-F])?$', s, I) if re is not None: re = re.groups() r = ASSScriptColor(int(re[0] * 2, 16), int(re[1] * 2, 16), int(re[2] * 2, 16)) if re[3]: r.set_color(alpha=int(re[3] * 2, 16)) return r raise ValueError(lan['INVALID_CSS_COLOR'].replace('<value>', str(s))) lan = None se = loadset() if se == -1 or se == -2: se = {} ip = {} if len(sys.argv) > 1: ip = gopt(sys.argv[1:]) lan = getdict('ASSWriter', getlan(se, ip))