Remove YouTube integration from backend and deployment config
Drops the YouTube-backed second catalog source entirely: the Local/External split on Track/Album collapses into single concrete entities, Artist/TrackArtist/ExternalTrack/ExternalAlbum and the YouTube service/download pipeline (yt-dlp, MassTransit consumer, routing slip) are deleted, and mixes now source discovery only from local listening history. Includes the RemoveYouTubeIntegration EF Core migration and matching Worker/deploy/compose cleanup (no more yt-dlp/python/deno in the Worker image, no thumbnail-cache/YtDlp config sections).
This commit is contained in:
@@ -36,9 +36,6 @@
|
||||
"OpenTelemetry": {
|
||||
"OtlpEndpoint": "http://localhost:4317"
|
||||
},
|
||||
"YouTube": {
|
||||
"GeographicalLocation": "ES"
|
||||
},
|
||||
"Workers": {
|
||||
"Routes": {
|
||||
"TemporaryFilesDirectory": "../../../deploy/.tmp"
|
||||
|
||||
@@ -53,21 +53,8 @@
|
||||
"AnonymousFragmentSeconds": 0,
|
||||
"EstimatedAudioBytesPerSecond": 16000
|
||||
},
|
||||
"YouTube": {
|
||||
"Enabled": true,
|
||||
"GeographicalLocation": "US",
|
||||
"StreamUrlCacheSeconds": 1800,
|
||||
"SearchContinuationCacheSeconds": 600,
|
||||
"SearchResultsCacheSeconds": 900,
|
||||
"SongInfoCacheSeconds": 86400,
|
||||
"ThumbnailSize": 240,
|
||||
"ArtworkSize": 544
|
||||
},
|
||||
"Mix": {
|
||||
"ArtistMixCount": 3,
|
||||
"ItemsPerMix": 12,
|
||||
"SeedArtistCount": 3,
|
||||
"YouTubeResultsPerSeed": 12
|
||||
"ItemsPerMix": 12
|
||||
},
|
||||
"PlayList": {
|
||||
"Routes": {
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
using Musify.Domain.ValueObjects;
|
||||
|
||||
namespace Musify.Api.DataTransferObjects.Likes;
|
||||
|
||||
/// <summary>Toggle a like on a track already in the catalog by <see cref="TrackId"/>, or one from an
|
||||
/// external source by <see cref="Source"/> + <see cref="ExternalId"/> (provisioning it in the
|
||||
/// background if needed) — exactly one of the two must be given.</summary>
|
||||
public record ToggleLikeRequest(Guid? TrackId, TrackSource? Source, string? ExternalId);
|
||||
public record ToggleLikeRequest(Guid TrackId);
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
using Musify.Domain.ValueObjects;
|
||||
|
||||
namespace Musify.Api.DataTransferObjects.PlayLists;
|
||||
|
||||
/// <summary>Add a track already in the catalog by <see cref="TrackId"/>, or one from an external
|
||||
/// source by <see cref="Source"/> + <see cref="ExternalId"/> (provisioning it in the background if
|
||||
/// needed) — exactly one of the two must be given.</summary>
|
||||
public record AddPlayListTrackRequest(Guid? TrackId, TrackSource? Source, string? ExternalId);
|
||||
public record AddPlayListTrackRequest(Guid TrackId);
|
||||
|
||||
@@ -8,8 +8,6 @@ using Musify.Application.Albums.Responses;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Shared;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
using Musify.Application.YouTube;
|
||||
using Musify.Domain.ValueObjects;
|
||||
|
||||
namespace Musify.Api.Endpoints;
|
||||
|
||||
@@ -22,7 +20,7 @@ public static class AlbumEndpoints
|
||||
|
||||
group.MapGet("/", GetAlbums)
|
||||
.WithName("GetAlbums")
|
||||
.WithSummary("Get Paginated Albums, Combined With Live YouTube Music Results When A Title Filter Is Given.")
|
||||
.WithSummary("Get Paginated Albums, Optionally Filtered By Title.")
|
||||
.Produces<AlbumsSearchResponse>();
|
||||
|
||||
group.MapGet("/{id}", GetAlbumById)
|
||||
@@ -31,12 +29,6 @@ public static class AlbumEndpoints
|
||||
.Produces<AlbumApplicationResponse>()
|
||||
.Produces(StatusCodes.Status404NotFound);
|
||||
|
||||
group.MapGet("/external/{source}/{externalId}", GetExternalAlbum)
|
||||
.WithName("GetExternalAlbum")
|
||||
.WithSummary("Get An Album From An External Source (Currently Only YouTube Music) With Its Tracklist.")
|
||||
.Produces<YouTubeAlbumDetail>()
|
||||
.Produces(StatusCodes.Status404NotFound);
|
||||
|
||||
group.MapGet("/users/{userId}", GetAlbumsByUserId)
|
||||
.WithName("GetAlbumsByUserId")
|
||||
.WithSummary("Get Paginated Albums For A User.")
|
||||
@@ -125,10 +117,9 @@ public static class AlbumEndpoints
|
||||
CancellationToken cancellationToken,
|
||||
string? title,
|
||||
int pageNumber = 1,
|
||||
int pageSize = 10,
|
||||
string? youtubeContinuationToken = null)
|
||||
int pageSize = 10)
|
||||
{
|
||||
var result = await mediator.Send(new GetAlbumsQuery(title, pageNumber, pageSize, youtubeContinuationToken), cancellationToken);
|
||||
var result = await mediator.Send(new GetAlbumsQuery(title, pageNumber, pageSize), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
@@ -141,19 +132,6 @@ public static class AlbumEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> GetExternalAlbum(
|
||||
IMediator mediator,
|
||||
string source,
|
||||
string externalId,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (!Enum.TryParse<TrackSource>(source, ignoreCase: true, out var trackSource) || trackSource != TrackSource.YouTube)
|
||||
return Results.NotFound($"Unknown or unsupported source '{source}'.");
|
||||
|
||||
var result = await mediator.Send(new GetYouTubeAlbumQuery(externalId), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> GetAlbumsByUserId(
|
||||
IMediator mediator,
|
||||
long userId,
|
||||
|
||||
@@ -25,10 +25,8 @@ public static class LikeEndpoints
|
||||
|
||||
group.MapPost("/toggle", ToggleTrackLike)
|
||||
.WithName("ToggleTrackLike")
|
||||
.WithSummary("Like Or Unlike A Track, By Id Or By External Source, Provisioning It In The Background If Needed.")
|
||||
.AddEndpointFilter<ValidationFilter<ToggleLikeRequest>>()
|
||||
.WithSummary("Like Or Unlike A Track By Id.")
|
||||
.Produces<bool>()
|
||||
.ProducesValidationProblem()
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces(StatusCodes.Status404NotFound);
|
||||
|
||||
@@ -53,7 +51,7 @@ public static class LikeEndpoints
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await mediator.Send(
|
||||
new ToggleTrackLikeCommand(currentUser.RequiredId, request.TrackId, request.Source, request.ExternalId),
|
||||
new ToggleTrackLikeCommand(currentUser.RequiredId, request.TrackId),
|
||||
cancellationToken);
|
||||
|
||||
return result.ToHttpResult();
|
||||
|
||||
@@ -5,7 +5,6 @@ using Musify.Application.Tracks;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
using Musify.Application.Shared;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Domain.ValueObjects;
|
||||
using Musify.Api.Authentication;
|
||||
using Musify.Api.DataTransferObjects.PlayLists;
|
||||
using Musify.Api.Extensions;
|
||||
@@ -88,11 +87,9 @@ public static class PlayListEndpoints
|
||||
|
||||
group.MapPost("/{playlistId}/tracks", AddPlayListTrack)
|
||||
.WithName("AddPlayListTrack")
|
||||
.WithSummary("Add A Track To A PlayList, By Id Or By External Source, Provisioning It In The Background If Needed.")
|
||||
.AddEndpointFilter<ValidationFilter<AddPlayListTrackRequest>>()
|
||||
.WithSummary("Add One Of Your Tracks To A PlayList.")
|
||||
.RequireAuthorization()
|
||||
.Produces<TrackApplicationResponse>(StatusCodes.Status201Created)
|
||||
.ProducesValidationProblem()
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces(StatusCodes.Status404NotFound)
|
||||
.Produces(StatusCodes.Status409Conflict);
|
||||
@@ -227,25 +224,14 @@ public static class PlayListEndpoints
|
||||
AddPlayListTrackRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.TrackId is { } trackId)
|
||||
{
|
||||
var addResult = await mediator.Send(
|
||||
new AddTrackToPlayListCommand(currentUser.RequiredId, playlistId, trackId),
|
||||
cancellationToken);
|
||||
if (addResult.IsError)
|
||||
return addResult.ToHttpResult();
|
||||
|
||||
var trackResult = await mediator.Send(new GetTrackByIdQuery(trackId), cancellationToken);
|
||||
return trackResult.ToCreatedResult(track => $"/tracks/{track.Id}");
|
||||
}
|
||||
|
||||
// The validator guarantees Source/ExternalId are set whenever TrackId isn't, and that Source
|
||||
// is one of the currently supported external sources (only YouTube for now).
|
||||
var result = await mediator.Send(
|
||||
new AddYouTubeTrackToPlayListCommand(currentUser.RequiredId, playlistId, request.ExternalId!),
|
||||
var addResult = await mediator.Send(
|
||||
new AddTrackToPlayListCommand(currentUser.RequiredId, playlistId, request.TrackId),
|
||||
cancellationToken);
|
||||
if (addResult.IsError)
|
||||
return addResult.ToHttpResult();
|
||||
|
||||
return result.ToCreatedResult(track => $"/tracks/{track.Id}");
|
||||
var trackResult = await mediator.Send(new GetTrackByIdQuery(request.TrackId), cancellationToken);
|
||||
return trackResult.ToCreatedResult(track => $"/tracks/{track.Id}");
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveTrackFromPlayList(
|
||||
|
||||
@@ -3,9 +3,6 @@ using Musify.Application.Tracks;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
using Musify.Application.Shared;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.YouTube;
|
||||
using Musify.Application.YouTube.Responses;
|
||||
using Musify.Domain.ValueObjects;
|
||||
using Musify.Api.Authentication;
|
||||
using Musify.Api.DataTransferObjects.Tracks;
|
||||
using Musify.Api.Extensions;
|
||||
@@ -22,7 +19,7 @@ public static class TrackEndpoints
|
||||
|
||||
group.MapGet("/", GetTracks)
|
||||
.WithName("GetTracks")
|
||||
.WithSummary("Get Paginated Tracks, Combined With Live YouTube Music Results When A Name Filter Is Given.")
|
||||
.WithSummary("Get Paginated Tracks, Optionally Filtered By Name.")
|
||||
.Produces<TracksSearchResponse>();
|
||||
|
||||
group.MapGet("/{id}", GetTrackById)
|
||||
@@ -44,14 +41,6 @@ public static class TrackEndpoints
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces(StatusCodes.Status404NotFound);
|
||||
|
||||
group.MapGet("/external/{source}/{externalId}/stream", GetExternalTrackStream)
|
||||
.WithName("GetExternalTrackStream")
|
||||
.WithSummary("Resolve Playback For A Track From An External Source (Currently Only YouTube Music): Server Stream If Downloaded, Direct Stream From The Source Otherwise. Works Anonymously When The Playback Configuration Allows It.")
|
||||
.Produces<YouTubeStreamResponse>()
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.Produces(StatusCodes.Status404NotFound)
|
||||
.Produces(StatusCodes.Status409Conflict);
|
||||
|
||||
group.MapGet("/users/{userId}", GetTracksByUserId)
|
||||
.WithName("GetTracksByUserId")
|
||||
.WithSummary("Get Paginated Tracks For A User.")
|
||||
@@ -96,10 +85,9 @@ public static class TrackEndpoints
|
||||
CancellationToken cancellationToken,
|
||||
string? name,
|
||||
int pageNumber = 1,
|
||||
int pageSize = 10,
|
||||
string? youtubeContinuationToken = null)
|
||||
int pageSize = 10)
|
||||
{
|
||||
var result = await mediator.Send(new GetTracksQuery(name, pageNumber, pageSize, youtubeContinuationToken), cancellationToken);
|
||||
var result = await mediator.Send(new GetTracksQuery(name, pageNumber, pageSize), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
@@ -140,20 +128,6 @@ public static class TrackEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> GetExternalTrackStream(
|
||||
IMediator mediator,
|
||||
CurrentUser currentUser,
|
||||
string source,
|
||||
string externalId,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (!Enum.TryParse<TrackSource>(source, ignoreCase: true, out var trackSource) || trackSource != TrackSource.YouTube)
|
||||
return Results.NotFound($"Unknown or unsupported source '{source}'.");
|
||||
|
||||
var result = await mediator.Send(new ResolveYouTubeTrackStreamCommand(externalId, currentUser.Id), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> GetTracksByUserId(
|
||||
IMediator mediator,
|
||||
long userId,
|
||||
|
||||
@@ -18,7 +18,6 @@ public static class ServiceCollectionExtensions
|
||||
services.AddDatabase(configuration);
|
||||
services.AddStorageService(configuration);
|
||||
services.AddStreamTicketService(configuration);
|
||||
services.AddYouTubeMusicService(configuration);
|
||||
services.AddMassTransitClient(configuration);
|
||||
services.AddAuthenticationConfiguration(configuration);
|
||||
services.AddOpenApiConfiguration();
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Musify.Api.DataTransferObjects.Likes;
|
||||
using Musify.Domain.ValueObjects;
|
||||
|
||||
namespace Musify.Api.Validators.Likes;
|
||||
|
||||
public sealed class ToggleLikeRequestValidator : AbstractValidator<ToggleLikeRequest>
|
||||
{
|
||||
public ToggleLikeRequestValidator()
|
||||
{
|
||||
RuleFor(x => x)
|
||||
.Must(x => x.TrackId.HasValue ^ (x.Source.HasValue && !string.IsNullOrEmpty(x.ExternalId)))
|
||||
.WithMessage("Provide either trackId, or source and externalId, but not both.");
|
||||
|
||||
When(x => x.Source.HasValue, () =>
|
||||
{
|
||||
RuleFor(x => x.Source)
|
||||
.Must(source => source == TrackSource.YouTube)
|
||||
.WithMessage("Unsupported source.");
|
||||
|
||||
RuleFor(x => x.ExternalId)
|
||||
.NotEmpty()
|
||||
.Matches("^[A-Za-z0-9_-]{11}$")
|
||||
.WithMessage("externalId must be a valid YouTube video id.");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Musify.Api.DataTransferObjects.PlayLists;
|
||||
using Musify.Domain.ValueObjects;
|
||||
|
||||
namespace Musify.Api.Validators.PlayLists;
|
||||
|
||||
public sealed class AddPlayListTrackRequestValidator : AbstractValidator<AddPlayListTrackRequest>
|
||||
{
|
||||
public AddPlayListTrackRequestValidator()
|
||||
{
|
||||
RuleFor(x => x)
|
||||
.Must(x => x.TrackId.HasValue ^ (x.Source.HasValue && !string.IsNullOrEmpty(x.ExternalId)))
|
||||
.WithMessage("Provide either trackId, or source and externalId, but not both.");
|
||||
|
||||
When(x => x.Source.HasValue, () =>
|
||||
{
|
||||
RuleFor(x => x.Source)
|
||||
.Must(source => source == TrackSource.YouTube)
|
||||
.WithMessage("Unsupported source.");
|
||||
|
||||
RuleFor(x => x.ExternalId)
|
||||
.NotEmpty()
|
||||
.Matches("^[A-Za-z0-9_-]{11}$")
|
||||
.WithMessage("externalId must be a valid YouTube video id.");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,6 @@
|
||||
"OpenTelemetry": {
|
||||
"OtlpEndpoint": "http://localhost:4317"
|
||||
},
|
||||
"YouTube": {
|
||||
"GeographicalLocation": "ES"
|
||||
},
|
||||
"InfrastructureStorage": {
|
||||
"Address": "http://localhost:8333",
|
||||
"AccessKey": "admin_access_key",
|
||||
|
||||
@@ -26,14 +26,8 @@
|
||||
"ApplicationStorage": {
|
||||
"Bucket": ""
|
||||
},
|
||||
"YouTube": {
|
||||
"Enabled": true
|
||||
},
|
||||
"Mix": {
|
||||
"ArtistMixCount": 3,
|
||||
"ItemsPerMix": 12,
|
||||
"SeedArtistCount": 3,
|
||||
"YouTubeResultsPerSeed": 12
|
||||
"ItemsPerMix": 12
|
||||
},
|
||||
"PlayList": {
|
||||
"Routes": {
|
||||
@@ -83,12 +77,6 @@
|
||||
},
|
||||
"TranscodingTimeout": "00:05:00"
|
||||
},
|
||||
"YtDlp": {
|
||||
"ExecutableName": "yt-dlp",
|
||||
"Format": "bestaudio",
|
||||
"AdditionalArguments": "",
|
||||
"DownloadTimeout": "00:05:00"
|
||||
},
|
||||
"Workers": {
|
||||
"Routes": {
|
||||
"TemporaryFilesDirectory": ""
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Hangfire;
|
||||
using Musify.Application.Configuration;
|
||||
using Musify.Application.Services;
|
||||
using Musify.Infrastructure.Jobs;
|
||||
using Musify.Infrastructure.MassTransit;
|
||||
using Musify.Infrastructure.Persistence;
|
||||
@@ -29,7 +28,6 @@ services.AddValidatedOptions<TrackConfiguration>(configuration, TrackConfigurati
|
||||
services.AddValidatedOptions<MixConfiguration>(configuration, MixConfiguration.SectionName);
|
||||
services.AddStorageService(configuration);
|
||||
services.AddAudioTranscoder(configuration);
|
||||
services.AddYouTubeDownloader(configuration);
|
||||
services.AddHttpClient();
|
||||
services.AddPictureService(configuration);
|
||||
services.AddPlayListPresetSeeder(configuration);
|
||||
@@ -37,8 +35,6 @@ services.AddDatabase(configuration);
|
||||
services.AddMassTransitConsumers(configuration);
|
||||
services.AddUploadIntentJobs(configuration);
|
||||
services.AddMediator();
|
||||
services.AddScoped<YouTubeTrackProvisioner>();
|
||||
services.AddYouTubeMusicService(configuration);
|
||||
services.AddDailyMixGenerationJob(configuration);
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
Reference in New Issue
Block a user