SOURCE

fetch('https://gentle-dream-6173.calvinduo.workers.dev/videos.txt')
  .then(response => response.text())
  .then(data => {
    // 处理数据
    const cids = data.split("\n")
  })
  .catch(error => console.error(error));
console.log(cids)



function isExist(dvdid, cids) {
    try {
        if (dvdid === '') {
            return '';
        }
        const trueIds = {}; // 缓存TrueId
        for (const cid of cids) {
            let cidTrueId = trueIds[cid];
            if (cidTrueId === undefined) { // 如果TrueId未缓存,则计算并缓存
                cidTrueId = getTrueId(cid);
                trueIds[cid] = cidTrueId;
            }
            const dvdidTrimmed = trim(dvdid.toLowerCase());
            const cidTrimmed = trim(cid).toLowerCase();
            if (dvdidTrimmed === cidTrimmed) { // 简单比较
                console.log(${dvdidTrimmed}配对了${cidTrimmed});
                return cid;
            }
            const dvdidTrueId = trueIds[dvdidTrimmed];
            if (dvdidTrueId !== undefined && dvdidTrueId === cidTrueId) { // 判断TrueId是否相等
                console.log(${dvdidTrimmed}配对了${cidTrimmed});
                return cid;
            }
        }
        return '';
    } catch (err) {
        console.log(dvdid=====>${dvdid}\n);
        console.log(cid=======>${tempcid}\n);
        console.log(err);
        return 0;
    }
}

function getTrueId(id) {
    const regex = {
        dash: /-([0-9])/,
        t28: /^55t28([0-9]+)$/,
        r18: /^h_093r18([0-9]+)$/,
        id: /^5521id([0-9]+)$/,
        alpha: /^([a-z]+)([0-9]+)$/,
        num: /^([0-9])([0-9])$/,
    };
    let idChar;
    let idDigi;
    if (regex.dash.test(id)) {
        idChar = id.split('-')[0];
        idDigi = regex.dash.exec(id)[1];
    } else if (regex.t28.test(id)) {
        idChar = 't28';
        idDigi = regex.t28.exec(id)[1];
    } else if (regex.r18.test(id)) {
        idChar = 'r18';
        idDigi = regex.r18.exec(id)[1];
    } else if (regex.id.test(id)) {
        idChar = 'id';
        idDigi = regex.id.exec(id)[1];
    } else if (regex.alpha.test(id)) {
        idChar = regex.alpha.exec(id)[1];
        idDigi = regex.alpha.exec(id)[2];
    } else {
        idChar = id.split('')[0];
        idDigi = id.split('')[1];
    }
    idChar = parseInt(idChar) || idChar;
    idDigi = parseInt(idDigi);
    const idNew = ${idChar}${idDigi};
    return idNew;
}

function trim(mystr) {
    return mystr.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

// 将cids数组转换为Set
const cidsSet = new Set(cids);
const result = isExist(dvdid, cidsSet);
console 命令行工具 X clear

                    
>
console