summaryrefslogtreecommitdiff
path: root/apps/web/src/app/api
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-08-04 02:59:07 +0200
committerMaze Winther <mazewinther@gmail.com>2025-08-04 02:59:07 +0200
commitacc2089d0d6975d9cede833b083f9d1d2f78504d (patch)
tree4697e16e1c3e92711e1bb92e8504b2634c6d6d46 /apps/web/src/app/api
parent35ade4b25f417e0d7c4d155b8afc51fb94ebcdd7 (diff)
downloadopencut-acc2089d0d6975d9cede833b083f9d1d2f78504d.tar.gz
feat: add license filtering for sound effects
Diffstat (limited to 'apps/web/src/app/api')
-rw-r--r--apps/web/src/app/api/sounds/search/route.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/apps/web/src/app/api/sounds/search/route.ts b/apps/web/src/app/api/sounds/search/route.ts
index 15954140..c89bc76c 100644
--- a/apps/web/src/app/api/sounds/search/route.ts
+++ b/apps/web/src/app/api/sounds/search/route.ts
@@ -12,6 +12,7 @@ const searchParamsSchema = z.object({
.enum(["downloads", "rating", "created", "score"])
.default("downloads"),
min_rating: z.coerce.number().min(0).max(5).default(3),
+ commercial_only: z.coerce.boolean().default(true),
});
const freesoundResultSchema = z.object({
@@ -124,6 +125,7 @@ export async function GET(request: NextRequest) {
page_size: pageSize,
sort,
min_rating,
+ commercial_only,
} = validationResult.data;
if (type === "songs") {
@@ -160,6 +162,15 @@ export async function GET(request: NextRequest) {
if (type === "effects" || !type) {
params.append("filter", "duration:[* TO 30.0]");
params.append("filter", `avg_rating:[${min_rating} TO *]`);
+
+ // Filter by license if commercial_only is true
+ if (commercial_only) {
+ params.append(
+ "filter",
+ 'license:("Attribution" OR "Creative Commons 0" OR "Attribution Noncommercial" OR "Attribution Commercial")'
+ );
+ }
+
params.append(
"filter",
"tag:sound-effect OR tag:sfx OR tag:foley OR tag:ambient OR tag:nature OR tag:mechanical OR tag:electronic OR tag:impact OR tag:whoosh OR tag:explosion"