Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问我这个是路径问题还是key #1

Open
ershouqingge opened this issue Dec 1, 2022 · 11 comments
Open

请问我这个是路径问题还是key #1

ershouqingge opened this issue Dec 1, 2022 · 11 comments

Comments

@ershouqingge
Copy link

2022-12-01 07:11:34 stderr 2022/12/01 07:11:34 [error] 27#27: *27 js exception: Error: unhandled promise rejection: SyntaxError: Unexpected token at position 0, client: 172.19.0.1, server: default, request: "GET /emby/videos/8/stream.mkv?DeviceId=4AA1DC47-009B-4DE9-A10E-0990CD440F00&MediaSourceId=5b8640b915468dfbbd3533985334cc1d&Static=true&PlaySessionId=cf5677837ead4abea384575d6c4407ff&api_key=deb7d1f477e946208fdd332c48efbaa6&SubtitleCodec=subrip HTTP/1.1", host: "admin.xyz:8095"
2022-12-01 07:11:34 stderr 2022/12/01 07:11:34 [warn] 27#27: *27 js: mount emby file path: /mnt/share/日韩剧/苏里南(2022)/Season 1/苏里南 Narco Saints - S01E01 - 第1集.mkv
2022-12-01 07:11:34 stderr 2022/12/01 07:11:34 [warn] 27#27: *27 js: itemInfoUri: http://192.168.0.153:8097/Items/8/PlaybackInfo?MediaSourceId=5b8640b915468dfbbd3533985334cc1d&api_key=deb7d1f477e946208fdd332c48efbaa6
@ershouqingge
Copy link
Author

我emby端口是8097 反代端口是8095 emby.conf和js都改过了 感谢

@zxcvbnmzsedr
Copy link
Owner

看不出啥问题,在emby.js中 多打点log 看报错的是哪一行

@zxcvbnmzsedr
Copy link
Owner

也有可能是 alist的问题,这个版本是根据alist v2写的

@ershouqingge
Copy link
Author

大佬 我已经邮件把所有配置和日志发你你看到了吗

@ershouqingge
Copy link
Author

也有可能是 alist的问题,这个版本是根据alist v2写的

https://{{HOST}}/api/public/path 我去alist项目看了v2和v3的api都是一样的请求接口的

@ershouqingge
Copy link
Author

看不出啥问题,在emby.js中 多打点log 看报错的是哪一行

