protected void AssertArtistNameLowered(string name, string expected) { DatabaseAlbumInfo info = new DatabaseAlbumInfo(); info.ArtistName = name; Assert.AreEqual(expected, info.ArtistNameLowered); }
public void SetBook(DatabaseAlbumInfo book) { ThreadAssist.AssertInMainThread(); Book = book; title_label.Markup = String.Format( "<span size=\"x-large\" weight=\"bold\">{0}</span>\n" + "{1}", GLib.Markup.EscapeText(book.Title), GLib.Markup.EscapeText(book.ArtistName) ); var bookmark = library.GetLastPlayedBookmark(book.DbId); UpdateResumeButton(bookmark); UpdateCover(); /*var bookmarks = Bookmark.Provider.FetchAllMatching ( * "TrackID IN (SELECT TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND AlbumID = ?)", * library.DbId, book.DbId * );*/ rating_entry.Value = (int)Math.Round(ServiceManager.DbConnection.Query <double> ( "SELECT AVG(RATING) FROM CoreTracks WHERE PrimarySourceID = ? AND AlbumID = ?", library.DbId, book.DbId )); }
protected override void PruneArtistsAlbums() { ServiceManager.DbConnection.Execute(prune_artists_albums_command); base.PruneArtistsAlbums(); DatabaseAlbumInfo.Reset(); DatabaseArtistInfo.Reset(); }
protected void AssertTitleLowered(string title, string expected) { DatabaseAlbumInfo info = new DatabaseAlbumInfo(); info.Title = title; Assert.AreEqual(expected, info.TitleLowered); }
protected void AssertArtistNameSort(string name, string name_sort, byte[] expected) { DatabaseAlbumInfo info = new DatabaseAlbumInfo(); info.ArtistName = name; info.ArtistNameSort = name_sort; Assert.AreEqual(expected, info.ArtistNameSortKey); }
protected void AssertTitleSort(string title, string title_sort, byte[] expected) { DatabaseAlbumInfo info = new DatabaseAlbumInfo(); info.Title = title; info.TitleSort = title_sort; Assert.AreEqual(expected, info.TitleSortKey); }
public void SwitchToBookView(DatabaseAlbumInfo book) { if (CurrentViewBook == null) { CurrentViewBook = book; book_view.SetSource(this); book_view.Contents.SetBook(book); Properties.Set <ISourceContents> ("Nereid.SourceContents", book_view); if (BooksModel.Selection.Count != 1) { var index = BooksModel.Selection.FocusedIndex; BooksModel.Selection.Clear(false); BooksModel.Selection.Select(index); } Actions.UpdateActions(); } }
/// <summary> /// Checks if we are in PartyMode & if a new song started playing /// Called from OnPlaybackControllerTrackStarted /// </summary> private void CheckForSwitch() { ThreadAssist.ProxyToMain(delegate { TrackInfo current_track = ServiceManager.PlaybackController.CurrentTrack; if (current_track != null && transitioned_track != current_track) { if (IsActiveSource) { FilterView.LabelTrack.SetValueWithAnim(current_track.TrackNumber + " - " + current_track.TrackTitle); } if (InPartyMode) { DatabaseAlbumInfo album = DatabaseAlbumInfo.FindOrCreate( DatabaseArtistInfo.FindOrCreate(current_track.AlbumArtist, current_track.AlbumArtistSort), current_track.AlbumTitle, current_track.AlbumTitleSort, current_track.IsCompilation); FilterView.ScrollTo(album); } transitioned_track = ServiceManager.PlayerEngine.CurrentTrack; } }); }
public void SwitchToBookView(DatabaseAlbumInfo book) { if (!book_label.Visible) { CurrentViewBook = book; book_label.Text = String.Format(" » {0}", book.DisplayTitle); book_label.Visible = true; book_view.SetSource(this); book_view.Contents.SetBook(book); Properties.Set <ISourceContents> ("Nereid.SourceContents", book_view); if (BooksModel.Selection.Count != 1) { var index = BooksModel.Selection.FocusedIndex; BooksModel.Selection.Clear(false); BooksModel.Selection.Select(index); } Actions.UpdateActions(); } }
private void LoadDiscMetadata(object state) { try { LocalDisc mb_disc = (LocalDisc)state; OnMetadataQueryStarted(mb_disc); Release release = Release.Query(mb_disc).First(); if (release == null || release.Score < 100) { OnMetadataQueryFinished(false); return; } var tracks = release.GetTracks(); if (tracks.Count != Count) { OnMetadataQueryFinished(false); return; } disc_title = release.GetTitle(); int disc_number = 1; int i = 0; foreach (Disc disc in release.GetDiscs()) { i++; if (disc.Id == mb_disc.Id) { disc_number = i; } } DateTime release_date = DateTime.MaxValue; foreach (Event release_event in release.GetEvents()) { if (release_event.Date != null) { try { // Handle "YYYY" dates var date_str = release_event.Date; DateTime date = DateTime.Parse( date_str.Length > 4 ? date_str : date_str + "-01", ApplicationContext.InternalCultureInfo ); if (date < release_date) { release_date = date; } } catch { } } } DatabaseArtistInfo artist = new DatabaseArtistInfo(); var mb_artist = release.GetArtist(); artist.Name = mb_artist.GetName(); artist.NameSort = mb_artist.GetSortName(); artist.MusicBrainzId = mb_artist.Id; bool is_compilation = false; DatabaseAlbumInfo album = new DatabaseAlbumInfo(); album.Title = disc_title; album.ArtistName = artist.Name; album.MusicBrainzId = release.Id; album.ReleaseDate = release_date == DateTime.MaxValue ? DateTime.MinValue : release_date; i = 0; foreach (Track track in tracks) { AudioCdTrackInfo model_track = (AudioCdTrackInfo)this[i++]; var mb_track_artist = track.GetArtist(); model_track.MusicBrainzId = track.Id; model_track.TrackTitle = track.GetTitle(); model_track.ArtistName = mb_track_artist.GetName(); model_track.AlbumTitle = disc_title; model_track.DiscNumber = disc_number; model_track.Album = album; model_track.Artist = new DatabaseArtistInfo(); model_track.Artist.Name = model_track.ArtistName; model_track.Artist.NameSort = mb_track_artist.GetSortName(); model_track.Artist.MusicBrainzId = mb_track_artist.Id; if (release_date != DateTime.MinValue) { model_track.Year = release_date.Year; } if (!is_compilation && mb_track_artist.Id != artist.MusicBrainzId) { is_compilation = true; } } if (is_compilation) { album.IsCompilation = true; for (i = 0; i < tracks.Count; i++) { AudioCdTrackInfo model_track = (AudioCdTrackInfo)this[i]; model_track.IsCompilation = true; model_track.AlbumArtist = artist.Name; model_track.AlbumArtistSort = artist.NameSort; } } OnMetadataQueryFinished(true); } catch (Exception ex) { Log.DebugException(ex); OnMetadataQueryFinished(false); } }
private void OnMerge(object o, EventArgs a) { var discs = library.BooksModel.SelectedItems.OrderBy(d => d.Title).ToList(); var author = DatabaseArtistInfo.Provider.FetchSingle((discs[0] as DatabaseAlbumInfo).ArtistId); var dialog = new HigMessageDialog( ServiceManager.Get <GtkElementsService> ().PrimaryWindow, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.OkCancel, String.Format(Catalog.GetPluralString( "Merge the {0} selected discs into one book?", "Merge the {0} selected discs into one book?", discs.Count), discs.Count), Catalog.GetString( "This will ensure the disc numbers are all " + "set properly, and then set the author and book title for all tracks " + "on all these discs to the values below") ); var table = new SimpleTable <int> (); var author_entry = new Entry() { Text = discs[0].ArtistName }; table.AddRow(0, new Label(Catalog.GetString("Author:")) { Xalign = 0 }, author_entry ); var trimmings = new char [] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ', '-' }; var title_entry = new Entry() { Text = discs[0].Title.Trim(trimmings) }; table.AddRow(1, new Label(Catalog.GetString("Book Title:")) { Xalign = 0 }, title_entry ); dialog.LabelVBox.PackStart(table, false, false, 0); dialog.ShowAll(); var response = dialog.Run(); string title = title_entry.Text; string author_name = author_entry.Text; dialog.Destroy(); if (response == (int)Gtk.ResponseType.Ok && !String.IsNullOrEmpty(title)) { if (author_name != author.Name) { author = DatabaseArtistInfo.FindOrCreate(author_name, null); } var book = DatabaseAlbumInfo.FindOrCreate(author, title, null, false); int disc_num = 1; foreach (DatabaseAlbumInfo disc in discs) { // Update the disc num/count field for all tracks on this 'book' (actually just one disc of a book) ServiceManager.DbConnection.Execute( @"UPDATE CoreTracks SET AlbumID = ?, Disc = ?, DiscCount = ?, DateUpdatedStamp = ? WHERE PrimarySourceID = ? AND AlbumID = ?", book.DbId, disc_num++, discs.Count, DateTime.Now, library.DbId, disc.DbId ); } // Update the MetadataHash for all those tracks DatabaseTrackInfo.UpdateMetadataHash( book.Title, author.Name, String.Format("PrimarySourceId = {0} AND AlbumID = {1}", library.DbId, book.DbId) ); library.NotifyTracksChanged(); } }