Design Prot Merge #1
+2
-2
@@ -43,10 +43,10 @@ namespace Musify.Infrastructure.MassTransit.Activities.Audio
|
|||||||
|
|
||||||
if (downloadResult.ExitCode != 0)
|
if (downloadResult.ExitCode != 0)
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"yt-dlp failed with exit code {downloadResult.ExitCode}: {downloadResult.StandardError}");
|
$"YouTube audio download failed: {downloadResult.StandardError}");
|
||||||
|
|
||||||
if (!File.Exists(destinationPath))
|
if (!File.Exists(destinationPath))
|
||||||
throw new InvalidOperationException($"yt-dlp did not produce the expected file {destinationPath}.");
|
throw new InvalidOperationException($"YouTube audio download did not produce the expected file {destinationPath}.");
|
||||||
|
|
||||||
logger.LogInformation("Downloaded YouTube audio for video {VideoId} to {DestinationPath}",
|
logger.LogInformation("Downloaded YouTube audio for video {VideoId} to {DestinationPath}",
|
||||||
executeContext.Arguments.VideoId, destinationPath);
|
executeContext.Arguments.VideoId, destinationPath);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using ErrorOr;
|
using ErrorOr;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Musify.Application.Contracts;
|
using Musify.Application.Contracts;
|
||||||
using Musify.Infrastructure.Configuration;
|
using Musify.Infrastructure.Configuration;
|
||||||
using YouTubeMusicAPI.Client;
|
using YouTubeMusicAPI.Client;
|
||||||
@@ -9,7 +10,7 @@ using YouTubeMusicAPI.Pagination;
|
|||||||
|
|
||||||
namespace Musify.Infrastructure.Services
|
namespace Musify.Infrastructure.Services
|
||||||
{
|
{
|
||||||
public class YouTubeMusicService(YouTubeConfiguration configuration, IMemoryCache cache) : IYouTubeMusicService
|
public class YouTubeMusicService(YouTubeConfiguration configuration, IMemoryCache cache, ILogger<YouTubeMusicService> logger) : IYouTubeMusicService
|
||||||
{
|
{
|
||||||
private readonly YouTubeMusicClient client = new(geographicalLocation: configuration.GeographicalLocation);
|
private readonly YouTubeMusicClient client = new(geographicalLocation: configuration.GeographicalLocation);
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ namespace Musify.Infrastructure.Services
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
logger.LogError(exception, "YouTube Music search failed for query '{Query}'", query);
|
||||||
return Error.Failure(description: $"YouTube Music search failed: {exception.Message}");
|
return Error.Failure(description: $"YouTube Music search failed: {exception.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +89,7 @@ namespace Musify.Infrastructure.Services
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
logger.LogError(exception, "Failed to resolve YouTube stream for '{VideoId}'", videoId);
|
||||||
return Error.Failure(description: $"Failed to resolve YouTube stream for '{videoId}': {exception.Message}");
|
return Error.Failure(description: $"Failed to resolve YouTube stream for '{videoId}': {exception.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +141,7 @@ namespace Musify.Infrastructure.Services
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
logger.LogError(exception, "Failed to load YouTube song info for '{VideoId}'", videoId);
|
||||||
return Error.Failure(description: $"Failed to load YouTube song info for '{videoId}': {exception.Message}");
|
return Error.Failure(description: $"Failed to load YouTube song info for '{videoId}': {exception.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user