date stream content
2022-12-01 09:02:13 stdout 172.19.0.1 - - [01/Dec/2022:09:02:13 +0000] "POST /emby/Sessions/Playing/Progress?X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6&reqformat=json HTTP/1.1" 204 0 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:11 stdout 172.19.0.1 - - [01/Dec/2022:09:02:11 +0000] "GET /emby/videos/8/hls1/main/8.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 3604900 "-" "libmpv" "-"
2022-12-01 09:02:11 stdout 172.19.0.1 - - [01/Dec/2022:09:02:11 +0000] "GET /emby/videos/8/hls1/main/7.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 3373660 "-" "libmpv" "-"
2022-12-01 09:02:11 stdout 172.19.0.1 - - [01/Dec/2022:09:02:11 +0000] "POST /emby/Sessions/Playing/Progress?X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6&reqformat=json HTTP/1.1" 204 0 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:10 stdout 172.19.0.1 - - [01/Dec/2022:09:02:10 +0000] "GET /emby/videos/8/hls1/main/6.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 3169116 "-" "libmpv" "-"
2022-12-01 09:02:10 stdout 172.19.0.1 - - [01/Dec/2022:09:02:10 +0000] "GET /emby/videos/8/hls1/main/5.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 2380832 "-" "libmpv" "-"
2022-12-01 09:02:09 stdout 172.19.0.1 - - [01/Dec/2022:09:02:09 +0000] "GET /emby/videos/8/hls1/main/4.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 2109548 "-" "libmpv" "-"
2022-12-01 09:02:09 stdout 172.19.0.1 - - [01/Dec/2022:09:02:09 +0000] "GET /emby/videos/8/hls1/main/3.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 472444 "-" "libmpv" "-"
2022-12-01 09:02:09 stdout 172.19.0.1 - - [01/Dec/2022:09:02:09 +0000] "GET /emby/videos/8/hls1/main/2.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 455148 "-" "libmpv" "-"
2022-12-01 09:02:09 stdout 172.19.0.1 - - [01/Dec/2022:09:02:09 +0000] "GET /emby/videos/8/hls1/main/1.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 2028708 "-" "libmpv" "-"
2022-12-01 09:02:08 stdout 172.19.0.1 - - [01/Dec/2022:09:02:08 +0000] "POST /emby/Sessions/Playing/Progress?X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6&reqformat=json HTTP/1.1" 204 0 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:08 stdout 172.19.0.1 - - [01/Dec/2022:09:02:08 +0000] "POST /emby/Sessions/Playing/Progress?X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6&reqformat=json HTTP/1.1" 204 0 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:08 stdout 172.19.0.1 - - [01/Dec/2022:09:02:08 +0000] "GET /emby/videos/8/hls1/main/0.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 422436 "-" "libmpv" "-"
2022-12-01 09:02:08 stdout 172.19.0.1 - - [01/Dec/2022:09:02:08 +0000] "GET /emby/Users/aec24b94eb1e4a649449477e65d98ee2/Items/8?X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6 HTTP/1.1" 200 2731 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:08 stdout 172.19.0.1 - - [01/Dec/2022:09:02:08 +0000] "POST /emby/Videos/ActiveEncodings/Delete?deviceId=4AA1DC47-009B-4DE9-A10E-0990CD440F00&PlaySessionId=27a7c397230147038d8ecb2c9d052006&X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6 HTTP/1.1" 204 0 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:08 stdout 172.19.0.1 - - [01/Dec/2022:09:02:08 +0000] "POST /emby/Sessions/Playing/Progress?X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6&reqformat=json HTTP/1.1" 204 0 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:08 stdout 172.19.0.1 - - [01/Dec/2022:09:02:08 +0000] "GET /emby/videos/8/hls1/main/1.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 1494341 "-" "libmpv" "-"
2022-12-01 09:02:08 stdout 172.19.0.1 - - [01/Dec/2022:09:02:08 +0000] "GET /emby/videos/8/hls1/main/0.ts?PlaySessionId=68d71610498f4efeafcb2388cda92707 HTTP/1.1" 200 422436 "-" "libmpv" "-"
2022-12-01 09:02:05 stdout 172.19.0.1 - - [01/Dec/2022:09:02:05 +0000] "GET /emby/videos/8/main.m3u8?DeviceId=4AA1DC47-009B-4DE9-A10E-0990CD440F00&MediaSourceId=5b8640b915468dfbbd3533985334cc1d&PlaySessionId=68d71610498f4efeafcb2388cda92707&api_key=deb7d1f477e946208fdd332c48efbaa6&VideoCodec=h264,hevc,mpeg2video&AudioCodec=ac3,mp3,aac&VideoBitrate=139232000&AudioBitrate=768000&AudioStreamIndex=1&SubtitleStreamIndex=3&SubtitleMethod=Encode&TranscodingMaxAudioChannels=6&SegmentContainer=ts&SegmentLength=3&MinSegments=1&BreakOnNonKeyFrames=True&hevc-profile=Main,Main10&TranscodeReasons=DirectPlayError HTTP/1.1" 200 109091 "-" "libmpv" "-"
2022-12-01 09:02:05 stdout 172.19.0.1 - - [01/Dec/2022:09:02:05 +0000] "GET /emby/videos/8/master.m3u8?DeviceId=4AA1DC47-009B-4DE9-A10E-0990CD440F00&MediaSourceId=5b8640b915468dfbbd3533985334cc1d&PlaySessionId=68d71610498f4efeafcb2388cda92707&api_key=deb7d1f477e946208fdd332c48efbaa6&VideoCodec=h264,hevc,mpeg2video&AudioCodec=ac3,mp3,aac&VideoBitrate=139232000&AudioBitrate=768000&AudioStreamIndex=1&SubtitleStreamIndex=3&SubtitleMethod=Encode&TranscodingMaxAudioChannels=6&SegmentContainer=ts&SegmentLength=3&MinSegments=1&BreakOnNonKeyFrames=True&hevc-profile=Main,Main10&TranscodeReasons=DirectPlayError HTTP/1.1" 200 689 "-" "libmpv" "-"
2022-12-01 09:02:05 stdout 172.19.0.1 - - [01/Dec/2022:09:02:05 +0000] "GET /emby/videos/8/master.m3u8?DeviceId=4AA1DC47-009B-4DE9-A10E-0990CD440F00&MediaSourceId=5b8640b915468dfbbd3533985334cc1d&PlaySessionId=68d71610498f4efeafcb2388cda92707&api_key=deb7d1f477e946208fdd332c48efbaa6&VideoCodec=h264,hevc,mpeg2video&AudioCodec=ac3,mp3,aac&VideoBitrate=139232000&AudioBitrate=768000&AudioStreamIndex=1&SubtitleStreamIndex=3&SubtitleMethod=Encode&TranscodingMaxAudioChannels=6&SegmentContainer=ts&SegmentLength=3&MinSegments=1&BreakOnNonKeyFrames=True&hevc-profile=Main,Main10&TranscodeReasons=DirectPlayError HTTP/1.1" 200 689 "-" "libmpv" "-"
2022-12-01 09:02:05 stdout 172.19.0.1 - - [01/Dec/2022:09:02:05 +0000] "POST /emby/Videos/ActiveEncodings/Delete?deviceId=4AA1DC47-009B-4DE9-A10E-0990CD440F00&PlaySessionId=27a7c397230147038d8ecb2c9d052006&X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6 HTTP/1.1" 204 0 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:05 stdout 172.19.0.1 - - [01/Dec/2022:09:02:05 +0000] "POST /emby/Items/8/PlaybackInfo?UserId=aec24b94eb1e4a649449477e65d98ee2&StartTimeTicks=0&IsPlayback=true&AutoOpenLiveStream=true&AudioStreamIndex=1&SubtitleStreamIndex=3&EnableDirectPlay=false&EnableDirectStream=false&MediaSourceId=5b8640b915468dfbbd3533985334cc1d&MaxStreamingBitrate=140000000&CurrentPlaySessionId=27a7c397230147038d8ecb2c9d052006&X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6&reqformat=json HTTP/1.1" 200 16578 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:05 stdout 172.19.0.1 - - [01/Dec/2022:09:02:05 +0000] "POST /emby/Sessions/Playing?X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6&reqformat=json HTTP/1.1" 204 0 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"
2022-12-01 09:02:05 stderr 2022/12/01 09:02:05 [error] 25#25: *182 js exception: Error: unhandled promise rejection: SyntaxError: Unexpected token at position 0, client: 172.19.0.1, server: default, request: "GET /emby/videos/8/stream.mkv?DeviceId=4AA1DC47-009B-4DE9-A10E-0990CD440F00&MediaSourceId=5b8640b915468dfbbd3533985334cc1d&Static=true&PlaySessionId=27a7c397230147038d8ecb2c9d052006&api_key=deb7d1f477e946208fdd332c48efbaa6&SubtitleCodec=subrip HTTP/1.1", host: "admin.xyz:8095"
2022-12-01 09:02:05 stdout 172.19.0.1 - - [01/Dec/2022:09:02:05 +0000] "GET /emby/videos/8/stream.mkv?DeviceId=4AA1DC47-009B-4DE9-A10E-0990CD440F00&MediaSourceId=5b8640b915468dfbbd3533985334cc1d&Static=true&PlaySessionId=27a7c397230147038d8ecb2c9d052006&api_key=deb7d1f477e946208fdd332c48efbaa6&SubtitleCodec=subrip HTTP/1.1" 000 0 "-" "libmpv" "-"
2022-12-01 09:02:05 stderr 2022/12/01 09:02:05 [warn] 25#25: *182 js: mount emby file path: /mnt/share/日韩剧/苏里南(2022)/Season 1/苏里南 Narco Saints - S01E01 - 第1集.mkv
2022-12-01 09:02:05 stderr 2022/12/01 09:02:05 [warn] 25#25: *182 js: itemInfoUri: http://192.168.0.153:8097/Items/8/PlaybackInfo?MediaSourceId=5b8640b915468dfbbd3533985334cc1d&api_key=deb7d1f477e946208fdd332c48efbaa6
2022-12-01 09:02:04 stdout 172.19.0.1 - - [01/Dec/2022:09:02:04 +0000] "POST /emby/Items/8/PlaybackInfo?UserId=aec24b94eb1e4a649449477e65d98ee2&StartTimeTicks=0&IsPlayback=true&AutoOpenLiveStream=true&MaxStreamingBitrate=140000000&X-Emby-Client=Emby%20for%20iOS&X-Emby-Device-Name=iPhone&X-Emby-Device-Id=4AA1DC47-009B-4DE9-A10E-0990CD440F00&X-Emby-Client-Version=2.2.5&X-Emby-Token=deb7d1f477e946208fdd332c48efbaa6&reqformat=json HTTP/1.1" 200 17150 "http://localhost:12344/" "Mozilla/5.0 (iPhone; CPU iPhone OS 16_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" "-"

