//MUSIC OBJECT BUILDER public static PlexMusic GetMusicObjectFromIndex(int index, bool waitWindow = true) { try { if (waitWindow) { return((PlexMusic)WaitWindow.WaitWindow.Show(GetMusicObjectFromIndex_Callback, @"Getting metadata", index)); } var obj = new PlexMusic(); LoggingHelpers.RecordGeneralEntry(@"Content Parse Started"); LoggingHelpers.RecordGeneralEntry(@"Grabbing Titles"); var metadata = XmlMetadataContent.GetTrackMetadata(index); LoggingHelpers.RecordGeneralEntry(@"Checking XML validity"); if (Methods.PlexXmlValid(metadata.Xml)) { LoggingHelpers.RecordGeneralEntry(@"XML Valid"); //UIMessages.Info(ObjectProvider.CurrentContentType.ToString()); var dlInfo = DownloadInfoGatherers.GetContentDownloadInfo(metadata.Xml); if (dlInfo != null) { LoggingHelpers.RecordGeneralEntry(@"Assembling Object"); obj.ApiUri = metadata.ApiUri; obj.ContentGenre = XmlMetadataStrings.GetContentGenre(metadata.Xml); obj.StreamInformation = dlInfo; obj.StreamResolution = new Resolution(); //audio doesn't have video-type resolution obj.Actors = new List <PlexActor>(); //Plex audio does not contain the "<Role>" tag obj.StreamIndex = index; obj.Album = XmlMetadataStrings.GetParentTitle(metadata.Xml); obj.Artist = XmlMetadataStrings.GetGrandparentTitle(metadata.Xml); obj.Synopsis = "Auditory Content"; //Plex audio does not contain the "summary" attribute //apply the raw metadata to the object (it won't get serialised) obj.RawMetadata = metadata.Xml; } else { UIMessages.Error( @"Failed to get contextual information; an unknown error occurred. Check the exception log for more information.", @"Data Error"); LoggingHelpers.RecordException( @"DownloadInfo invalid. This may be an internal error; please report this issue on GitHub.", @"ContextDownloadInfoNull"); LoggingHelpers.RecordGeneralEntry("DownloadInfo is invalid (no stream contextual information)"); } } else { LoggingHelpers.RecordGeneralEntry("XML Invalid"); } LoggingHelpers.RecordGeneralEntry("Returned assembled Music object"); return(obj); } catch (ThreadAbortException) { //literally nothing; this gets raised when a cancellation happens. return(null); } catch (Exception ex) { UIMessages.Error("Content metadata error:\n\n" + ex, @"Data Error"); LoggingHelpers.RecordException(ex.Message, @"MusicObjectError"); return(null); } }