Skip to content

Commit

Permalink
Merge pull request #1481 from UnblockNeteaseMusic/yt
Browse files Browse the repository at this point in the history
feat(yt-dlp, youtube-dl): remove redundant call
  • Loading branch information
pan93412 authored Sep 3, 2024
2 parents bb33ef7 + 0c881d1 commit 0ca630f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
14 changes: 4 additions & 10 deletions src/provider/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
14 changes: 4 additions & 10 deletions src/provider/yt-dlp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

0 comments on commit 0ca630f

Please sign in to comment.