@ershouqingge
Copy link
Author

大佬 我已经邮件把所有配置和日志发你你看到了吗

上面这个日志可以吗

@zxcvbnmzsedr
Copy link
Owner

V2和V3的请求API是一样的,但是返回结构是不一样的

@zxcvbnmzsedr
Copy link
Owner

zxcvbnmzsedr commented Dec 1, 2022

将整个 fetchAlistPathApi 方法替换成下面的这个试试看

async function fetchAlistPathApi(alistApiPath, alistFilePath, alistPwd) {
    const alistRequestBody = {
        "path": alistFilePath,
        "password": alistPwd
    }
    try {
        const response = await ngx.fetch(alistApiPath, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json;charset=utf-8'
            },
            max_response_body_size: 65535,
            body: JSON.stringify(alistRequestBody)
        })
        if (response.ok) {
            const result = await response.json();
            if (result === null || result === undefined) {

                return `error: alist_path_api response is null`;
            }

            if (result.message == 'success') {
                if (!result.data.is_dir) {
                   return result.data.raw_url;
                }
            }
            if (result.code == 401) {
                return `error401: alist_path_api ${result.message}`;
            }
            if (result.message.includes('account')) {
                return `error404: alist_path_api ${result.code} ${result.message}`;
            }
            if (result.message == 'file not found' || result.message == 'path not found') {
                return `error404: alist_path_api ${result.message}`;
            }
            return `error: alist_path_api ${result.code} ${result.message}`;
        }
        else {
            return `error: alist_path_api ${response.status} ${response.statusText}`;
        }
    } catch (error) {
        return (`error: alist_path_api fetchAlistFiled ${error}`);
    }
}

