mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-10-08 14:05:02 -04:00
74 lines
3.3 KiB
C#
74 lines
3.3 KiB
C#
using allstarr.Models.Domain;
|
|
using allstarr.Models.Settings;
|
|
using allstarr.Models.Download;
|
|
using allstarr.Models.Search;
|
|
using allstarr.Models.Subsonic;
|
|
|
|
namespace allstarr.Services;
|
|
|
|
/// <summary>
|
|
/// Interface for the music download service (Deezspot or other)
|
|
/// </summary>
|
|
public interface IDownloadService
|
|
{
|
|
/// <summary>
|
|
/// Downloads a song from an external provider
|
|
/// </summary>
|
|
/// <param name="externalProvider">The provider (deezer, spotify)</param>
|
|
/// <param name="externalId">The ID on the external provider</param>
|
|
/// <param name="cancellationToken">Cancellation token</param>
|
|
/// <returns>The path to the downloaded file</returns>
|
|
Task<string> DownloadSongAsync(string externalProvider, string externalId, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Downloads a song and streams the result progressively.
|
|
/// When qualityOverride is specified (not null and not Original), downloads at the requested
|
|
/// quality tier instead of the configured .env quality. Used for client-requested "transcoding".
|
|
/// The .env quality acts as a ceiling — client requests can only go equal or lower.
|
|
/// </summary>
|
|
/// <param name="externalProvider">The provider (deezer, spotify)</param>
|
|
/// <param name="externalId">The ID on the external provider</param>
|
|
/// <param name="qualityOverride">Optional quality tier override for streaming (null = use .env quality)</param>
|
|
/// <param name="cancellationToken">Cancellation token</param>
|
|
/// <returns>A stream of the audio file</returns>
|
|
Task<Stream> DownloadAndStreamAsync(string externalProvider, string externalId, Common.StreamQuality? qualityOverride = null, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Downloads remaining tracks from an album in background (excluding the specified track)
|
|
/// </summary>
|
|
/// <param name="externalProvider">The provider (deezer, spotify)</param>
|
|
/// <param name="albumExternalId">The album ID on the external provider</param>
|
|
/// <param name="excludeTrackExternalId">The track ID to exclude (already downloaded)</param>
|
|
void DownloadRemainingAlbumTracksInBackground(string externalProvider, string albumExternalId, string excludeTrackExternalId);
|
|
|
|
/// <summary>
|
|
/// Checks if a song is currently being downloaded
|
|
/// </summary>
|
|
DownloadInfo? GetDownloadStatus(string songId);
|
|
|
|
/// <summary>
|
|
/// Gets a snapshot of all active/recent downloads for the activity feed
|
|
/// </summary>
|
|
IReadOnlyList<DownloadInfo> GetActiveDownloads();
|
|
|
|
/// <summary>
|
|
/// Gets the local path for a song if it has been downloaded already
|
|
/// </summary>
|
|
/// <param name="externalProvider">The provider (deezer, qobuz, etc.)</param>
|
|
/// <param name="externalId">The ID on the external provider</param>
|
|
/// <returns>The local file path if exists, null otherwise</returns>
|
|
Task<string?> GetLocalPathIfExistsAsync(string externalProvider, string externalId);
|
|
|
|
/// <summary>
|
|
/// Checks if the service is properly configured and functional
|
|
/// </summary>
|
|
Task<bool> IsAvailableAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Marker interface to distinguish concrete download services from orchestrator services.
|
|
/// </summary>
|
|
public interface IConcreteDownloadService : IDownloadService
|
|
{
|
|
}
|