support for epidemic sound

This commit is contained in:
Steve Berdy 2024-01-17 13:24:37 -05:00
parent dcb3cf3673
commit 7bc5d3990c
6 changed files with 49 additions and 3 deletions

View File

@ -14,6 +14,7 @@ this list is not final and keeps expanding over time. if support for a service y
| service | video + audio | only audio | only video | metadata | rich file names |
| :-------- | :-----------: | :--------: | :--------: | :------: | :-------------: |
| bilibili.com | ✅ | ✅ | ✅ | | |
| epidemic sound | | ✅ | | ✅ | ✅ |
| instagram posts & stories | ✅ | ✅ | ✅ | | |
| instagram reels | ✅ | ✅ | ✅ | | |
| pinterest | ✅ | ✅ | ✅ | | |

View File

@ -24,6 +24,7 @@ import pinterest from "./services/pinterest.js";
import streamable from "./services/streamable.js";
import twitch from "./services/twitch.js";
import rutube from "./services/rutube.js";
import epidemicsound from "./services/epidemicsound.js";
export default async function(host, patternMatch, url, lang, obj) {
assert(url instanceof URL);
@ -158,6 +159,11 @@ export default async function(host, patternMatch, url, lang, obj) {
isAudioOnly: isAudioOnly
});
break;
case "epidemicsound":
r = await epidemicsound({
id: patternMatch.id
});
break;
default:
return apiJSON(0, { t: errorUnsupported(lang) });
}

View File

@ -0,0 +1,22 @@
export default async function (obj) {
let json = await fetch(`https://www.epidemicsound.com/json/track/${obj.id}`).then((r) => {
return r.status === 200 ? r.json() : false
}).catch(() => { return false });
let fileMetadata = {
title: json.title,
artist: (json.creatives.mainArtists || []).map(artist => artist.name).join(", ")
}
return {
urls: json.stems.full.lqMp3Url,
filenameAttributes: {
service: "epidemicsound",
id: json.id,
title: fileMetadata.title,
author: fileMetadata.artist
},
isMp3: true,
fileMetadata
}
}

View File

@ -106,6 +106,11 @@
"tld": "ru",
"patterns": ["video/:id", "play/embed/:id"],
"enabled": true
},
"epidemicsound": {
"alias": "epidemic sound music and sound effects",
"patterns": ["track/:id"],
"enabled": true
}
}
}

View File

@ -2,10 +2,13 @@ export const testers = {
"bilibili": (patternMatch) =>
patternMatch.id?.length <= 12,
"epidemicsound": (patternMatch) =>
patternMatch.id?.length === 10,
"instagram": (patternMatch) =>
patternMatch.postId?.length <= 12
|| (patternMatch.username?.length <= 30 && patternMatch.storyId?.length <= 24),
"ok": (patternMatch) =>
patternMatch.id?.length <= 16,
@ -19,12 +22,12 @@ export const testers = {
patternMatch.id?.length === 32,
"soundcloud": (patternMatch) =>
(patternMatch.author?.length <= 255 && patternMatch.song?.length <= 255)
(patternMatch.author?.length <= 255 && patternMatch.song?.length <= 255)
|| patternMatch.shortLink?.length <= 32,
"streamable": (patternMatch) =>
patternMatch.id?.length === 6,
"tiktok": (patternMatch) =>
patternMatch.postId?.length <= 21 || patternMatch.id?.length <= 13,

View File

@ -1171,5 +1171,14 @@
"code": 200,
"status": "stream"
}
}],
"epidemicsound": [{
"name": "track",
"url": "https://www.epidemicsound.com/track/NpuE3YgGmN/",
"params": {},
"expected": {
"code": 200,
"status": "stream"
}
}]
}