@psychopasss
Copy link

psychopasss commented Feb 20, 2024

//查看日志: "docker logs -f -n 10 emby-nginx 2>&1  | grep js:"
async function redirect2Pan(r) {
    //根据实际情况修改下面4个设置
    const embyHost = 'http://xxx:8096'; //这里默认emby/jellyfin的地址是宿主机,要注意iptables给容器放行端口
    const embyMountPath = '/video/alist';  // rclone 的挂载目录, 例如将od, gd挂载到/mnt目录下:  /mnt/onedrive  /mnt/gd ,那么这里 就填写 /mnt
    const alistToken = '';      //alist token
    const alistApiPath = 'http://xxx:5244/api/fs/get'; //访问宿主机上5244端口的alist api, 要注意iptables给容 器放行端口

    //fetch mount emby/jellyfin file path
    const regex = /[A-Za-z0-9]+/g;
    const itemId = r.uri.replace('emby', '').replace(/-/g, '').match(regex)[1];
    let mediaSourceId = r.args.MediaSourceId;
    let api_key = r.args.api_key;
    if ((mediaSourceId === null) || (mediaSourceId === undefined)) {
        mediaSourceId = '';
    }
    //infuse用户需要填写下面的api_key, 感谢@amwamw968
    if ((api_key === null) || (api_key === undefined)) {
        api_key = '';//这里填自己的emby/jellyfin API KEY
        r.warn(`api key for Infuse: ${api_key}`);
    }

    const itemInfoUri = `${embyHost}/Items/${itemId}/PlaybackInfo?MediaSourceId=${mediaSourceId}&api_key=${api_key}`;
    r.warn(`itemInfoUri: ${itemInfoUri}`);
    const embyRes = await fetchEmbyFilePath(itemInfoUri, r);
    if (embyRes.startsWith('error')) {
        r.error(embyRes);
        r.return(500, embyRes);
        return;
    }
    r.warn(`mount emby file path: ${embyRes}`);

    //fetch alist direct link
    const alistFilePath = embyRes.replace(embyMountPath, '');
    const alistRes = await fetchAlistPathApi(alistApiPath, alistFilePath, alistToken, r);
    if (!alistRes.startsWith('error')) {
        r.warn(`redirect to: ${alistRes}`);
        r.return(302, alistRes);
        return;
    }
    if (alistRes.startsWith('error401')) {
        r.error(alistRes);
        r.return(401, alistRes);
        return;
    }
    if (alistRes.startsWith('error404')) {
        const filePath = alistFilePath.substring(alistFilePath.indexOf('/', 1));
        const foldersRes = await fetchAlistPathApi(alistApiPath, '/', alistToken, r);
        if (foldersRes.startsWith('error')) {
            r.error(foldersRes);
            r.return(500, foldersRes);
            return;
        }
        const folders = foldersRes.split(',').sort();
        for (let i = 0; i < folders.length; i++) {
            r.warn(`try to fetch alist path from /${folders[i]}${filePath}`);
            const driverRes = await fetchAlistPathApi(alistApiPath, `/${folders[i]}${filePath}`, alistToken, r);
            if (!driverRes.startsWith('error')) {
                r.warn(`redirect to: ${driverRes}`);
                r.return(302, driverRes);
                return;
            }
        }
        r.warn(`not found direct ${alistRes}`);
        r.internalRedirect("@backend");
        return;

    }
    r.warn(`not found direct ${alistRes}`);
    r.internalRedirect("@backend");
    return;
}

