public override async Task <bool> UpdateFromOnlineMusicTrackAlbumCompanyAsync(AlbumInfo album, CompanyInfo company, string language, bool cacheOnly) { try { TrackLabel labelDetail = null; if (!string.IsNullOrEmpty(company.MusicBrainzId)) { labelDetail = await _musicBrainzHandler.GetLabelAsync(company.MusicBrainzId, cacheOnly).ConfigureAwait(false); } if (labelDetail == null) { return(false); } if (labelDetail.Label == null) { return(false); } company.MusicBrainzId = labelDetail.Label.Id; company.Name = labelDetail.Label.Name; company.Type = CompanyAspect.COMPANY_MUSIC_LABEL; return(true); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Debug("MusicBrainzWrapper: Exception while processing company {0}", ex, company.ToString()); return(false); } }
public static void GetTrackNames(TrackLabel currentTrack, TrackLabel previousTrack, ref string currentTrackName, ref string previousTrackName) { try { // Get the HTML document nodes here var doc = new HtmlWeb().Load(parseAddress); var nodes = doc.DocumentNode.Descendants("div") .Where(div => div.GetAttributeValue("id", "") == "playlist_tracklist").ToList(); // Get the current track names here from Serato Live string[] currentTracks = new string[2]; currentTracks[0] = GetTrackName(0, nodes); currentTracks[1] = GetTrackName(1, nodes); // Check here to see if there was an update in either of the track names if ((currentTracks[0] != currentTrackName) || currentTracks[1] != previousTrackName) { // Check to see if we need to write the new track names here if (currentTracks[0] != currentTrackName) { WriteLabelFiles(currentTrack, currentTracks[0]); currentTrackName = currentTracks[0]; } // Only write the previous track if wee have the setting enables and the name is different if ((previousTrack != null) && currentTracks[1] != previousTrackName) { WriteLabelFiles(previousTrack, currentTracks[1]); previousTrackName = currentTracks[1]; } } } catch { } }
static void WriteLabelFiles(TrackLabel trackLabel, string labelValue) { // If the file doesn't exist, create it if (!File.Exists(trackLabel.LabelLocation)) { File.Create(trackLabel.LabelLocation); } // Write the data to the label file here using (var writer = new StreamWriter(trackLabel.LabelLocation)) { var output = String.Empty; if (!String.IsNullOrEmpty(trackLabel.LabelPrefix)) { output += $"{trackLabel.LabelPrefix} "; } output += $" {labelValue} "; if (!String.IsNullOrEmpty(trackLabel.LabelSuffix)) { output += $" {trackLabel.LabelSuffix}"; } writer.WriteLine(output); writer.Close(); } }
static void WorkerThreadMethod() { // Build the track objects here TrackLabel currentTrack = new TrackLabel { LabelLocation = currentTrackLabel }; Console.WriteLine("Application is Running . . . Close to Stop"); while (true) { FileController.ReadHtml(currentTrack, null); Thread.Sleep(parseTime); } }
void WorkerThreadMethod() { // Build the track objects here TrackLabel currentTrack = new TrackLabel { LabelLocation = TxtBxCurrentTrack.Text, LabelPrefix = ChkBxCurrentPrefix.Checked ? !String.IsNullOrEmpty(TxtBxCurrentPrefix.Text) ? TxtBxCurrentPrefix.Text : String.Empty : String.Empty, LabelSuffix = ChkBxCurrentSuffix.Checked ? !String.IsNullOrEmpty(TxtBxCurrentSuffix.Text) ? TxtBxCurrentSuffix.Text : String.Empty : String.Empty }; TrackLabel previousTrack = null; if (ChkBxPreviousTrack.Checked) { previousTrack = new TrackLabel { LabelLocation = TxtBxPreviousTrack.Text, LabelPrefix = ChkBxPreviousPrefix.Checked ? !String.IsNullOrEmpty(TxtBxPreviousPrefix.Text) ? TxtBxPreviousPrefix.Text : String.Empty : String.Empty, LabelSuffix = ChkBxPreviousSuffix.Checked ? !String.IsNullOrEmpty(TxtBxPreviousSuffix.Text) ? TxtBxPreviousSuffix.Text : String.Empty : String.Empty } } ; while (true) { FileController.ReadHtml(currentTrack, previousTrack); Thread.Sleep((int)NudPareTime.Value * 1000); } } }
public static void ReadHtml(TrackLabel currentTrack, TrackLabel previousTrack) => FileHelper.GetTrackNames(currentTrack, previousTrack, ref currentTrackValue, ref previousTrackValue);