#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 .
#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
{
/// GET /api/v1/library
public sealed class LibraryDto
{
/// Changes whenever any song file is added, removed or changed. Also sent as ETag.
public string Version { get; set; } = "";
public string ScannedAt { get; set; } = "";
public List Songs { get; set; } = new List();
/// All files in the song folders (text files, audio, video, images), downloadable via /api/v1/files/{path}.
public List Files { get; set; } = new List();
}
public sealed class SongDto
{
/// Stable id, derived from the path of the text file.
public string Id { get; set; } = "";
/// Path of the UltraStar text file.
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; }
/// Last modification, Unix time in milliseconds (UTC).
public long Modified { get; set; }
}
/// POST /api/v1/files/bundle: returns the files as a zip archive (entries named by their path).
public sealed class BundleRequest
{
public List Paths { get; set; } = new List();
}
/// GET /api/v1/sources: where new songs can be found.
public sealed class SourceDto
{
public string Id { get; set; } = "";
public string Name { get; set; } = "";
public string Description { get; set; } = "";
public bool Enabled { get; set; }
/// Why the source is disabled (e.g. missing account), or empty.
public string Hint { get; set; } = "";
}
/// GET /api/v1/search?q=...: results of all enabled sources.
public sealed class SearchResponse
{
public List Results { get; set; } = new List();
/// Sources that failed for this search: source id -> error message.
public Dictionary Errors { get; set; } = new Dictionary();
}
public sealed class SearchResultDto
{
public string Source { get; set; } = "";
/// Id of the song within its source; used to download it.
public string SourceId { get; set; } = "";
public string Artist { get; set; } = "";
public string Title { get; set; } = "";
/// Extra info shown with the result (language, year, license, ...).
public string Details { get; set; } = "";
public string CoverUrl { get; set; } = "";
/// True if a song with the same artist and title is already in the library.
public bool InLibrary { get; set; }
}
/// POST /api/v1/downloads
public sealed class DownloadRequest
{
public string Source { get; set; } = "";
public string SourceId { get; set; } = "";
public string Artist { get; set; } = "";
public string Title { get; set; } = "";
}
/// GET /api/v1/downloads: queued, running and finished downloads (newest first).
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; } = "";
/// queued, running, done or failed
public string State { get; set; } = "";
/// 0..1
public double Progress { get; set; }
public string Message { get; set; } = "";
public string Created { get; set; } = "";
}
}