async function fetchAlistPathApi(alistApiPath, alistFilePath, alistToken, r) {
    const alistRequestBody = {
        "path": alistFilePath
    }
    try {
        const response = await ngx.fetch(alistApiPath, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json;charset=utf-8',
                'Authorization': alistToken
            },
            max_response_body_size: 65535,
            body: JSON.stringify(alistRequestBody)
        })
        if (response.ok) {
            const result = await response.json();
            let resultJsonString = JSON.stringify(result);
            r.warn(`alist result: ${resultJsonString}`);
            if (result === null || result === undefined) {
                return `error: alist_path_api response is null`;
            }
            if (result.message == 'success') {
                if (!result.data.is_dir) {
                    return result.data.raw_url;
                }
            }
            if (result.code == 401) {
                return `error401: alist_path_api ${result.message}`;
            }
            if (result.message.includes('account')) {
                return `error404: alist_path_api ${result.code} ${result.message}`;
            }
            if (result.message == 'file not found' || result.message == 'path not found') {
                return `error404: alist_path_api ${result.message}`;
            }
            return `error: alist_path_api ${result.code} ${result.message}`;
        }
        else {
            return `error: alist_path_api ${response.status} ${response.statusText}`;
        }
    } catch (error) {
        return (`error: alist_path_api fetchAlistFiled ${error}`);
    }
}

async function fetchEmbyFilePath(itemInfoUri, r) {
    try {
        const res = await ngx.fetch(itemInfoUri, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json;charset=utf-8',
                'Content-Length': 0,
            },
            max_response_body_size: 65535,
        });
        if (res.ok) {
            const result = await res.json();
            let resultJsonString = JSON.stringify(result);
            r.warn(`emby result: ${resultJsonString}`);
            if (result === null || result === undefined) {
                return `error: emby_api itemInfoUri response is null`;
            }
            return result.MediaSources[0].Path;
        }
        else {
            return (`error: emby_api ${res.status} ${res.statusText}`);
        }
    }
    catch (error) {
        return (`error: emby_api fetch mediaItemInfo failed,  ${error}`);
    }
}

export default { redirect2Pan };

emby.js用这个,适配了alist V3的api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants