mirror of
https://github.com/lifegpc/pythonscript.git
synced 2026-06-06 11:28:58 +08:00
Use vendor instead of engine
This commit is contained in:
110
eh_mark_vn.py
110
eh_mark_vn.py
@@ -4,15 +4,22 @@ from sys import exit
|
|||||||
from re import compile
|
from re import compile
|
||||||
|
|
||||||
|
|
||||||
BGI = compile(r'^(tmb_|ex_)?([ehm]v\d+[a-z_]*|scene\d+)\.(jpg|png)$')
|
# きゃべつそふと BGI
|
||||||
KRKR = compile(r'^(E[VC]H?\d+H?(_\d+[a-z_]*)?|img_.*)\.(jpg|png)$')
|
CABBAGE_SOFT_BGI = compile(r'^(tmb_|ex_|br_)?([ehm]v|bg)\d+[a-z_0-9A-Z]*\.(jpg|png)$') # noqa: E501
|
||||||
|
# きゃべつそふと 星恋*ティンクル
|
||||||
|
HOSHIKOI_TWINKLE = compile(r'^(((ev|z_)?etc|nagi|saku|sd|sora|tama)\d+)[a-z_]*(_large)?\.(jpg|png)$') # noqa: E501
|
||||||
|
HOSHIKOI_H_LIST = ['etc06', 'nagi08', 'nagi09', 'nagi10', 'nagi11', 'nagi12', 'nagi13', 'nagi14', 'nagi15', 'nagi16', 'nagi17', 'nagi19', 'nagi22', 'saku02', 'saku03', 'saku08', 'saku09', 'saku11', 'saku12', 'saku13', 'saku14', 'saku15', 'saku16', 'saku17', 'saku18', 'sora01', 'sora02', 'sora03', 'sora05', 'sora07', 'sora09', 'sora10', 'sora11', 'sora12', 'sora13', 'sora14', 'sora15', 'sora16', 'sora17', 'sora18', 'sora19', 'sora21', 'tama03', 'tama08', 'tama09', 'tama10', 'tama11', 'tama12', 'tama13', 'tama16', 'tama17', 'tama18', 'tama19', 'z_etc28'] # noqa: E501
|
||||||
|
# Lump of Sugar
|
||||||
|
LOS_BGI = compile(r'^h?ev(sd)?h?_.*\.(png|jpg)')
|
||||||
|
# Lump of Sugar ねこツク、さくら。
|
||||||
|
LOS_BGI_H = compile(r'^ev_[a-z]h.*\.(png|jpg)')
|
||||||
p = ArgumentParser()
|
p = ArgumentParser()
|
||||||
p.add_argument('-b', '--base', default='http://localhost:8080', help='API Host') # noqa: E501
|
p.add_argument('-b', '--base', default='http://localhost:8080', help='API Host') # noqa: E501
|
||||||
p.add_argument('-t', '--token', help='Token')
|
p.add_argument('-t', '--token', help='Token')
|
||||||
p.add_argument('-p', '--print', action='store_true', default=False, help='Print page') # noqa: E501
|
p.add_argument('-p', '--print', action='store_true', default=False, help='Print page') # noqa: E501
|
||||||
p.add_argument('-d', '--dryrun', action='store_true', default=False, help='Dry run') # noqa: E501
|
p.add_argument('-d', '--dryrun', action='store_true', default=False, help='Dry run') # noqa: E501
|
||||||
p.add_argument('gid', help='Gallery id', type=int)
|
p.add_argument('gid', help='Gallery id', type=int)
|
||||||
p.add_argument('typ', nargs='?', default='auto', choices=['auto', 'bgi', 'krkr'], help='Engine') # noqa: E501
|
p.add_argument('typ', nargs='?', default='auto', choices=['auto', 'cabbage-soft', 'cabbage-soft/hoshikoi-twinkle'], help='Type') # noqa: E501
|
||||||
arg = p.parse_intermixed_args()
|
arg = p.parse_intermixed_args()
|
||||||
|
|
||||||
|
|
||||||
@@ -33,58 +40,72 @@ def mark(page, changes, is_nsfw=None, is_ad=None):
|
|||||||
print(f'Mark {index}.{name}({width}x{height}) as {", ".join(t)}')
|
print(f'Mark {index}.{name}({width}x{height}) as {", ".join(t)}')
|
||||||
|
|
||||||
|
|
||||||
def bgi_check_pages(pages, changes):
|
def check_tag(tags: list, tag: str):
|
||||||
|
for t in tags:
|
||||||
|
if t['tag'] == tag:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def check_cabbage_soft_pages(pages):
|
||||||
for p in pages:
|
for p in pages:
|
||||||
name: str = p['name']
|
name: str = p['name']
|
||||||
if name.startswith("tmb_"):
|
if name.startswith("tmb_"):
|
||||||
name = name[4:]
|
name = name[4:]
|
||||||
is_nsfw = name.startswith("hv") or name.startswith("scene")
|
is_nsfw = name.startswith("hv")
|
||||||
mark(p, changes, is_nsfw, True)
|
mark(p, changes, is_nsfw, True)
|
||||||
elif name.startswith("hv"):
|
else:
|
||||||
|
if name.startswith("ex_") or name.startswith('br_'):
|
||||||
|
name = name[3:]
|
||||||
|
if name.startswith("hv"):
|
||||||
|
mark(p, changes, True, False)
|
||||||
|
else:
|
||||||
|
mark(p, changes, False, False)
|
||||||
|
|
||||||
|
|
||||||
|
def check_hoshikoi_twinkle(pages):
|
||||||
|
for p in pages:
|
||||||
|
name: str = p['name']
|
||||||
|
m = HOSHIKOI_TWINKLE.match(name)
|
||||||
|
if not m:
|
||||||
|
continue
|
||||||
|
t = m.group(1)
|
||||||
|
if t in HOSHIKOI_H_LIST:
|
||||||
mark(p, changes, True, False)
|
mark(p, changes, True, False)
|
||||||
else:
|
else:
|
||||||
mark(p, changes, False, False)
|
mark(p, changes, False, False)
|
||||||
|
|
||||||
|
|
||||||
def krkr_check_pages(pages, changes):
|
def guess_cabbage_soft(pages):
|
||||||
|
c = 0
|
||||||
for p in pages:
|
for p in pages:
|
||||||
name: str = p['name']
|
name: str = p['name']
|
||||||
ns = name.split('_')
|
if name.startswith('_') or CABBAGE_SOFT_BGI.match(name):
|
||||||
if ns[0].startswith("EVH"):
|
c += 1
|
||||||
mark(p, changes, True, False)
|
return c / len(pages)
|
||||||
elif ns[0].startswith("EV") and ns[0].endswith("H"):
|
|
||||||
mark(p, changes, True, False)
|
|
||||||
|
def guess_hoshikoi_twinkle(pages):
|
||||||
|
c = 0
|
||||||
|
for p in pages:
|
||||||
|
name: str = p['name']
|
||||||
|
if name.startswith('_') or HOSHIKOI_TWINKLE.match(name):
|
||||||
|
c += 1
|
||||||
else:
|
else:
|
||||||
mark(p, changes, False, False)
|
print(name)
|
||||||
|
|
||||||
|
|
||||||
def guess_as_bgi(pages):
|
|
||||||
c = 0
|
|
||||||
for p in pages:
|
|
||||||
name: str = p['name']
|
|
||||||
if name.startswith('_') or BGI.match(name):
|
|
||||||
c += 1
|
|
||||||
return c / len(pages)
|
return c / len(pages)
|
||||||
|
|
||||||
|
|
||||||
def guess_as_krkr(pages):
|
def guess_engine(pages, tags):
|
||||||
c = 0
|
if check_tag(tags, 'group:cabbage soft'):
|
||||||
for p in pages:
|
cabbage_soft = guess_cabbage_soft(pages)
|
||||||
name: str = p['name']
|
print("きゃべつそふと(BGI) coverage:", cabbage_soft)
|
||||||
if name.startswith('_') or KRKR.match(name):
|
if cabbage_soft >= 0.9:
|
||||||
c += 1
|
return 'cabbage-soft'
|
||||||
return c / len(pages)
|
hoshikoi = guess_hoshikoi_twinkle(pages)
|
||||||
|
print("星恋*ティンクル coverage:", hoshikoi)
|
||||||
|
if hoshikoi >= 0.9:
|
||||||
def guess_engine(pages):
|
return 'cabbage-soft/hoshikoi-twinkle'
|
||||||
bgi = guess_as_bgi(pages)
|
|
||||||
print('BGI coverage:', bgi)
|
|
||||||
if bgi >= 0.9:
|
|
||||||
return 'bgi'
|
|
||||||
krkr = guess_as_krkr(pages)
|
|
||||||
print('KRKR coverage:', krkr)
|
|
||||||
if krkr >= 0.9:
|
|
||||||
return krkr
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -94,20 +115,21 @@ with EHC() as c:
|
|||||||
c.ses.headers.update({'X-TOKEN': arg.token})
|
c.ses.headers.update({'X-TOKEN': arg.token})
|
||||||
gallery = c.get_gallery(arg.gid)
|
gallery = c.get_gallery(arg.gid)
|
||||||
pages = gallery['pages']
|
pages = gallery['pages']
|
||||||
|
tags = gallery['tags']
|
||||||
if arg.print:
|
if arg.print:
|
||||||
for p in pages:
|
for p in pages:
|
||||||
print(p)
|
print(p)
|
||||||
exit(0)
|
exit(0)
|
||||||
typ = arg.typ
|
typ = arg.typ
|
||||||
if typ == 'auto':
|
if typ == 'auto':
|
||||||
typ = guess_engine(pages)
|
typ = guess_engine(pages, tags)
|
||||||
if not typ:
|
if not typ:
|
||||||
raise ValueError('Unknown engine.')
|
raise ValueError('Unknown engine.')
|
||||||
changes = []
|
changes = []
|
||||||
if typ == 'bgi':
|
if typ == 'cabbage-soft':
|
||||||
bgi_check_pages(pages, changes)
|
check_cabbage_soft_pages(pages)
|
||||||
elif typ == 'krkr':
|
elif typ == 'cabbage-soft/hoshikoi-twinkle':
|
||||||
krkr_check_pages(pages, changes)
|
check_hoshikoi_twinkle(pages)
|
||||||
if arg.dryrun:
|
if arg.dryrun:
|
||||||
exit(0)
|
exit(0)
|
||||||
c.update_file_meta_json(changes)
|
c.update_file_meta_json(changes)
|
||||||
|
|||||||
Reference in New Issue
Block a user