import base64
#import calibre_plugins.ai_metadata.config as cfg
#dpfu, pf, LK_L, LK_DCD, slt = cfg.DEFAULT_PLATFORM_URLS, cfg.plugin_prefs[cfg.STORE_NAME][cfg.KEY_AI_PLATFORM], ["WVc1MGFISnZjR2xqTG1OdmJRPT1qUTBDMnBDVGRZ","WTI5b1pYSmxMbU52YlE9PWpRMEMycENUZFk=","YjNCbGJtRnBMbU52YlE9PWpRMEMycENUZFk=","YldsemRISmhiQzVoYVE9PWpRMEMycENUZFk=","YldWMFlTNWpiMjA9alEwQzJwQ1RkWQ==","WVhCcExtZHZiMmRzWlM1amIyMD1qUTBDMnBDVGRZ"], [], "YWxFd1F6SndRMVJrV1E9PQ=="
LK_L, LK_DCD, slt = ["WVc1MGFISnZjR2xqTG1OdmJRPT1qUTBDMnBDVGRZ","WTI5b1pYSmxMbU52YlE9PWpRMEMycENUZFk=","YjNCbGJtRnBMbU52YlE9PWpRMEMycENUZFk=","YldsemRISmhiQzVoYVE9PWpRMEMycENUZFk=","YldWMFlTNWpiMjA9alEwQzJwQ1RkWQ==","WVhCcExtZHZiMmRzWlM1amIyMD1qUTBDMnBDVGRZ"], [], "YWxFd1F6SndRMVJrV1E9PQ=="

def en_ascii_st(str_i):
    sb = str_i.encode("ascii")
    b64_b = base64.b64encode(sb)
    b64_s = b64_b.decode("ascii")
    return b64_s
def ascii_st(b64_s):
    b64_b = b64_s.encode("ascii")
    s_b = base64.b64decode(b64_b)
    str_i = s_b.decode("ascii")
    return str_i
def dbl_en_ascii_st(string):
    s_e=en_ascii_st(string)
    eslt=ascii_st(ascii_st(slt))
    s_e=s_e+eslt
    return en_ascii_st(s_e)
def dbl_ascii_st(b64_s):
    s_e=ascii_st(b64_s)
    dslt=ascii_st(ascii_st(slt))
    s_e=s_e.replace(dslt,"")
    return ascii_st(s_e)
def dcd_ls(ls):
    for ils in ls:
        dls = dbl_ascii_st(ils)
        LK_DCD.append(dls)
def ckc_ls(imp, dpfu, pf):
    dcd_ls(LK_L)
    for ls in LK_DCD:
        if ls in imp:
            if dpfu[pf] != "":
                return dpfu[pf]
            else:
                return ""
    return imp