l='REQUEST_METHOD'
k='Content-Type'
j='wsgi.input'
i='CONTENT_LENGTH'
h='proxy-connection'
g='upgrade'
f='connection'
e='HTTP_'
d='PATH_INFO'
c='embykeeperweb'
b='embykeeper'
V='/ek'
U=None
T='install'
S='pip'
R='-m'
Q=set
P=Exception
M='CONTENT_TYPE'
G=False
D=int
B=print
A=True
import eventlet as H
H.monkey_patch()
import os as C,sys as K,tempfile as m,subprocess as E,shutil as F
from pathlib import Path
import threading as W
from appdirs import user_data_dir as n
import socketio as N,eventlet as H,requests as X
L='7.1.24'
o=Path(n(b))
O=o/'hf'/'version'
def p():
try:
O.mkdir(parents=A,exist_ok=A);M=O/f"emby-keeper-{L}";H=O/f"emby-keeper-{L}.tar.gz"
if M.exists():B(f"Using cached version from {M}",flush=A);return A
I=m.mkdtemp();B('Downloading EK...',flush=A);D=C.path.join(I,'embykeeper.tar.gz')
if H.exists():B(f"Using cached tarball from {H}",flush=A);F.copy2(H,D)
else:N=f"https://github.com/emby-keeper/emby-keeper/archive/refs/tags/v{L}.tar.gz";E.run(['wget','-q',N,'-O',D],check=A);F.copy2(D,H)
E.run(['tar','xf',D,'-C',I],check=A);C.remove(D);J=C.path.join(I,f"emby-keeper-{L}");B('Obfuscating code...',flush=A)
if not q(J):raise P('Obfuscation failed')
B('Installing dependencies...',flush=A);E.run([K.executable,R,S,T,'-r',C.path.join(J,'requirements.txt')],check=A);E.run([K.executable,R,S,T,J],check=A);F.copytree(J,M,dirs_exist_ok=A);F.rmtree(I);return A
except P as Q:B(f"Error setting up EK: {Q}",flush=A);return G
def q(package_path):
Q='dist';O='pyarmor';I=package_path
try:
E.run([K.executable,R,S,T,O],check=A)
for J in[b,c]:
D=C.path.join(I,J)
if not C.path.exists(D):B(f"Package directory not found: {D}",flush=A);continue
B(f"Obfuscating {J}...",flush=A);E.run([O,'gen','--recursive','--output',C.path.join(I,Q),D],check=A);H=C.path.join(I,Q)
if C.path.exists(H):
for M in C.listdir(H):
L=C.path.join(H,M);N=C.path.join(D,M)
if C.path.isdir(L):F.copytree(L,N,dirs_exist_ok=A)
else:F.copy2(L,N)
F.rmtree(H)
else:B(f"Dist directory not found after obfuscation for {J}",flush=A);return G
return A
except P as U:B(f"Error during obfuscation: {U}",flush=A);return G
def Y():
with H.listen(('',0))as A:return A.getsockname()[1]
def r():
J='Prompt Generator v0.2(More tags)';H='Prompt Generator v0.1(Better quality)';import gradio as C,random as M;from time import time,ctime
def F(choice,num,artist):
L='art by';I=choice;E=artist;C=num;N=time();B(ctime(N))
if I==H:G=open('pr1.txt').read().splitlines()
elif I==J:G=open('pr2.txt').read().splitlines()
if D(C)<1 or D(C)>20:C=10
if D(E)<0 or D(E)>40:E=2
O=len(G);A=[];K=0
while len(sorted(Q(A),key=lambda d:A.index(d))) \n Simple prompt generation script for Midjourney. EmbyKeeper is in /ek path. More examples in Github and Project site\n Simple Prompt Generator v0.6 (Gradio Demo)\n
\n