Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
362 changes: 362 additions & 0 deletions docs/HYBRID_YOUTUBE_IMPLEMENTATION.md

Large diffs are not rendered by default.

396 changes: 396 additions & 0 deletions docs/YOUTUBE_INTEGRATION_DESIGN_OPTIONS.md

Large diffs are not rendered by default.

35 changes: 30 additions & 5 deletions src/Muine.App/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,15 @@ public MainWindowViewModel()
_mprisService.PreviousRequested += (s, e) => _ = PlayPreviousCommand.ExecuteAsync(null);

// Initialize view models
MusicLibraryViewModel = new MusicLibraryViewModel(_databaseService);
MusicLibraryViewModel = new MusicLibraryViewModel(_databaseService, _youtubeService, _taggingQueue, managedLibraryService, _metadataService);
PlaylistViewModel = new PlaylistViewModel();
RadioViewModel = new RadioViewModel(_radioStationService, _radioMetadataService, _radioBrowserService);
YouTubeSearchViewModel = new YouTubeSearchViewModel(_youtubeService, _databaseService, _taggingQueue, managedLibraryService, _metadataService);

// Subscribe to library events
MusicLibraryViewModel.SongsAddedToLibrary += OnYouTubeSongsAddedToLibrary;
MusicLibraryViewModel.YouTubeSongNeedsMetadataReview += OnYouTubeSongNeedsMetadataReview;

// Subscribe to YouTube events
YouTubeSearchViewModel.SongsAddedToLibrary += OnYouTubeSongsAddedToLibrary;
YouTubeSearchViewModel.YouTubeSongNeedsMetadataReview += OnYouTubeSongNeedsMetadataReview;
Expand Down Expand Up @@ -781,13 +785,29 @@ private void OnYouTubeSongNeedsMetadataReview(object? sender, YouTubeSongEventAr
{
// Download happens here, AFTER user has selected metadata
// This provides responsive UI - user sees results immediately
await YouTubeSearchViewModel!.CompleteYouTubeImportAsync(e.Song, e.YouTubeId);
// Determine which ViewModel triggered the event
if (sender == MusicLibraryViewModel)
{
await MusicLibraryViewModel!.CompleteYouTubeImportAsync(e.Song, e.YouTubeId);
}
else if (sender == YouTubeSearchViewModel)
{
await YouTubeSearchViewModel!.CompleteYouTubeImportAsync(e.Song, e.YouTubeId);
}
}
else
{
// User skipped - no download needed, nothing to clean up
YouTubeSearchViewModel!.StatusMessage = "Import cancelled";
YouTubeSearchViewModel.IsSearching = false;
if (sender == MusicLibraryViewModel)
{
MusicLibraryViewModel!.YoutubeStatusMessage = "Import cancelled";
MusicLibraryViewModel.IsYouTubeSearching = false;
}
else if (sender == YouTubeSearchViewModel)
{
YouTubeSearchViewModel!.StatusMessage = "Import cancelled";
YouTubeSearchViewModel.IsSearching = false;
}
}
}
}
Expand All @@ -797,7 +817,12 @@ private void OnYouTubeSongNeedsMetadataReview(object? sender, YouTubeSongEventAr
LoggingService.Error("Failed to open metadata review dialog for YouTube song", ex, "MainWindowViewModel");
StatusMessage = "Error reviewing YouTube song metadata";

if (YouTubeSearchViewModel != null)
// Reset searching state based on sender
if (sender == MusicLibraryViewModel && MusicLibraryViewModel != null)
{
MusicLibraryViewModel.IsYouTubeSearching = false;
}
else if (sender == YouTubeSearchViewModel && YouTubeSearchViewModel != null)
{
YouTubeSearchViewModel.IsSearching = false;
}
Expand Down
Loading