- Sources: "free" (Creative Commons songs with media from github.com/UltraStar-Deluxe/songs) and "usdb" (usdb.animux.de with an account; audio/video via yt-dlp from the song's #VIDEO hints or YouTube links in the comments, covers from fanart.tv/YouTube) - Aggregated search (all sources in parallel, in-library flag), download queue into <library>/Downloads/<source>/<Artist - Title>, then rescan - Web UI in wwwroot (plain JS, no build): search, downloads with progress, library; phone first, dark mode, installable - Docker image with yt-dlp, ffmpeg and deno; library mounted writable - Tests for matching, USDB parsing and song rewriting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
117 lines
4.9 KiB
C#
117 lines
4.9 KiB
C#
#region license
|
|
// This file is part of Vocaluxe.
|
|
//
|
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Vocaluxe is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
|
#endregion
|
|
|
|
using System.Collections.Generic;
|
|
|
|
// Shared between the song server and the game (linked into Vocaluxe.csproj). Keep it free of dependencies.
|
|
// Serialized as camelCase JSON. All paths are relative to the library root and use '/'.
|
|
namespace VocaluxeSongServer.Contracts
|
|
{
|
|
/// <summary>GET /api/v1/library</summary>
|
|
public sealed class LibraryDto
|
|
{
|
|
/// <summary>Changes whenever any song file is added, removed or changed. Also sent as ETag.</summary>
|
|
public string Version { get; set; } = "";
|
|
public string ScannedAt { get; set; } = "";
|
|
public List<SongDto> Songs { get; set; } = new List<SongDto>();
|
|
/// <summary>All files in the song folders (text files, audio, video, images), downloadable via /api/v1/files/{path}.</summary>
|
|
public List<FileDto> Files { get; set; } = new List<FileDto>();
|
|
}
|
|
|
|
public sealed class SongDto
|
|
{
|
|
/// <summary>Stable id, derived from the path of the text file.</summary>
|
|
public string Id { get; set; } = "";
|
|
/// <summary>Path of the UltraStar text file.</summary>
|
|
public string Path { get; set; } = "";
|
|
public string Title { get; set; } = "";
|
|
public string Artist { get; set; } = "";
|
|
}
|
|
|
|
public sealed class FileDto
|
|
{
|
|
public string Path { get; set; } = "";
|
|
public long Size { get; set; }
|
|
/// <summary>Last modification, Unix time in milliseconds (UTC).</summary>
|
|
public long Modified { get; set; }
|
|
}
|
|
|
|
/// <summary>POST /api/v1/files/bundle: returns the files as a zip archive (entries named by their path).</summary>
|
|
public sealed class BundleRequest
|
|
{
|
|
public List<string> Paths { get; set; } = new List<string>();
|
|
}
|
|
|
|
/// <summary>GET /api/v1/sources: where new songs can be found.</summary>
|
|
public sealed class SourceDto
|
|
{
|
|
public string Id { get; set; } = "";
|
|
public string Name { get; set; } = "";
|
|
public string Description { get; set; } = "";
|
|
public bool Enabled { get; set; }
|
|
/// <summary>Why the source is disabled (e.g. missing account), or empty.</summary>
|
|
public string Hint { get; set; } = "";
|
|
}
|
|
|
|
/// <summary>GET /api/v1/search?q=...: results of all enabled sources.</summary>
|
|
public sealed class SearchResponse
|
|
{
|
|
public List<SearchResultDto> Results { get; set; } = new List<SearchResultDto>();
|
|
/// <summary>Sources that failed for this search: source id -> error message.</summary>
|
|
public Dictionary<string, string> Errors { get; set; } = new Dictionary<string, string>();
|
|
}
|
|
|
|
public sealed class SearchResultDto
|
|
{
|
|
public string Source { get; set; } = "";
|
|
/// <summary>Id of the song within its source; used to download it.</summary>
|
|
public string SourceId { get; set; } = "";
|
|
public string Artist { get; set; } = "";
|
|
public string Title { get; set; } = "";
|
|
/// <summary>Extra info shown with the result (language, year, license, ...).</summary>
|
|
public string Details { get; set; } = "";
|
|
public string CoverUrl { get; set; } = "";
|
|
/// <summary>True if a song with the same artist and title is already in the library.</summary>
|
|
public bool InLibrary { get; set; }
|
|
}
|
|
|
|
/// <summary>POST /api/v1/downloads</summary>
|
|
public sealed class DownloadRequest
|
|
{
|
|
public string Source { get; set; } = "";
|
|
public string SourceId { get; set; } = "";
|
|
public string Artist { get; set; } = "";
|
|
public string Title { get; set; } = "";
|
|
}
|
|
|
|
/// <summary>GET /api/v1/downloads: queued, running and finished downloads (newest first).</summary>
|
|
public sealed class DownloadJobDto
|
|
{
|
|
public string Id { get; set; } = "";
|
|
public string Source { get; set; } = "";
|
|
public string SourceId { get; set; } = "";
|
|
public string Artist { get; set; } = "";
|
|
public string Title { get; set; } = "";
|
|
/// <summary>queued, running, done or failed</summary>
|
|
public string State { get; set; } = "";
|
|
/// <summary>0..1</summary>
|
|
public double Progress { get; set; }
|
|
public string Message { get; set; } = "";
|
|
public string Created { get; set; } = "";
|
|
}
|
|
}
|