public void GetArtist(WebData webData, long artistID) { var result = RPCArtist.Load(mdb, mdb.Artists.TryGetStruct(artistID)); webData.Result.AddMessage(webData.Method, "Retrieved Artist."); webData.Result.AddStruct(result); }
public void GetArtistsWithoutImage(WebData webData, MDBImageType imageType = 0) { var artists = mdb.Artists.GetStructs(); var missing = new List <RPCArtist>(); foreach (var artist in artists) { var search = Search.FieldEquals(nameof(MDBImage.MusicBrainzGuid), artist.MusicBrainzArtistGuid); if (imageType != 0) { search &= Search.FieldEquals(nameof(MDBImage.Type), imageType); } if (!mdb.Images.Exist(search)) { missing.Add(RPCArtist.Load(mdb, artist)); } } webData.Result.AddMessage(webData.Method, "Retrieved artist datasets with missing imagetype {0}...", imageType); webData.Result.AddStructs(missing); }
public void GetAlbumsWithErrorsList(WebData webData) { var audioFiles = mdb.AudioFiles.GetStructs(Search.FieldNotEquals(nameof(MDBAudioFile.MetaErrors), 0)); var albumErrors = new Dictionary <long, MDBMetaErrors>(); foreach (var audioFile in audioFiles) { albumErrors.TryGetValue(audioFile.AlbumID, out MDBMetaErrors errors); errors |= audioFile.MetaErrors; albumErrors[audioFile.AlbumID] = errors; } var albums = mdb.Albums.GetStructs( Search.FieldIn(nameof(MDBAlbum.ID), albumErrors.Keys) | Search.FieldEquals(nameof(MDBAlbum.MusicBrainzAlbumGuid), null) | Search.FieldEquals(nameof(MDBAlbum.MusicBrainzReleaseGroupGuid), null) ); foreach (var album in albums) { albumErrors.TryGetValue(album.ID, out MDBMetaErrors errors); if (album.MusicBrainzAlbumGuid == null) { errors |= MDBMetaErrors.MusicBrainzAlbum; } if (album.MusicBrainzReleaseGroupGuid == null) { errors |= MDBMetaErrors.MusicBrainzReleaseGroup; } albumErrors[album.ID] = errors; } var artists = mdb.Artists.GetStructs(albums.Select(a => a.ArtistID)); webData.Result.AddMessage(webData.Method, "Retrieved albums with errors datasets..."); webData.Result.AddStructs(albums.Select(a => RPCAlbum.Load(mdb, a))); webData.Result.AddStructs(artists.Select(a => RPCArtist.Load(mdb, a))); }
public void SearchArtists(WebData webData, string filter = null, int page = 0, long categoryID = 0, long genreID = 0, long tagID = 0, string genre = null, string tag = null) { ICollection <long> artistIDs = null; //select audio files if (genreID != 0 || categoryID != 0 || tagID != 0 || genre != null || tag != null) { Search s = Search.None; if (genreID != 0) { s &= Search.FieldEquals(nameof(MDBAudioFile.GenreID), genreID); } if (tagID != 0) { s &= Search.FieldEquals(nameof(MDBAudioFile.TagID), tagID); } if (genre != null) { s &= Search.FieldLike(nameof(MDBAudioFile.Genres), MDBSearch.Text("%" + genre + "%")); } if (tag != null) { s &= Search.FieldLike(nameof(MDBAudioFile.Tags), MDBSearch.Text("%" + tag + "%")); } if (categoryID > 0) { s &= GetCategorySearch(categoryID); } int fieldIndex = mdb.AudioFiles.Layout.GetFieldIndex(nameof(MDBAudioFile.SongArtistID)); artistIDs = mdb.AudioFiles.GetRows(s).Select(r => (long)r.GetValue(fieldIndex)).ToList(); } //select artists IList <MDBArtist> artists; long rowCount; { Search search = Search.None; if (filter != null) { search &= Search.FieldLike(nameof(MDBArtist.Name), MDBSearch.Text("%" + filter + "%")); } if (artistIDs != null) { search &= Search.FieldIn(nameof(MDBArtist.ID), artistIDs); } if (search.Mode == SearchMode.None) { rowCount = mdb.Artists.RowCount; } else { rowCount = mdb.Artists.Count(search); } artists = mdb.Artists.GetStructs(search, ResultOption.SortAscending(nameof(MDBArtist.Name)) + ResultOption.Offset(page * RowsPerPage) + ResultOption.Limit(RowsPerPage)); } var result = artists.Select(i => RPCArtist.Load(mdb, i)); webData.Result.AddMessage(webData.Method, "Retrieved Artists with filter."); AddPagination(webData, page, rowCount); webData.Result.AddStructs(result); }