remove qobuz-api directory
This commit is contained in:
parent
dc1425d041
commit
b3b7836cc5
6 changed files with 0 additions and 170 deletions
|
|
@ -1,26 +0,0 @@
|
|||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getDownloadURL } from '@/lib/qobuz-dl-server';
|
||||
import z from 'zod';
|
||||
|
||||
const downloadParamsSchema = z.object({
|
||||
track_id: z.preprocess((a) => parseInt(a as string), z.number().min(0, 'ID must be 0 or greater').default(1)),
|
||||
quality: z.enum(['27', '7', '6', '5']).default('27'),
|
||||
});
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const country = request.headers.get('Token-Country');
|
||||
const params = Object.fromEntries(new URL(request.url).searchParams.entries());
|
||||
try {
|
||||
const { track_id, quality } = downloadParamsSchema.parse(params);
|
||||
const url = await getDownloadURL(track_id, quality, country ? { country } : {});
|
||||
return new NextResponse(JSON.stringify({ success: true, data: { url } }), { status: 200 });
|
||||
} catch (error: any) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
success: false,
|
||||
error: error?.errors || error.message || 'An error occurred parsing the request.',
|
||||
}),
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getAlbumInfo } from '@/lib/qobuz-dl-server';
|
||||
import z from 'zod';
|
||||
|
||||
const albumInfoParamsSchema = z.object({
|
||||
album_id: z.string().min(1, 'ID is required'),
|
||||
});
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const country = request.headers.get('Token-Country');
|
||||
const params = Object.fromEntries(new URL(request.url).searchParams.entries());
|
||||
try {
|
||||
const { album_id } = albumInfoParamsSchema.parse(params);
|
||||
const data = await getAlbumInfo(album_id, country ? { country } : {});
|
||||
return new NextResponse(JSON.stringify({ success: true, data }), { status: 200 });
|
||||
} catch (error: any) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
success: false,
|
||||
error: error?.errors || error.message || 'An error occurred parsing the request.',
|
||||
}),
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getArtist } from '@/lib/qobuz-dl-server';
|
||||
import z from 'zod';
|
||||
|
||||
const artistParamsSchema = z.object({
|
||||
artist_id: z.string().min(1, 'ID is required'),
|
||||
});
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const country = request.headers.get('Token-Country');
|
||||
const params = Object.fromEntries(new URL(request.url).searchParams.entries());
|
||||
try {
|
||||
const { artist_id } = artistParamsSchema.parse(params);
|
||||
const data = await getArtist(artist_id, country ? { country } : {});
|
||||
return new NextResponse(JSON.stringify({ success: true, data }), { status: 200 });
|
||||
} catch (error: any) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
success: false,
|
||||
error: error?.errors || error.message || 'An error occurred parsing the request.',
|
||||
}),
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
import { tokenCountriesMap, TokenCountry } from '@/config/token-countries';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export async function GET() {
|
||||
if (tokenCountriesMap.length === 0) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
success: false,
|
||||
error: 'No countries list found',
|
||||
})
|
||||
);
|
||||
}
|
||||
try {
|
||||
const countryCodes: string[] = tokenCountriesMap.map((country: TokenCountry) => country.code);
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
data: countryCodes,
|
||||
})
|
||||
);
|
||||
} catch {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
success: false,
|
||||
error: 'Error parsing the countries list',
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { search } from '@/lib/qobuz-dl-server';
|
||||
import z from 'zod';
|
||||
|
||||
const searchParamsSchema = z.object({
|
||||
q: z.string().min(1, 'Query is required'),
|
||||
offset: z.preprocess(
|
||||
(a) => parseInt(a as string),
|
||||
z.number().max(1000, 'Offset must be less than 1000').min(0, 'Offset must be 0 or greater').default(0)
|
||||
),
|
||||
});
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const country = request.headers.get('Token-Country');
|
||||
const params = Object.fromEntries(new URL(request.url).searchParams.entries());
|
||||
try {
|
||||
const { q, offset } = searchParamsSchema.parse(params);
|
||||
const searchResults = await search(q, 10, offset, country ? { country } : {});
|
||||
return new NextResponse(JSON.stringify({ success: true, data: searchResults }), { status: 200 });
|
||||
} catch (error: any) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
success: false,
|
||||
error: error?.errors || error.message || 'An error occurred parsing the request.',
|
||||
}),
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getArtistReleases } from '@/lib/qobuz-dl-server';
|
||||
import z from 'zod';
|
||||
|
||||
const releasesParamsSchema = z.object({
|
||||
artist_id: z.string().min(1, 'ID is required'),
|
||||
release_type: z.enum(['album', 'live', 'compilation', 'epSingle', 'download']).default('album'),
|
||||
track_size: z.number().positive().default(1000),
|
||||
offset: z.preprocess((a) => parseInt(a as string), z.number().nonnegative().default(0)),
|
||||
limit: z.preprocess((a) => parseInt(a as string), z.number().positive().default(10)),
|
||||
});
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const country = request.headers.get('Token-Country');
|
||||
const params = Object.fromEntries(new URL(request.url).searchParams.entries());
|
||||
try {
|
||||
const { artist_id, release_type, track_size, offset, limit } = releasesParamsSchema.parse(params);
|
||||
const data = await getArtistReleases(
|
||||
artist_id,
|
||||
release_type,
|
||||
limit,
|
||||
offset,
|
||||
track_size,
|
||||
country ? { country } : {}
|
||||
);
|
||||
return new NextResponse(JSON.stringify({ success: true, data }), { status: 200 });
|
||||
} catch (error: any) {
|
||||
return new NextResponse(
|
||||
JSON.stringify({
|
||||
success: false,
|
||||
error: error?.errors || error.message || 'An error occurred parsing the request.',
|
||||
}),
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue