From 5e0887c657c2a41d170211b0d81f1dc5c8f66960 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Tue, 3 Sep 2024 12:20:06 +0800 Subject: [PATCH 1/2] feat(provider/yt-dlp): remove redundant call playurl is already returned in search stage, let's use it directly. Signed-off-by: Tianling Shen --- src/provider/yt-dlp.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/provider/yt-dlp.js b/src/provider/yt-dlp.js index 901740b6aa..e573e0f87e 100644 --- a/src/provider/yt-dlp.js +++ b/src/provider/yt-dlp.js @@ -47,24 +47,18 @@ async function getUrl(args) { } } -const search = async (info) => { - const { id } = await getUrl(dlArguments(byKeyword(info.keyword))); - return id; -}; - -const track = async (id) => { - const { url } = await getUrl(dlArguments(byId(id))); +const track = async (info) => { + const { url } = await getUrl(dlArguments(byKeyword(info.keyword))); return url; }; const cs = getManagedCacheStorage('yt-dlp'); const check = (info) => cs - .cache(info, () => search(info)) - .then(track) + .cache(info, () => track(info)) .catch((e) => { if (e) logger.error(e); throw e; }); -module.exports = { check, track }; +module.exports = { check }; From 0c881d13e8627d41d188112ceec4334e2da9cb05 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Tue, 3 Sep 2024 12:23:52 +0800 Subject: [PATCH 2/2] feat(provider/youtube-dl): remove redundant call playurl is already returned in search stage, let's use it directly. Signed-off-by: Tianling Shen --- src/provider/youtube-dl.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/provider/youtube-dl.js b/src/provider/youtube-dl.js index d74a25bc4b..4e128f69a0 100644 --- a/src/provider/youtube-dl.js +++ b/src/provider/youtube-dl.js @@ -47,24 +47,18 @@ async function getUrl(args) { } } -const search = async (info) => { - const { id } = await getUrl(dlArguments(byKeyword(info.keyword))); - return id; -}; - -const track = async (id) => { - const { url } = await getUrl(dlArguments(byId(id))); +const track = async (info) => { + const { url } = await getUrl(dlArguments(byKeyword(info.keyword))); return url; }; const cs = getManagedCacheStorage('youtube-dl'); const check = (info) => cs - .cache(info, () => search(info)) - .then(track) + .cache(info, () => track(info)) .catch((e) => { if (e) logger.error(e); throw e; }); -module.exports = { check, track }; +module.exports = { check };