mirror of
https://github.com/Kirazul/Verome-API.git
synced 2026-03-08 08:15:20 +00:00
Consolidate API - remove v1/v2 duplication, v2 is now main
This commit is contained in:
712
mod.ts
712
mod.ts
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Virome API for Deno
|
||||
* A consolidated YouTube Music, YouTube Search, JioSaavn, and Last.fm API
|
||||
* YouTube Music, YouTube Search, and Last.fm API
|
||||
*
|
||||
* Run with: deno run --allow-net --allow-env --allow-read mod.ts
|
||||
* Or deploy to Deno Deploy
|
||||
@@ -12,18 +12,15 @@ import { html as uiHtml } from "./ui.ts";
|
||||
|
||||
const PORT = parseInt(Deno.env.get("PORT") || "8000");
|
||||
|
||||
// Initialize clients
|
||||
const ytmusic = new YTMusic();
|
||||
const youtubeSearch = new YouTubeSearch();
|
||||
|
||||
// CORS headers
|
||||
const corsHeaders = {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
||||
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
||||
};
|
||||
|
||||
// Helper functions
|
||||
function json(data: unknown, status = 200): Response {
|
||||
return new Response(JSON.stringify(data), {
|
||||
status,
|
||||
@@ -35,13 +32,10 @@ function error(message: string, status = 400): Response {
|
||||
return json({ error: message }, status);
|
||||
}
|
||||
|
||||
// URL pattern matching
|
||||
function matchRoute(pathname: string, pattern: string): Record<string, string> | null {
|
||||
const patternParts = pattern.split("/");
|
||||
const pathParts = pathname.split("/");
|
||||
|
||||
if (patternParts.length !== pathParts.length) return null;
|
||||
|
||||
const params: Record<string, string> = {};
|
||||
for (let i = 0; i < patternParts.length; i++) {
|
||||
if (patternParts[i].startsWith(":")) {
|
||||
@@ -53,584 +47,269 @@ function matchRoute(pathname: string, pattern: string): Record<string, string> |
|
||||
return params;
|
||||
}
|
||||
|
||||
// Country code to language mapping
|
||||
const countryLanguageMap: Record<string, string> = {
|
||||
TN: "ar", DZ: "ar", MA: "ar", EG: "ar", SA: "ar", AE: "ar", KW: "ar", QA: "ar", BH: "ar", OM: "ar", JO: "ar", LB: "ar", IQ: "ar", LY: "ar", SD: "ar", YE: "ar", SY: "ar", PS: "ar",
|
||||
FR: "fr", BE: "fr", CH: "fr", CA: "fr", SN: "fr", CI: "fr", ML: "fr", BF: "fr", NE: "fr", TG: "fr", BJ: "fr", CM: "fr", MG: "fr",
|
||||
DE: "de", AT: "de",
|
||||
ES: "es", MX: "es", AR: "es", CO: "es", PE: "es", VE: "es", CL: "es", EC: "es", GT: "es", CU: "es", BO: "es", DO: "es", HN: "es", PY: "es", SV: "es", NI: "es", CR: "es", PA: "es", UY: "es",
|
||||
PT: "pt", BR: "pt", AO: "pt", MZ: "pt",
|
||||
IT: "it",
|
||||
NL: "nl",
|
||||
RU: "ru", BY: "ru", KZ: "ru",
|
||||
TR: "tr",
|
||||
JP: "ja",
|
||||
KR: "ko",
|
||||
CN: "zh", TW: "zh", HK: "zh",
|
||||
IN: "hi",
|
||||
TH: "th",
|
||||
VN: "vi",
|
||||
ID: "id",
|
||||
PL: "pl",
|
||||
UA: "uk",
|
||||
RO: "ro",
|
||||
GR: "el",
|
||||
CZ: "cs",
|
||||
SE: "sv",
|
||||
NO: "no",
|
||||
DK: "da",
|
||||
FI: "fi",
|
||||
HU: "hu",
|
||||
IL: "he",
|
||||
IR: "fa",
|
||||
PK: "ur",
|
||||
BD: "bn",
|
||||
PH: "tl",
|
||||
MY: "ms",
|
||||
DE: "de", AT: "de", ES: "es", MX: "es", AR: "es", CO: "es", PE: "es", VE: "es", CL: "es", EC: "es", GT: "es", CU: "es", BO: "es", DO: "es", HN: "es", PY: "es", SV: "es", NI: "es", CR: "es", PA: "es", UY: "es",
|
||||
PT: "pt", BR: "pt", AO: "pt", MZ: "pt", IT: "it", NL: "nl", RU: "ru", BY: "ru", KZ: "ru", TR: "tr", JP: "ja", KR: "ko", CN: "zh", TW: "zh", HK: "zh", IN: "hi", TH: "th", VN: "vi", ID: "id", PL: "pl", UA: "uk", RO: "ro", GR: "el", CZ: "cs", SE: "sv", NO: "no", DK: "da", FI: "fi", HU: "hu", IL: "he", IR: "fa", PK: "ur", BD: "bn", PH: "tl", MY: "ms",
|
||||
};
|
||||
|
||||
// Detect region from IP using Cloudflare/Deno Deploy headers or fallback to IP lookup
|
||||
async function detectRegionFromIP(req: Request): Promise<{ country: string; language: string } | null> {
|
||||
try {
|
||||
// Try Cloudflare/Deno Deploy headers first (fastest)
|
||||
const cfCountry = req.headers.get("cf-ipcountry") || req.headers.get("x-country");
|
||||
if (cfCountry && cfCountry !== "XX") {
|
||||
const language = countryLanguageMap[cfCountry] || "en";
|
||||
return { country: cfCountry, language };
|
||||
return { country: cfCountry, language: countryLanguageMap[cfCountry] || "en" };
|
||||
}
|
||||
|
||||
// Get client IP
|
||||
const forwardedFor = req.headers.get("x-forwarded-for");
|
||||
const clientIP = forwardedFor ? forwardedFor.split(",")[0].trim() : null;
|
||||
|
||||
if (!clientIP || clientIP === "127.0.0.1" || clientIP.startsWith("192.168.") || clientIP.startsWith("10.")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fallback to IP geolocation API (ip-api.com is free, no key needed)
|
||||
if (!clientIP || clientIP === "127.0.0.1" || clientIP.startsWith("192.168.") || clientIP.startsWith("10.")) return null;
|
||||
const geoResponse = await fetch(`http://ip-api.com/json/${clientIP}?fields=countryCode`);
|
||||
if (geoResponse.ok) {
|
||||
const geoData = await geoResponse.json();
|
||||
if (geoData.countryCode) {
|
||||
const language = countryLanguageMap[geoData.countryCode] || "en";
|
||||
return { country: geoData.countryCode, language };
|
||||
}
|
||||
if (geoData.countryCode) return { country: geoData.countryCode, language: countryLanguageMap[geoData.countryCode] || "en" };
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
// Main request handler
|
||||
async function handler(req: Request): Promise<Response> {
|
||||
const url = new URL(req.url);
|
||||
const { pathname, searchParams } = url;
|
||||
|
||||
// Handle CORS preflight
|
||||
if (req.method === "OPTIONS") {
|
||||
return new Response(null, { headers: corsHeaders });
|
||||
}
|
||||
if (req.method === "OPTIONS") return new Response(null, { headers: corsHeaders });
|
||||
|
||||
try {
|
||||
// Root - API Documentation UI
|
||||
if (pathname === "/") {
|
||||
return new Response(uiHtml, { headers: { "Content-Type": "text/html", ...corsHeaders } });
|
||||
}
|
||||
// Root - UI
|
||||
if (pathname === "/") return new Response(uiHtml, { headers: { "Content-Type": "text/html", ...corsHeaders } });
|
||||
|
||||
// Serve logo from assets
|
||||
// Logo
|
||||
if (pathname === "/assets/logo.png" || pathname === "/assets/Logo.png") {
|
||||
try {
|
||||
const logoPath = new URL("./assets/Logo.png", import.meta.url).pathname.replace(/^\/([A-Z]:)/, "$1");
|
||||
const logo = await Deno.readFile(logoPath);
|
||||
return new Response(logo, {
|
||||
headers: { "Content-Type": "image/png", ...corsHeaders }
|
||||
});
|
||||
} catch {
|
||||
return new Response("Logo not found", { status: 404 });
|
||||
}
|
||||
return new Response(logo, { headers: { "Content-Type": "image/png", ...corsHeaders } });
|
||||
} catch { return new Response("Logo not found", { status: 404 }); }
|
||||
}
|
||||
|
||||
// Favicon
|
||||
if (pathname === "/favicon.ico") {
|
||||
return new Response(null, { status: 204 });
|
||||
}
|
||||
if (pathname === "/favicon.ico") return new Response(null, { status: 204 });
|
||||
if (pathname === "/health") return json({ status: "ok" });
|
||||
|
||||
// Health check
|
||||
if (pathname === "/health") {
|
||||
return json({ status: "ok" });
|
||||
}
|
||||
// ============ SEARCH ============
|
||||
|
||||
// ============ SEARCH ENDPOINTS ============
|
||||
|
||||
// YouTube Music Search with YouTube fallback video IDs
|
||||
if (pathname === "/api/search") {
|
||||
const query = searchParams.get("q");
|
||||
const filter = searchParams.get("filter") || undefined;
|
||||
const continuationToken = searchParams.get("continuationToken") || undefined;
|
||||
const ignoreSpelling = searchParams.get("ignore_spelling") === "true";
|
||||
const withFallback = searchParams.get("fallback") !== "0"; // Enable by default
|
||||
const withFallback = searchParams.get("fallback") !== "0";
|
||||
|
||||
// Get region from param or detect from IP
|
||||
let region = searchParams.get("region") || searchParams.get("gl") || undefined;
|
||||
let language = searchParams.get("language") || searchParams.get("hl") || undefined;
|
||||
|
||||
// Auto-detect region from IP if not provided
|
||||
if (!region) {
|
||||
const detectedRegion = await detectRegionFromIP(req);
|
||||
if (detectedRegion) {
|
||||
region = detectedRegion.country;
|
||||
if (!language) language = detectedRegion.language;
|
||||
}
|
||||
const detected = await detectRegionFromIP(req);
|
||||
if (detected) { region = detected.country; if (!language) language = detected.language; }
|
||||
}
|
||||
|
||||
if (!query && !continuationToken) {
|
||||
return error("Missing required query parameter 'q' or 'continuationToken'");
|
||||
}
|
||||
if (!query && !continuationToken) return error("Missing 'q' or 'continuationToken'");
|
||||
|
||||
const results = await ytmusic.search(query || "", filter, continuationToken, ignoreSpelling, region, language);
|
||||
|
||||
// For songs, add fallback YouTube video IDs (embeddable versions)
|
||||
// Add fallback YouTube IDs for songs
|
||||
if (withFallback && filter === "songs" && results.results?.length > 0) {
|
||||
// Get YouTube video alternatives for the top results
|
||||
const enhancedResults = await Promise.all(
|
||||
const enhanced = await Promise.all(
|
||||
results.results.slice(0, 10).map(async (song: any) => {
|
||||
try {
|
||||
// Search YouTube for official video
|
||||
const searchQuery = `${song.title} ${song.artists?.[0]?.name || ''} official`;
|
||||
const ytResults = await youtubeSearch.searchVideos(searchQuery);
|
||||
|
||||
// Find a non-Topic channel video
|
||||
const alternative = ytResults.results?.find((v: any) =>
|
||||
v.channel?.name && !v.channel.name.includes('Topic') && v.id
|
||||
);
|
||||
|
||||
if (alternative) {
|
||||
return {
|
||||
...song,
|
||||
fallbackVideoId: alternative.id,
|
||||
fallbackTitle: alternative.title,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// Ignore errors, just return original
|
||||
}
|
||||
const ytResults = await youtubeSearch.searchVideos(`${song.title} ${song.artists?.[0]?.name || ''} official`);
|
||||
const alt = ytResults.results?.find((v: any) => v.channel?.name && !v.channel.name.includes('Topic') && v.id);
|
||||
if (alt) return { ...song, fallbackVideoId: alt.id, fallbackTitle: alt.title };
|
||||
} catch {}
|
||||
return song;
|
||||
})
|
||||
);
|
||||
|
||||
// Replace first 10 results with enhanced ones, keep the rest
|
||||
results.results = [
|
||||
...enhancedResults,
|
||||
...results.results.slice(10)
|
||||
];
|
||||
results.results = [...enhanced, ...results.results.slice(10)];
|
||||
}
|
||||
|
||||
return json({ query, filter, region, language, ...results });
|
||||
}
|
||||
|
||||
// Search suggestions
|
||||
if (pathname === "/api/search/suggestions") {
|
||||
const query = searchParams.get("q");
|
||||
if (!query) return error("Missing 'q'");
|
||||
const music = searchParams.get("music");
|
||||
|
||||
if (!query) return error("Missing required query parameter 'q'");
|
||||
|
||||
if (music === "1") {
|
||||
const suggestions = await ytmusic.getSearchSuggestions(query);
|
||||
return json({ suggestions, source: "youtube_music" });
|
||||
} else {
|
||||
const suggestions = await youtubeSearch.getSuggestions(query);
|
||||
return json({ suggestions, source: "youtube" });
|
||||
}
|
||||
const suggestions = music === "1" ? await ytmusic.getSearchSuggestions(query) : await youtubeSearch.getSuggestions(query);
|
||||
return json({ suggestions, source: music === "1" ? "youtube_music" : "youtube" });
|
||||
}
|
||||
|
||||
// YouTube Search
|
||||
if (pathname === "/api/yt_search") {
|
||||
const query = searchParams.get("q");
|
||||
const filter = searchParams.get("filter") || "all";
|
||||
const continuationToken = searchParams.get("continuationToken") || undefined;
|
||||
|
||||
if (!query && !continuationToken) {
|
||||
return error("Missing required query parameter 'q' or 'continuationToken'");
|
||||
}
|
||||
if (!query && !continuationToken) return error("Missing 'q' or 'continuationToken'");
|
||||
|
||||
const results: unknown[] = [];
|
||||
let nextToken: string | null = null;
|
||||
|
||||
if (continuationToken) {
|
||||
if (filter === "videos") {
|
||||
const r = await youtubeSearch.searchVideos(null, continuationToken);
|
||||
results.push(...r.results);
|
||||
nextToken = r.continuationToken;
|
||||
} else if (filter === "channels") {
|
||||
const r = await youtubeSearch.searchChannels(null, continuationToken);
|
||||
results.push(...r.results);
|
||||
nextToken = r.continuationToken;
|
||||
} else if (filter === "playlists") {
|
||||
const r = await youtubeSearch.searchPlaylists(null, continuationToken);
|
||||
results.push(...r.results);
|
||||
nextToken = r.continuationToken;
|
||||
}
|
||||
if (filter === "videos") { const r = await youtubeSearch.searchVideos(null, continuationToken); results.push(...r.results); nextToken = r.continuationToken; }
|
||||
else if (filter === "channels") { const r = await youtubeSearch.searchChannels(null, continuationToken); results.push(...r.results); nextToken = r.continuationToken; }
|
||||
else if (filter === "playlists") { const r = await youtubeSearch.searchPlaylists(null, continuationToken); results.push(...r.results); nextToken = r.continuationToken; }
|
||||
} else if (query) {
|
||||
if (filter === "videos" || filter === "all") {
|
||||
const r = await youtubeSearch.searchVideos(query);
|
||||
results.push(...r.results);
|
||||
nextToken = r.continuationToken;
|
||||
}
|
||||
if (filter === "channels" || filter === "all") {
|
||||
const r = await youtubeSearch.searchChannels(query);
|
||||
results.push(...r.results);
|
||||
if (!nextToken) nextToken = r.continuationToken;
|
||||
}
|
||||
if (filter === "playlists" || filter === "all") {
|
||||
const r = await youtubeSearch.searchPlaylists(query);
|
||||
results.push(...r.results);
|
||||
if (!nextToken) nextToken = r.continuationToken;
|
||||
}
|
||||
if (filter === "videos" || filter === "all") { const r = await youtubeSearch.searchVideos(query); results.push(...r.results); nextToken = r.continuationToken; }
|
||||
if (filter === "channels" || filter === "all") { const r = await youtubeSearch.searchChannels(query); results.push(...r.results); if (!nextToken) nextToken = r.continuationToken; }
|
||||
if (filter === "playlists" || filter === "all") { const r = await youtubeSearch.searchPlaylists(query); results.push(...r.results); if (!nextToken) nextToken = r.continuationToken; }
|
||||
}
|
||||
|
||||
return json({ filter, query, results, continuationToken: nextToken });
|
||||
}
|
||||
|
||||
// ============ ENTITY ENDPOINTS ============
|
||||
// ============ ENTITIES (Complete data with links) ============
|
||||
|
||||
// Get song details
|
||||
let params = matchRoute(pathname, "/api/songs/:videoId");
|
||||
if (params) {
|
||||
const data = await ytmusic.getSong(params.videoId);
|
||||
return json(data);
|
||||
}
|
||||
if (params) return json(await getSongComplete(params.videoId, ytmusic));
|
||||
|
||||
// Get album details
|
||||
params = matchRoute(pathname, "/api/albums/:browseId");
|
||||
if (params) {
|
||||
const data = await ytmusic.getAlbum(params.browseId);
|
||||
return json(data);
|
||||
}
|
||||
if (params) return json(await getAlbumComplete(params.browseId, ytmusic));
|
||||
|
||||
params = matchRoute(pathname, "/api/album/:id");
|
||||
if (params) {
|
||||
const data = await ytmusic.getAlbum(params.id);
|
||||
return json(data);
|
||||
}
|
||||
if (params) return json(await getAlbumComplete(params.id, ytmusic));
|
||||
|
||||
// Get artist details (skip if it's /api/artist/info)
|
||||
params = matchRoute(pathname, "/api/artists/:browseId");
|
||||
if (params) {
|
||||
const data = await ytmusic.getArtist(params.browseId);
|
||||
return json(data);
|
||||
}
|
||||
if (params) return json(await getArtistComplete(params.browseId, ytmusic));
|
||||
|
||||
// Skip /api/artist/info - handled later by Last.fm endpoint
|
||||
if (pathname !== "/api/artist/info") {
|
||||
params = matchRoute(pathname, "/api/artist/:artistId");
|
||||
if (params) {
|
||||
const country = searchParams.get("country") || "US";
|
||||
const data = await ytmusic.getArtistSummary(params.artistId, country);
|
||||
return json(data);
|
||||
return json(await ytmusic.getArtistSummary(params.artistId, country));
|
||||
}
|
||||
}
|
||||
|
||||
// Get playlist details
|
||||
params = matchRoute(pathname, "/api/playlists/:playlistId");
|
||||
if (params) {
|
||||
const data = await ytmusic.getPlaylist(params.playlistId);
|
||||
return json(data);
|
||||
}
|
||||
if (params) return json(await ytmusic.getPlaylist(params.playlistId));
|
||||
|
||||
params = matchRoute(pathname, "/api/playlist/:id");
|
||||
if (params) {
|
||||
const data = await ytmusic.getPlaylist(params.id);
|
||||
return json(data);
|
||||
}
|
||||
if (params) return json(await ytmusic.getPlaylist(params.id));
|
||||
|
||||
// Get related videos
|
||||
params = matchRoute(pathname, "/api/related/:id");
|
||||
if (params) {
|
||||
const data = await ytmusic.getRelated(params.id);
|
||||
return json({ success: true, data });
|
||||
}
|
||||
if (params) return json({ success: true, data: await ytmusic.getRelated(params.id) });
|
||||
|
||||
// ============ EXPLORE ENDPOINTS ============
|
||||
// Full chain: song -> artist -> albums
|
||||
params = matchRoute(pathname, "/api/chain/:videoId");
|
||||
if (params) return json(await getFullChain(params.videoId, ytmusic));
|
||||
|
||||
// Charts
|
||||
if (pathname === "/api/charts") {
|
||||
const country = searchParams.get("country") || undefined;
|
||||
const data = await ytmusic.getCharts(country);
|
||||
return json(data);
|
||||
}
|
||||
// ============ EXPLORE ============
|
||||
|
||||
// Moods
|
||||
if (pathname === "/api/moods") {
|
||||
const data = await ytmusic.getMoodCategories();
|
||||
return json(data);
|
||||
}
|
||||
if (pathname === "/api/charts") return json(await ytmusic.getCharts(searchParams.get("country") || undefined));
|
||||
|
||||
if (pathname === "/api/moods") return json(await ytmusic.getMoodCategories());
|
||||
|
||||
params = matchRoute(pathname, "/api/moods/:categoryId");
|
||||
if (params) {
|
||||
const data = await ytmusic.getMoodPlaylists(params.categoryId);
|
||||
return json(data);
|
||||
}
|
||||
if (params) return json(await ytmusic.getMoodPlaylists(params.categoryId));
|
||||
|
||||
// Watch playlist
|
||||
if (pathname === "/api/watch_playlist") {
|
||||
const videoId = searchParams.get("videoId") || undefined;
|
||||
const playlistId = searchParams.get("playlistId") || undefined;
|
||||
const radio = searchParams.get("radio") === "true";
|
||||
const shuffle = searchParams.get("shuffle") === "true";
|
||||
const limit = parseInt(searchParams.get("limit") || "25");
|
||||
|
||||
if (!videoId && !playlistId) {
|
||||
return error("Provide either videoId or playlistId");
|
||||
}
|
||||
|
||||
const data = await ytmusic.getWatchPlaylist(videoId, playlistId, radio, shuffle, limit);
|
||||
return json(data);
|
||||
if (!videoId && !playlistId) return error("Provide videoId or playlistId");
|
||||
return json(await ytmusic.getWatchPlaylist(videoId, playlistId, searchParams.get("radio") === "true", searchParams.get("shuffle") === "true", parseInt(searchParams.get("limit") || "25")));
|
||||
}
|
||||
|
||||
// ============ STREAMING ENDPOINTS ============
|
||||
// ============ STREAMING ============
|
||||
|
||||
// Find song
|
||||
if (pathname === "/api/music/find") {
|
||||
const name = searchParams.get("name");
|
||||
const artist = searchParams.get("artist");
|
||||
const name = searchParams.get("name"), artist = searchParams.get("artist");
|
||||
if (!name || !artist) return error("Missing name and artist");
|
||||
|
||||
if (!name || !artist) {
|
||||
return error("Missing required parameters: name and artist are required");
|
||||
}
|
||||
|
||||
const query = `${name} ${artist}`;
|
||||
const searchResults = await ytmusic.search(query, "songs");
|
||||
|
||||
if (!searchResults.results?.length) {
|
||||
return json({ success: false, error: "Song not found" }, 404);
|
||||
}
|
||||
const searchResults = await ytmusic.search(`${name} ${artist}`, "songs");
|
||||
if (!searchResults.results?.length) return json({ success: false, error: "Song not found" }, 404);
|
||||
|
||||
const normalize = (s: string) => s.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/gi, "").toLowerCase();
|
||||
const nName = normalize(name);
|
||||
const artistsList = artist.split(",").map(a => normalize(a));
|
||||
|
||||
const bestMatch = searchResults.results.find((song: any) => {
|
||||
const match = searchResults.results.find((song: any) => {
|
||||
const nSongName = normalize(song.title || "");
|
||||
const songArtists = (song.artists || []).map((a: any) => normalize(a.name || ""));
|
||||
const titleMatch = nSongName.includes(nName) || nName.includes(nSongName);
|
||||
const artistMatch = artistsList.some(a => songArtists.some((sa: string) => sa.includes(a) || a.includes(sa)));
|
||||
return titleMatch && artistMatch;
|
||||
return (nSongName.includes(nName) || nName.includes(nSongName)) && artistsList.some(a => songArtists.some((sa: string) => sa.includes(a) || a.includes(sa)));
|
||||
});
|
||||
|
||||
if (bestMatch) {
|
||||
return json({ success: true, data: bestMatch });
|
||||
}
|
||||
return json({ success: false, error: "Song not found after filtering" }, 404);
|
||||
return match ? json({ success: true, data: match }) : json({ success: false, error: "Song not found" }, 404);
|
||||
}
|
||||
|
||||
// Stream endpoint - multi-source
|
||||
if (pathname === "/api/stream") {
|
||||
const id = searchParams.get("id");
|
||||
if (!id) return error("Missing id");
|
||||
|
||||
if (!id) {
|
||||
return error("Missing required parameter: id");
|
||||
}
|
||||
const piped = await fetchFromPiped(id);
|
||||
if (piped.success) return json({ success: true, service: "piped", instance: piped.instance, streamingUrls: piped.streamingUrls, metadata: piped.metadata, requestedId: id, timestamp: new Date().toISOString() });
|
||||
|
||||
// Try Piped first
|
||||
const pipedResult = await fetchFromPiped(id);
|
||||
if (pipedResult.success) {
|
||||
return json({
|
||||
success: true,
|
||||
service: "piped",
|
||||
instance: pipedResult.instance,
|
||||
streamingUrls: pipedResult.streamingUrls,
|
||||
metadata: pipedResult.metadata,
|
||||
requestedId: id,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
const invidious = await fetchFromInvidious(id);
|
||||
if (invidious.success) return json({ success: true, service: "invidious", instance: invidious.instance, streamingUrls: invidious.streamingUrls, metadata: invidious.metadata, requestedId: id, timestamp: new Date().toISOString() });
|
||||
|
||||
// Try Invidious
|
||||
const invidiousResult = await fetchFromInvidious(id);
|
||||
if (invidiousResult.success) {
|
||||
return json({
|
||||
success: true,
|
||||
service: "invidious",
|
||||
instance: invidiousResult.instance,
|
||||
streamingUrls: invidiousResult.streamingUrls,
|
||||
metadata: invidiousResult.metadata,
|
||||
requestedId: id,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
|
||||
return json({ success: false, error: "No streaming data found from any source" }, 404);
|
||||
return json({ success: false, error: "No streaming data found" }, 404);
|
||||
}
|
||||
|
||||
// ============ SIMILAR TRACKS ============
|
||||
|
||||
if (pathname === "/api/similar") {
|
||||
const title = searchParams.get("title");
|
||||
const artist = searchParams.get("artist");
|
||||
const limit = searchParams.get("limit") || "5";
|
||||
|
||||
if (!title || !artist) {
|
||||
return error("Missing title or artist parameter");
|
||||
}
|
||||
|
||||
const similarTracks = await LastFM.getSimilarTracks(title, artist, limit);
|
||||
if ("error" in similarTracks) {
|
||||
return json({ error: similarTracks.error }, 500);
|
||||
}
|
||||
|
||||
const ytResults = await Promise.all(
|
||||
similarTracks.map(async (t: any) => {
|
||||
const r = await youtubeSearch.searchVideos(`${t.title} ${t.artist}`);
|
||||
return r.results[0] || null;
|
||||
})
|
||||
);
|
||||
|
||||
return json(ytResults.filter(Boolean));
|
||||
}
|
||||
|
||||
// ============ FEED ENDPOINTS ============
|
||||
|
||||
// Audio proxy to bypass CORS
|
||||
if (pathname === "/api/proxy") {
|
||||
const audioUrl = searchParams.get("url");
|
||||
if (!audioUrl) {
|
||||
return error("Missing url parameter");
|
||||
}
|
||||
if (!audioUrl) return error("Missing url");
|
||||
return proxyAudio(audioUrl, req);
|
||||
}
|
||||
|
||||
// ============ LYRICS & INFO ============
|
||||
|
||||
if (pathname === "/api/lyrics") {
|
||||
const title = searchParams.get("title"), artist = searchParams.get("artist");
|
||||
if (!title || !artist) return error("Missing title and artist");
|
||||
return json(await getLyrics(title, artist, searchParams.get("duration") ? parseInt(searchParams.get("duration")!) : undefined));
|
||||
}
|
||||
|
||||
if (pathname === "/api/similar") {
|
||||
const title = searchParams.get("title"), artist = searchParams.get("artist");
|
||||
if (!title || !artist) return error("Missing title or artist");
|
||||
const similar = await LastFM.getSimilarTracks(title, artist, searchParams.get("limit") || "5");
|
||||
if ("error" in similar) return json({ error: similar.error }, 500);
|
||||
const ytResults = await Promise.all(similar.map(async (t: any) => { const r = await youtubeSearch.searchVideos(`${t.title} ${t.artist}`); return r.results[0] || null; }));
|
||||
return json(ytResults.filter(Boolean));
|
||||
}
|
||||
|
||||
if (pathname === "/api/trending") return json(await getTrendingMusic(searchParams.get("country") || "United States", ytmusic));
|
||||
|
||||
if (pathname === "/api/radio") {
|
||||
const videoId = searchParams.get("videoId");
|
||||
if (!videoId) return error("Missing videoId");
|
||||
return json(await getRadio(videoId, ytmusic));
|
||||
}
|
||||
|
||||
if (pathname === "/api/top/artists") return json(await getTopArtists(searchParams.get("country") || undefined, parseInt(searchParams.get("limit") || "20"), ytmusic));
|
||||
if (pathname === "/api/top/tracks") return json(await getTopTracks(searchParams.get("country") || undefined, parseInt(searchParams.get("limit") || "20"), ytmusic));
|
||||
|
||||
if (pathname === "/api/artist/info") {
|
||||
const artist = searchParams.get("artist");
|
||||
if (!artist) return error("Missing artist");
|
||||
return json(await getArtistInfo(artist));
|
||||
}
|
||||
|
||||
if (pathname === "/api/track/info") {
|
||||
const title = searchParams.get("title"), artist = searchParams.get("artist");
|
||||
if (!title || !artist) return error("Missing title and artist");
|
||||
return json(await getTrackInfo(title, artist));
|
||||
}
|
||||
|
||||
// ============ FEED ============
|
||||
|
||||
if (pathname === "/api/feed/unauthenticated" || pathname.startsWith("/api/feed/channels=")) {
|
||||
let channelsParam = searchParams.get("channels");
|
||||
|
||||
if (pathname.startsWith("/api/feed/channels=")) {
|
||||
channelsParam = pathname.replace("/api/feed/channels=", "").split("?")[0];
|
||||
}
|
||||
|
||||
if (!channelsParam) {
|
||||
return error("No valid channel IDs provided");
|
||||
}
|
||||
if (pathname.startsWith("/api/feed/channels=")) channelsParam = pathname.replace("/api/feed/channels=", "").split("?")[0];
|
||||
if (!channelsParam) return error("No channel IDs provided");
|
||||
|
||||
const channelIds = channelsParam.split(",").map(s => s.trim()).filter(Boolean);
|
||||
const preview = searchParams.get("preview") === "1";
|
||||
|
||||
const results: any[] = [];
|
||||
for (const channelId of channelIds) {
|
||||
const items = await fetchChannelVideos(channelId, preview ? 5 : undefined);
|
||||
results.push(...items);
|
||||
}
|
||||
|
||||
// Filter shorts and sort by upload date
|
||||
const filtered = results
|
||||
.filter(item => !item.isShort)
|
||||
.sort((a, b) => Number(b.uploaded) - Number(a.uploaded));
|
||||
|
||||
return json(filtered);
|
||||
for (const channelId of channelIds) results.push(...await fetchChannelVideos(channelId, preview ? 5 : undefined));
|
||||
return json(results.filter(item => !item.isShort).sort((a, b) => Number(b.uploaded) - Number(a.uploaded)));
|
||||
}
|
||||
|
||||
// ============ NEW FEATURES ============
|
||||
|
||||
// Lyrics
|
||||
if (pathname === "/api/lyrics") {
|
||||
const title = searchParams.get("title");
|
||||
const artist = searchParams.get("artist");
|
||||
const duration = searchParams.get("duration");
|
||||
|
||||
if (!title || !artist) {
|
||||
return error("Missing required parameters: title and artist");
|
||||
}
|
||||
|
||||
const result = await getLyrics(title, artist, duration ? parseInt(duration) : undefined);
|
||||
return json(result);
|
||||
}
|
||||
|
||||
// Trending Music
|
||||
if (pathname === "/api/trending") {
|
||||
const country = searchParams.get("country") || "United States";
|
||||
const result = await getTrendingMusic(country, ytmusic);
|
||||
return json(result);
|
||||
}
|
||||
|
||||
// Radio (infinite mix based on a song)
|
||||
if (pathname === "/api/radio") {
|
||||
const videoId = searchParams.get("videoId");
|
||||
if (!videoId) {
|
||||
return error("Missing required parameter: videoId");
|
||||
}
|
||||
const result = await getRadio(videoId, ytmusic);
|
||||
return json(result);
|
||||
}
|
||||
|
||||
// Top Artists (by country using YouTube Music search)
|
||||
if (pathname === "/api/top/artists") {
|
||||
const country = searchParams.get("country") || undefined;
|
||||
const limit = parseInt(searchParams.get("limit") || "20");
|
||||
const result = await getTopArtists(country, limit, ytmusic);
|
||||
return json(result);
|
||||
}
|
||||
|
||||
// Top Tracks (by country using YouTube Music search)
|
||||
if (pathname === "/api/top/tracks") {
|
||||
const country = searchParams.get("country") || undefined;
|
||||
const limit = parseInt(searchParams.get("limit") || "20");
|
||||
const result = await getTopTracks(country, limit, ytmusic);
|
||||
return json(result);
|
||||
}
|
||||
|
||||
// Artist Info (detailed from Last.fm)
|
||||
if (pathname === "/api/artist/info") {
|
||||
const artist = searchParams.get("artist");
|
||||
if (!artist) {
|
||||
return error("Missing required parameter: artist");
|
||||
}
|
||||
const result = await getArtistInfo(artist);
|
||||
return json(result);
|
||||
}
|
||||
|
||||
// Track Info (detailed from Last.fm)
|
||||
if (pathname === "/api/track/info") {
|
||||
const title = searchParams.get("title");
|
||||
const artist = searchParams.get("artist");
|
||||
if (!title || !artist) {
|
||||
return error("Missing required parameters: title and artist");
|
||||
}
|
||||
const result = await getTrackInfo(title, artist);
|
||||
return json(result);
|
||||
}
|
||||
|
||||
// ============ UNIFIED ENTITY ENDPOINTS ============
|
||||
|
||||
// Get complete song with artist/album links
|
||||
params = matchRoute(pathname, "/api/v2/songs/:videoId");
|
||||
if (params) {
|
||||
const data = await getSongComplete(params.videoId, ytmusic);
|
||||
return json(data);
|
||||
}
|
||||
|
||||
// Get complete album with artist link and tracks
|
||||
params = matchRoute(pathname, "/api/v2/albums/:browseId");
|
||||
if (params) {
|
||||
const data = await getAlbumComplete(params.browseId, ytmusic);
|
||||
return json(data);
|
||||
}
|
||||
|
||||
// Get complete artist with discography
|
||||
params = matchRoute(pathname, "/api/v2/artists/:browseId");
|
||||
if (params) {
|
||||
const data = await getArtistComplete(params.browseId, ytmusic);
|
||||
return json(data);
|
||||
}
|
||||
|
||||
// Get full chain: song -> artist -> albums (navigation helper)
|
||||
params = matchRoute(pathname, "/api/v2/chain/:videoId");
|
||||
if (params) {
|
||||
const data = await getFullChain(params.videoId, ytmusic);
|
||||
return json(data);
|
||||
}
|
||||
|
||||
// 404
|
||||
return json({ error: "Route not found", path: pathname }, 404);
|
||||
|
||||
} catch (err) {
|
||||
@@ -639,32 +318,17 @@ async function handler(req: Request): Promise<Response> {
|
||||
}
|
||||
}
|
||||
|
||||
// Audio proxy endpoint to bypass CORS with range request support
|
||||
async function proxyAudio(url: string, req: Request): Promise<Response> {
|
||||
try {
|
||||
const headers: Record<string, string> = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||
"Accept": "*/*",
|
||||
"Accept-Language": "en-US,en;q=0.9",
|
||||
"Referer": "https://www.youtube.com/",
|
||||
"Origin": "https://www.youtube.com",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
||||
"Accept": "*/*", "Referer": "https://www.youtube.com/", "Origin": "https://www.youtube.com",
|
||||
};
|
||||
|
||||
// Forward range header for seeking support
|
||||
const rangeHeader = req.headers.get("Range");
|
||||
if (rangeHeader) {
|
||||
headers["Range"] = rangeHeader;
|
||||
}
|
||||
if (rangeHeader) headers["Range"] = rangeHeader;
|
||||
|
||||
const response = await fetch(url, { headers });
|
||||
|
||||
if (!response.ok && response.status !== 206) {
|
||||
console.error(`[Proxy] Upstream error: ${response.status} ${response.statusText}`);
|
||||
return new Response(`Failed to fetch audio: ${response.status}`, {
|
||||
status: 502,
|
||||
headers: corsHeaders
|
||||
});
|
||||
}
|
||||
if (!response.ok && response.status !== 206) return new Response(`Failed: ${response.status}`, { status: 502, headers: corsHeaders });
|
||||
|
||||
const responseHeaders = new Headers();
|
||||
responseHeaders.set("Access-Control-Allow-Origin", "*");
|
||||
@@ -672,139 +336,59 @@ async function proxyAudio(url: string, req: Request): Promise<Response> {
|
||||
responseHeaders.set("Access-Control-Allow-Headers", "Range, Content-Type");
|
||||
responseHeaders.set("Access-Control-Expose-Headers", "Content-Length, Content-Range, Accept-Ranges");
|
||||
responseHeaders.set("Cache-Control", "public, max-age=3600");
|
||||
responseHeaders.set("Content-Type", response.headers.get("Content-Type") || "audio/mp4");
|
||||
if (response.headers.get("Content-Length")) responseHeaders.set("Content-Length", response.headers.get("Content-Length")!);
|
||||
if (response.headers.get("Content-Range")) responseHeaders.set("Content-Range", response.headers.get("Content-Range")!);
|
||||
responseHeaders.set("Accept-Ranges", response.headers.get("Accept-Ranges") || "bytes");
|
||||
|
||||
// Copy important headers from upstream
|
||||
const contentType = response.headers.get("Content-Type");
|
||||
if (contentType) {
|
||||
responseHeaders.set("Content-Type", contentType);
|
||||
} else {
|
||||
responseHeaders.set("Content-Type", "audio/mp4");
|
||||
}
|
||||
|
||||
const contentLength = response.headers.get("Content-Length");
|
||||
if (contentLength) {
|
||||
responseHeaders.set("Content-Length", contentLength);
|
||||
}
|
||||
|
||||
const contentRange = response.headers.get("Content-Range");
|
||||
if (contentRange) {
|
||||
responseHeaders.set("Content-Range", contentRange);
|
||||
}
|
||||
|
||||
const acceptRanges = response.headers.get("Accept-Ranges");
|
||||
if (acceptRanges) {
|
||||
responseHeaders.set("Accept-Ranges", acceptRanges);
|
||||
} else {
|
||||
responseHeaders.set("Accept-Ranges", "bytes");
|
||||
}
|
||||
|
||||
return new Response(response.body, {
|
||||
status: response.status,
|
||||
headers: responseHeaders
|
||||
});
|
||||
return new Response(response.body, { status: response.status, headers: responseHeaders });
|
||||
} catch (err) {
|
||||
console.error("[Proxy] Error:", err);
|
||||
return new Response("Proxy error: " + String(err), {
|
||||
status: 502,
|
||||
headers: corsHeaders
|
||||
});
|
||||
return new Response("Proxy error: " + String(err), { status: 502, headers: corsHeaders });
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch channel videos using YouTube Browse API
|
||||
async function fetchChannelVideos(channelId: string, limit?: number): Promise<any[]> {
|
||||
try {
|
||||
const url = "https://www.youtube.com/youtubei/v1/browse?prettyPrint=false";
|
||||
const payload = {
|
||||
browseId: channelId,
|
||||
context: {
|
||||
client: {
|
||||
clientName: "WEB",
|
||||
clientVersion: "2.20251013.01.00",
|
||||
hl: "en",
|
||||
gl: "US",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const response = await fetch(url, {
|
||||
const response = await fetch("https://www.youtube.com/youtubei/v1/browse?prettyPrint=false", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
body: JSON.stringify({ browseId: channelId, context: { client: { clientName: "WEB", clientVersion: "2.20251013.01.00", hl: "en", gl: "US" } } }),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
const items: any[] = [];
|
||||
const channelName = data?.header?.c4TabbedHeaderRenderer?.title || data?.metadata?.channelMetadataRenderer?.title || "";
|
||||
|
||||
// Extract channel name
|
||||
let channelName = data?.header?.c4TabbedHeaderRenderer?.title ||
|
||||
data?.metadata?.channelMetadataRenderer?.title || "";
|
||||
|
||||
// Extract videos from response
|
||||
const extractVideos = (contents: any[]) => {
|
||||
if (!contents) return;
|
||||
for (const item of contents) {
|
||||
const video = item?.richItemRenderer?.content?.videoRenderer ||
|
||||
item?.videoRenderer ||
|
||||
item?.gridVideoRenderer;
|
||||
if (video?.videoId) {
|
||||
items.push(parseVideo(video, channelId, channelName));
|
||||
}
|
||||
// Handle nested content
|
||||
if (item?.shelfRenderer?.content?.expandedShelfContentsRenderer?.items) {
|
||||
extractVideos(item.shelfRenderer.content.expandedShelfContentsRenderer.items);
|
||||
}
|
||||
if (item?.itemSectionRenderer?.contents) {
|
||||
extractVideos(item.itemSectionRenderer.contents);
|
||||
}
|
||||
const video = item?.richItemRenderer?.content?.videoRenderer || item?.videoRenderer || item?.gridVideoRenderer;
|
||||
if (video?.videoId) items.push(parseVideo(video, channelId, channelName));
|
||||
if (item?.shelfRenderer?.content?.expandedShelfContentsRenderer?.items) extractVideos(item.shelfRenderer.content.expandedShelfContentsRenderer.items);
|
||||
if (item?.itemSectionRenderer?.contents) extractVideos(item.itemSectionRenderer.contents);
|
||||
if (limit && items.length >= limit) return;
|
||||
}
|
||||
};
|
||||
|
||||
// Try different response structures
|
||||
const tabs = data?.contents?.twoColumnBrowseResultsRenderer?.tabs ||
|
||||
data?.contents?.singleColumnBrowseResultsRenderer?.tabs || [];
|
||||
|
||||
for (const tab of tabs) {
|
||||
const contents = tab?.tabRenderer?.content?.sectionListRenderer?.contents ||
|
||||
tab?.tabRenderer?.content?.richGridRenderer?.contents || [];
|
||||
extractVideos(contents);
|
||||
}
|
||||
|
||||
const tabs = data?.contents?.twoColumnBrowseResultsRenderer?.tabs || data?.contents?.singleColumnBrowseResultsRenderer?.tabs || [];
|
||||
for (const tab of tabs) extractVideos(tab?.tabRenderer?.content?.sectionListRenderer?.contents || tab?.tabRenderer?.content?.richGridRenderer?.contents || []);
|
||||
return items.slice(0, limit || items.length);
|
||||
} catch (err) {
|
||||
console.error("Channel fetch error:", err);
|
||||
return [];
|
||||
}
|
||||
} catch { return []; }
|
||||
}
|
||||
|
||||
function parseVideo(video: any, channelId: string, channelName: string): any {
|
||||
const id = video?.videoId || "";
|
||||
const title = video?.title?.runs?.[0]?.text || video?.title?.simpleText || "";
|
||||
|
||||
// Parse duration
|
||||
let duration = 0;
|
||||
const durationText = video?.lengthText?.simpleText ||
|
||||
video?.thumbnailOverlays?.[0]?.thumbnailOverlayTimeStatusRenderer?.text?.simpleText || "";
|
||||
const durationText = video?.lengthText?.simpleText || video?.thumbnailOverlays?.[0]?.thumbnailOverlayTimeStatusRenderer?.text?.simpleText || "";
|
||||
if (durationText) {
|
||||
const parts = durationText.split(":").map((p: string) => parseInt(p) || 0);
|
||||
if (parts.length === 2) duration = parts[0] * 60 + parts[1];
|
||||
else if (parts.length === 3) duration = parts[0] * 3600 + parts[1] * 60 + parts[2];
|
||||
}
|
||||
|
||||
// Parse views
|
||||
let views = 0;
|
||||
const viewText = video?.viewCountText?.simpleText || "";
|
||||
const match = viewText.match(/([\d,\.]+)([KMB]?)/);
|
||||
if (match) {
|
||||
let num = parseFloat(match[1].replace(/,/g, ""));
|
||||
if (match[2] === "K") num *= 1000;
|
||||
else if (match[2] === "M") num *= 1000000;
|
||||
else if (match[2] === "B") num *= 1000000000;
|
||||
views = Math.floor(num);
|
||||
}
|
||||
|
||||
// Parse published time
|
||||
if (match) { let num = parseFloat(match[1].replace(/,/g, "")); if (match[2] === "K") num *= 1000; else if (match[2] === "M") num *= 1000000; else if (match[2] === "B") num *= 1000000000; views = Math.floor(num); }
|
||||
let uploaded = Date.now();
|
||||
const timeText = (video?.publishedTimeText?.simpleText || "").toLowerCase();
|
||||
if (timeText.includes("hour")) uploaded -= parseInt(timeText.match(/(\d+)/)?.[1] || "1") * 3600000;
|
||||
@@ -812,24 +396,8 @@ function parseVideo(video: any, channelId: string, channelName: string): any {
|
||||
else if (timeText.includes("week")) uploaded -= parseInt(timeText.match(/(\d+)/)?.[1] || "1") * 604800000;
|
||||
else if (timeText.includes("month")) uploaded -= parseInt(timeText.match(/(\d+)/)?.[1] || "1") * 2592000000;
|
||||
else if (timeText.includes("year")) uploaded -= parseInt(timeText.match(/(\d+)/)?.[1] || "1") * 31536000000;
|
||||
|
||||
const isShort = duration > 0 && duration <= 60;
|
||||
|
||||
return {
|
||||
id,
|
||||
authorId: channelId,
|
||||
duration: duration.toString(),
|
||||
author: channelName,
|
||||
views: views.toString(),
|
||||
uploaded: uploaded.toString(),
|
||||
title,
|
||||
isShort,
|
||||
thumbnail: video?.thumbnail?.thumbnails?.slice(-1)[0]?.url || "",
|
||||
};
|
||||
return { id, authorId: channelId, duration: duration.toString(), author: channelName, views: views.toString(), uploaded: uploaded.toString(), title, isShort: duration > 0 && duration <= 60, thumbnail: video?.thumbnail?.thumbnails?.slice(-1)[0]?.url || "" };
|
||||
}
|
||||
|
||||
// Start server
|
||||
console.log(`Virome API running on http://localhost:${PORT}`);
|
||||
console.log(`Endpoints: /api/search, /api/stream, /api/charts, etc.`);
|
||||
|
||||
serve(handler, { port: PORT });
|
||||
|
||||
162
ui.ts
162
ui.ts
@@ -14,45 +14,27 @@ export const html = `<!DOCTYPE html>
|
||||
*{margin:0;padding:0;box-sizing:border-box}
|
||||
:root{--accent:#10b981;--accent-dim:rgba(16,185,129,.15);--bg:#0a0a0a;--surface:#111;--surface2:#1a1a1a;--border:#222;--text:#fff;--muted:#888;--dim:#555}
|
||||
body{font-family:'Inter',system-ui,sans-serif;min-height:100vh;color:var(--text);background:var(--bg)}
|
||||
|
||||
/* Subtle gradient background */
|
||||
.bg{position:fixed;inset:0;z-index:-1;background:radial-gradient(ellipse 80% 50% at 50% -20%,rgba(16,185,129,.08),transparent)}
|
||||
|
||||
.container{max-width:900px;margin:0 auto;padding:60px 24px 180px}
|
||||
|
||||
/* Hero */
|
||||
.hero{text-align:center;margin-bottom:80px}
|
||||
.logo{width:160px;height:160px;margin-bottom:32px;filter:drop-shadow(0 20px 50px rgba(16,185,129,.4));animation:float 6s ease-in-out infinite}
|
||||
@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-10px)}}
|
||||
.title{font-size:3rem;font-weight:700;margin-bottom:12px;letter-spacing:-1px}
|
||||
.subtitle{color:var(--muted);font-size:1.1rem;font-weight:400}
|
||||
|
||||
/* Navigation */
|
||||
.nav{display:flex;justify-content:center;gap:8px;margin-bottom:48px}
|
||||
.nav-btn{padding:12px 28px;background:transparent;border:1px solid var(--border);color:var(--muted);font-size:.9rem;font-weight:500;cursor:pointer;border-radius:10px;transition:all .3s cubic-bezier(.4,0,.2,1);font-family:inherit;position:relative;overflow:hidden}
|
||||
.nav-btn::before{content:'';position:absolute;inset:0;background:var(--accent);opacity:0;transition:opacity .3s}
|
||||
.nav-btn{padding:12px 28px;background:transparent;border:1px solid var(--border);color:var(--muted);font-size:.9rem;font-weight:500;cursor:pointer;border-radius:10px;transition:all .3s;font-family:inherit}
|
||||
.nav-btn:hover{color:var(--text);border-color:#444;transform:translateY(-2px)}
|
||||
.nav-btn.active{color:var(--accent);border-color:var(--accent);background:var(--accent-dim);transform:translateY(-2px)}
|
||||
|
||||
/* Tabs with transitions */
|
||||
.tab{display:none;opacity:0;transform:translateY(20px);transition:opacity .4s ease,transform .4s ease}
|
||||
.tab{display:none;opacity:0;transform:translateY(20px);transition:opacity .4s,transform .4s}
|
||||
.tab.active{display:block;opacity:1;transform:translateY(0)}
|
||||
.tab.fade-out{opacity:0;transform:translateY(-20px)}
|
||||
.tab.fade-in{display:block}
|
||||
|
||||
/* Section */
|
||||
.section{margin-bottom:40px}
|
||||
.section-title{font-size:.7rem;text-transform:uppercase;letter-spacing:1.5px;color:var(--accent);margin-bottom:16px;font-weight:600}
|
||||
|
||||
/* API Cards */
|
||||
.api-list{display:flex;flex-direction:column;gap:8px}
|
||||
.api-item{display:flex;align-items:center;gap:16px;padding:16px 20px;background:var(--surface);border:1px solid var(--border);border-radius:12px;transition:all .15s;cursor:pointer}
|
||||
.api-item:hover{border-color:#333;transform:translateX(4px)}
|
||||
.method{font-size:.65rem;font-weight:700;padding:5px 10px;border-radius:6px;background:var(--accent-dim);color:var(--accent);min-width:42px;text-align:center}
|
||||
.path{font-family:'SF Mono',Monaco,monospace;font-size:.85rem;flex:1}
|
||||
.desc{font-size:.75rem;color:var(--dim);max-width:280px;text-align:right}
|
||||
|
||||
/* Search */
|
||||
.search-row{display:flex;gap:12px;margin-bottom:24px}
|
||||
.input{flex:1;background:var(--surface);border:1px solid var(--border);padding:14px 18px;border-radius:10px;color:var(--text);font-size:.95rem;font-family:inherit}
|
||||
.input:focus{outline:none;border-color:var(--accent)}
|
||||
@@ -63,8 +45,6 @@ export const html = `<!DOCTYPE html>
|
||||
.btn{background:var(--accent);color:#000;border:none;padding:14px 28px;border-radius:10px;font-size:.9rem;font-weight:600;font-family:inherit;cursor:pointer;transition:all .15s}
|
||||
.btn:hover{opacity:.9}
|
||||
.btn:disabled{opacity:.4}
|
||||
|
||||
/* Results */
|
||||
.results{max-height:50vh;overflow-y:auto}
|
||||
.result{display:flex;align-items:center;gap:14px;padding:12px;border-radius:10px;cursor:pointer;transition:all .15s}
|
||||
.result:hover{background:var(--surface)}
|
||||
@@ -76,14 +56,10 @@ export const html = `<!DOCTYPE html>
|
||||
.dur{font-size:.75rem;color:var(--dim);font-family:monospace}
|
||||
.empty{padding:48px;text-align:center;color:var(--dim)}
|
||||
.loading{display:none;padding:48px;text-align:center;color:var(--accent)}
|
||||
|
||||
/* API Tester */
|
||||
.tester-row{display:flex;gap:12px;margin-bottom:16px;flex-wrap:wrap}
|
||||
.url-preview{font-family:monospace;font-size:.8rem;color:var(--muted);padding:12px 16px;background:var(--surface);border-radius:8px;margin-bottom:16px;border:1px solid var(--border)}
|
||||
.response{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:20px;margin-top:20px;max-height:400px;overflow:auto}
|
||||
.response pre{font-family:'SF Mono',Monaco,monospace;font-size:.75rem;color:var(--accent);white-space:pre-wrap;word-break:break-all}
|
||||
|
||||
/* Player */
|
||||
.player{position:fixed;bottom:0;left:0;right:0;background:rgba(10,10,10,.95);backdrop-filter:blur(20px);border-top:1px solid var(--border);padding:16px 24px;display:none;z-index:100}
|
||||
.player.visible{display:block}
|
||||
.player-inner{max-width:900px;margin:0 auto}
|
||||
@@ -100,14 +76,7 @@ export const html = `<!DOCTYPE html>
|
||||
.time{font-size:.7rem;color:var(--muted);min-width:40px;font-family:monospace}
|
||||
.bar{flex:1;height:4px;background:var(--surface2);border-radius:2px;cursor:pointer}
|
||||
.fill{height:100%;background:var(--accent);border-radius:2px;width:0%}
|
||||
|
||||
@media(max-width:600px){
|
||||
.container{padding:40px 16px 180px}
|
||||
.logo{width:80px;height:80px}
|
||||
.title{font-size:2rem}
|
||||
.desc{display:none}
|
||||
.search-row{flex-direction:column}
|
||||
}
|
||||
@media(max-width:600px){.container{padding:40px 16px 180px}.logo{width:80px;height:80px}.title{font-size:2rem}.desc{display:none}.search-row{flex-direction:column}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -125,33 +94,24 @@ export const html = `<!DOCTYPE html>
|
||||
<button class="nav-btn" onclick="showTab('tester')">Tester</button>
|
||||
</div>
|
||||
|
||||
<!-- DOCS TAB -->
|
||||
<div id="docs" class="tab active">
|
||||
<div class="section">
|
||||
<div class="section-title">Search</div>
|
||||
<div class="api-list">
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/search</span><span class="desc">Search songs, albums, artists</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/search/suggestions</span><span class="desc">Autocomplete suggestions</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/yt_search</span><span class="desc">YouTube video search</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-title">Content (v1)</div>
|
||||
<div class="section-title">Content</div>
|
||||
<div class="api-list">
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/songs/:videoId</span><span class="desc">Song details</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/albums/:browseId</span><span class="desc">Album with tracks</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/artists/:browseId</span><span class="desc">Artist profile</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/songs/:videoId</span><span class="desc">Song + artist/album links</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/albums/:browseId</span><span class="desc">Album + tracks + artist</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/artists/:browseId</span><span class="desc">Artist + discography</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/playlists/:playlistId</span><span class="desc">Playlist tracks</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-title">Unified Content (v2) — Linked Entities</div>
|
||||
<div class="api-list">
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/v2/songs/:videoId</span><span class="desc">Song + artist/album links</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/v2/albums/:browseId</span><span class="desc">Album + artist + numbered tracks</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/v2/artists/:browseId</span><span class="desc">Artist + full discography</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/v2/chain/:videoId</span><span class="desc">Song → Artist → Discography</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/chain/:videoId</span><span class="desc">Song -> Artist -> Albums</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -160,7 +120,10 @@ export const html = `<!DOCTYPE html>
|
||||
<div class="api-list">
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/related/:videoId</span><span class="desc">Related songs</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/radio?videoId=</span><span class="desc">Generate radio mix</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/similar?title=&artist=</span><span class="desc">Similar tracks</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/charts?country=</span><span class="desc">Music charts</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/trending?country=</span><span class="desc">Trending music</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/moods</span><span class="desc">Mood categories</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -168,12 +131,22 @@ export const html = `<!DOCTYPE html>
|
||||
<div class="section-title">Streaming & Lyrics</div>
|
||||
<div class="api-list">
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/stream?id=</span><span class="desc">Audio stream URLs</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/proxy?url=</span><span class="desc">Audio proxy (CORS)</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/lyrics?title=&artist=</span><span class="desc">Synced lyrics (LRC)</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-title">Info</div>
|
||||
<div class="api-list">
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/artist/info?artist=</span><span class="desc">Artist bio (Last.fm)</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/track/info?title=&artist=</span><span class="desc">Track info (Last.fm)</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/top/artists?country=</span><span class="desc">Top artists</span></div>
|
||||
<div class="api-item"><span class="method">GET</span><span class="path">/api/top/tracks?country=</span><span class="desc">Top tracks</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PLAYER TAB -->
|
||||
<div id="player-tab" class="tab">
|
||||
<div class="search-row">
|
||||
<select class="select" id="filter">
|
||||
@@ -189,7 +162,6 @@ export const html = `<!DOCTYPE html>
|
||||
<div class="results" id="results"></div>
|
||||
</div>
|
||||
|
||||
<!-- TESTER TAB -->
|
||||
<div id="tester" class="tab">
|
||||
<div class="tester-row">
|
||||
<select class="select" id="endpoint" onchange="updateInputs()" style="min-width:200px">
|
||||
@@ -198,10 +170,7 @@ export const html = `<!DOCTYPE html>
|
||||
<option value="song">Song Details</option>
|
||||
<option value="album">Album</option>
|
||||
<option value="artist">Artist</option>
|
||||
<option value="v2song">v2 Song (linked)</option>
|
||||
<option value="v2album">v2 Album (linked)</option>
|
||||
<option value="v2artist">v2 Artist (linked)</option>
|
||||
<option value="v2chain">v2 Chain (full)</option>
|
||||
<option value="chain">Full Chain</option>
|
||||
<option value="related">Related</option>
|
||||
<option value="radio">Radio</option>
|
||||
<option value="lyrics">Lyrics</option>
|
||||
@@ -215,7 +184,6 @@ export const html = `<!DOCTYPE html>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PLAYER BAR -->
|
||||
<div class="player" id="playerBar">
|
||||
<div class="player-inner">
|
||||
<div class="player-row">
|
||||
@@ -241,38 +209,16 @@ export const html = `<!DOCTYPE html>
|
||||
<div id="ytplayer"></div>
|
||||
</body>
|
||||
<script>
|
||||
// Suppress YouTube errors
|
||||
(function(){var e=console.error;console.error=function(){var m=arguments[0]||'';if(typeof m==='string'&&(m.includes('postMessage')||m.includes('youtube')))return;e.apply(console,arguments)}})();
|
||||
|
||||
// Load YouTube API
|
||||
var tag=document.createElement('script');tag.src='https://www.youtube.com/iframe_api';document.head.appendChild(tag);
|
||||
|
||||
var songs=[],yt=null,ready=false,playing=false,idx=-1,interval=null;
|
||||
document.getElementById('query').onkeypress=e=>{if(e.key==='Enter')search()};
|
||||
|
||||
function showTab(t){
|
||||
var current=document.querySelector('.tab.active');
|
||||
var next=document.getElementById(t==='player'?'player-tab':t);
|
||||
if(current===next)return;
|
||||
|
||||
document.querySelectorAll('.tab').forEach(el=>el.classList.remove('active'));
|
||||
document.querySelectorAll('.nav-btn').forEach(b=>b.classList.remove('active'));
|
||||
document.getElementById(t==='player'?'player-tab':t).classList.add('active');
|
||||
document.querySelector('.nav-btn[onclick*="'+t+'"]').classList.add('active');
|
||||
|
||||
// Fade out current
|
||||
if(current){
|
||||
current.classList.add('fade-out');
|
||||
setTimeout(()=>{
|
||||
current.classList.remove('active','fade-out');
|
||||
// Fade in next
|
||||
next.classList.add('fade-in');
|
||||
requestAnimationFrame(()=>{
|
||||
next.classList.add('active');
|
||||
next.classList.remove('fade-in');
|
||||
});
|
||||
},200);
|
||||
}else{
|
||||
next.classList.add('active');
|
||||
}
|
||||
}
|
||||
|
||||
function onYouTubeIframeAPIReady(){
|
||||
@@ -280,29 +226,17 @@ function onYouTubeIframeAPIReady(){
|
||||
}
|
||||
function onErr(e){
|
||||
if(e.data===150||e.data===101||e.data===100){
|
||||
// Try fallbackVideoId first, then search YouTube
|
||||
var s=songs[idx];
|
||||
if(s&&s.fallbackVideoId&&!s.triedFallback){
|
||||
console.log('Using fallback:',s.fallbackVideoId);
|
||||
s.triedFallback=true;
|
||||
yt.loadVideoById(s.fallbackVideoId);
|
||||
s.triedFallback=true;yt.loadVideoById(s.fallbackVideoId);
|
||||
}else if(s&&!s.triedSearch){
|
||||
// Search YouTube for playable version
|
||||
s.triedSearch=true;
|
||||
searchYouTube(s.title,s.artists?.[0]?.name||'').then(vid=>{
|
||||
if(vid){console.log('Found alternative:',vid);yt.loadVideoById(vid)}
|
||||
});
|
||||
searchYouTube(s.title,s.artists?.[0]?.name||'').then(vid=>{if(vid)yt.loadVideoById(vid)});
|
||||
}
|
||||
}
|
||||
}
|
||||
async function searchYouTube(title,artist){
|
||||
try{
|
||||
var q=title+' '+artist+' official';
|
||||
var res=await fetch('/api/yt_search?q='+encodeURIComponent(q)+'&filter=videos');
|
||||
var data=await res.json();
|
||||
var alt=data.results?.find(v=>v.channel?.name&&!v.channel.name.includes('Topic')&&v.id);
|
||||
return alt?.id||null;
|
||||
}catch(e){return null}
|
||||
try{var res=await fetch('/api/yt_search?q='+encodeURIComponent(title+' '+artist+' official')+'&filter=videos');var data=await res.json();var alt=data.results?.find(v=>v.channel?.name&&!v.channel.name.includes('Topic')&&v.id);return alt?.id||null}catch(e){return null}
|
||||
}
|
||||
function onState(e){
|
||||
if(e.data===1){playing=true;document.getElementById('playBtn').textContent='⏸';startProgress()}
|
||||
@@ -311,29 +245,16 @@ function onState(e){
|
||||
}
|
||||
function startProgress(){stopProgress();interval=setInterval(updateProgress,500)}
|
||||
function stopProgress(){if(interval){clearInterval(interval);interval=null}}
|
||||
function updateProgress(){
|
||||
if(!yt||!ready)return;
|
||||
var c=yt.getCurrentTime()||0,t=yt.getDuration()||0;
|
||||
document.getElementById('cur').textContent=fmt(c);
|
||||
document.getElementById('total').textContent=fmt(t);
|
||||
document.getElementById('fill').style.width=t>0?(c/t*100)+'%':'0%';
|
||||
}
|
||||
function updateProgress(){if(!yt||!ready)return;var c=yt.getCurrentTime()||0,t=yt.getDuration()||0;document.getElementById('cur').textContent=fmt(c);document.getElementById('total').textContent=fmt(t);document.getElementById('fill').style.width=t>0?(c/t*100)+'%':'0%'}
|
||||
function fmt(s){var m=Math.floor(s/60),sec=Math.floor(s%60);return m+':'+(sec<10?'0':'')+sec}
|
||||
function seek(e){if(!yt||!ready)return;var bar=document.getElementById('bar'),rect=bar.getBoundingClientRect(),pct=(e.clientX-rect.left)/rect.width;yt.seekTo(pct*(yt.getDuration()||0),true)}
|
||||
|
||||
async function search(){
|
||||
var q=document.getElementById('query').value.trim();if(!q)return;
|
||||
var f=document.getElementById('filter').value;
|
||||
document.getElementById('searchBtn').disabled=true;
|
||||
document.getElementById('loading').style.display='block';
|
||||
document.getElementById('results').innerHTML='';
|
||||
try{
|
||||
var url='/api/search?q='+encodeURIComponent(q);if(f)url+='&filter='+f;
|
||||
var res=await fetch(url);var data=await res.json();
|
||||
songs=data.results||[];render(f);
|
||||
}catch(e){songs=[];render(f)}
|
||||
document.getElementById('searchBtn').disabled=false;
|
||||
document.getElementById('loading').style.display='none';
|
||||
document.getElementById('searchBtn').disabled=true;document.getElementById('loading').style.display='block';document.getElementById('results').innerHTML='';
|
||||
try{var url='/api/search?q='+encodeURIComponent(q);if(f)url+='&filter='+f;var res=await fetch(url);var data=await res.json();songs=data.results||[];render(f)}catch(e){songs=[];render(f)}
|
||||
document.getElementById('searchBtn').disabled=false;document.getElementById('loading').style.display='none';
|
||||
}
|
||||
|
||||
function render(f){
|
||||
@@ -348,8 +269,7 @@ function render(f){
|
||||
}
|
||||
|
||||
function play(i){
|
||||
if(!songs[i]||!ready)return;
|
||||
idx=i;var s=songs[i];
|
||||
if(!songs[i]||!ready)return;idx=i;var s=songs[i];
|
||||
document.getElementById('pTitle').textContent=s.title||'Unknown';
|
||||
document.getElementById('pArtist').textContent=s.artists?.map(a=>a.name).join(', ')||'';
|
||||
document.getElementById('pThumb').src=s.thumbnails?.[0]?.url||'https://img.youtube.com/vi/'+s.videoId+'/mqdefault.jpg';
|
||||
@@ -361,21 +281,16 @@ function toggle(){if(!ready)return;playing?yt.pauseVideo():yt.playVideo()}
|
||||
function prev(){if(idx>0)play(idx-1)}
|
||||
function next(){if(idx<songs.length-1)play(idx+1)}
|
||||
function esc(t){var d=document.createElement('div');d.textContent=t;return d.innerHTML}
|
||||
function viewArtist(id){showTab('tester');document.getElementById('endpoint').value='artist';updateInputs();document.getElementById('api_browseId').value=id;updateUrl();testApi()}
|
||||
function viewAlbum(id){showTab('tester');document.getElementById('endpoint').value='album';updateInputs();document.getElementById('api_browseId').value=id;updateUrl();testApi()}
|
||||
|
||||
function viewArtist(id){showTab('tester');document.getElementById('endpoint').value='v2artist';updateInputs();document.getElementById('api_browseId').value=id;updateUrl();testApi()}
|
||||
function viewAlbum(id){showTab('tester');document.getElementById('endpoint').value='v2album';updateInputs();document.getElementById('api_browseId').value=id;updateUrl();testApi()}
|
||||
|
||||
// API Tester
|
||||
var cfg={
|
||||
search:{inputs:[{n:'q',p:'Query',v:'coldplay'}],url:'/api/search'},
|
||||
stream:{inputs:[{n:'id',p:'Video ID',v:'dQw4w9WgXcQ'}],url:'/api/stream'},
|
||||
song:{inputs:[{n:'videoId',p:'Video ID',v:'dQw4w9WgXcQ'}],url:'/api/songs/{videoId}'},
|
||||
album:{inputs:[{n:'browseId',p:'Album ID',v:'MPREb_PvMNqFUp1oW'}],url:'/api/albums/{browseId}'},
|
||||
artist:{inputs:[{n:'browseId',p:'Artist ID',v:'UCIaFw5VBEK8qaW6nRpx_qnw'}],url:'/api/artists/{browseId}'},
|
||||
v2song:{inputs:[{n:'videoId',p:'Video ID',v:'9qnqYL0eNNI'}],url:'/api/v2/songs/{videoId}'},
|
||||
v2album:{inputs:[{n:'browseId',p:'Album ID',v:'MPREb_PvMNqFUp1oW'}],url:'/api/v2/albums/{browseId}'},
|
||||
v2artist:{inputs:[{n:'browseId',p:'Artist ID',v:'UCIaFw5VBEK8qaW6nRpx_qnw'}],url:'/api/v2/artists/{browseId}'},
|
||||
v2chain:{inputs:[{n:'videoId',p:'Video ID',v:'9qnqYL0eNNI'}],url:'/api/v2/chain/{videoId}'},
|
||||
chain:{inputs:[{n:'videoId',p:'Video ID',v:'9qnqYL0eNNI'}],url:'/api/chain/{videoId}'},
|
||||
related:{inputs:[{n:'id',p:'Video ID',v:'dQw4w9WgXcQ'}],url:'/api/related/{id}'},
|
||||
radio:{inputs:[{n:'videoId',p:'Video ID',v:'9qnqYL0eNNI'}],url:'/api/radio'},
|
||||
lyrics:{inputs:[{n:'title',p:'Title',v:'Yellow'},{n:'artist',p:'Artist',v:'Coldplay'}],url:'/api/lyrics'},
|
||||
@@ -390,8 +305,7 @@ function updateInputs(){
|
||||
function updateUrl(){
|
||||
var ep=document.getElementById('endpoint').value,c=cfg[ep],url=c.url,params=new URLSearchParams();
|
||||
c.inputs.forEach(i=>{var v=document.getElementById('api_'+i.n)?.value||i.v;if(v){if(url.includes('{'+i.n+'}'))url=url.replace('{'+i.n+'}',encodeURIComponent(v));else params.append(i.n,v)}});
|
||||
var qs=params.toString();if(qs)url+='?'+qs;
|
||||
document.getElementById('urlPreview').textContent='GET '+url;
|
||||
var qs=params.toString();if(qs)url+='?'+qs;document.getElementById('urlPreview').textContent='GET '+url;
|
||||
}
|
||||
async function testApi(){
|
||||
var ep=document.getElementById('endpoint').value,c=cfg[ep],url=c.url,params=new URLSearchParams();
|
||||
|
||||
Reference in New Issue
Block a user