/// <summary> /// Load artist intro for a specific artist. /// </summary> /// <param name="elem"></param> /// <returns></returns> public static async Task <DbArtist> LoadArtistIntroAsync(this DbArtist elem) { if (InternetConnectivityDetector.HasInternetConnection) { try { var bio = await GrooveMusicMetadata.GetArtistBio(elem.Name); elem.Intro = bio; } catch (Exception ex) { TelemetryHelper.TrackExceptionAsync(ex); } } return(elem); }
/// <summary> /// Load online content for a specific artist. /// </summary> /// <param name="elem"></param> /// <returns></returns> public static async Task <string> LoadArtistOnlineContentAsync(this DbArtist elem) { // Check internet connection if (InternetConnectivityDetector.HasInternetConnection) { // Return Online content try { var modifyFlag = false; if (string.IsNullOrEmpty(elem.Intro)) { var bio = await GrooveMusicMetadata.GetArtistBio(elem.Name); if (!string.IsNullOrEmpty(bio)) { modifyFlag = true; } } if (modifyFlag) { using (var scope = ApplicationServiceBase.App.GetScope()) using (var context = scope.ServiceProvider.GetRequiredService <MedialibraryDbContext>()) { context.Entry(elem).Entity.ImagePath = elem.ImagePath; context.Entry(elem).Entity.Intro = elem.Intro; context.Entry(elem).State = EntityState.Modified; await context.SaveChangesAsync(); } return(elem.ImagePath); } } catch (Exception ex) { TelemetryHelper.TrackExceptionAsync(ex); } } return(string.Empty); }