public RecognizeEpisodeWizardWindow(BaseTarget target, XEpisode episode) { this.ViewModel = new RecognizeEpisodeViewModel(target, episode, this) { RecognizeStateChanged = (st) => { SetCurrentPage(st); }, }; InitializeComponent(); }
public RecognizeEpisodeViewModel(BaseTarget target, XEpisode episode, Window view) { this.Target = target; this.Episode = episode; this.Window = view; this.Window.Closing += Window_Closing; this.Window.DataContext = this; this.AudioPlayer = new MediaAudioPlayer(); this.AudioPlayer.Load(this.LocalEpisode.AudioFilePath); BuildWorkflowApp(); if (this.Window.IsLoaded == true) { Init(); } else { this.Window.Loaded += ParentWindow_Loaded; } }
public override IEnumerable <XEpisode> GetEpisodes(XPage page) { DateTime newDT = DateTime.MinValue; var html = BaseTarget.SaveAndReturn(page.URL, Path.Combine(this.GetAlbumFolderPath(page.AlbumID), page.Index.ToString() + ".html"), this.Encoding); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(html); var listNode = htmlDoc.GetElementbyId("list"); if (listNode == null) { listNode = htmlDoc.DocumentNode.SelectSingleNode(@"//div[@class='list']"); } if (listNode != null) { var liCollection = listNode.SelectNodes("ul/li"); foreach (HtmlNode li in liCollection) { //process episode title,date,contentUrl var a = li.Element("a"); var episodeUrl = new Uri(this.CurrentXTarget.URL, a.Attributes["href"].Value); var id = Path.GetFileNameWithoutExtension(episodeUrl.ToString()); #region Find and Check Date DateTime date = DateTime.MinValue; var match = GetRegexResult("\\d+-\\d+-\\d+", li.InnerHtml); var dateString = match.Value.Trim(); var array = dateString.Split('-'); int year = int.Parse(array[0]); int month = int.Parse(array[1]); int day = int.Parse(array[2]); if (year < 2000) { year += 2000; } //Only Return Episodes these after 2012 if (year < FromYear) { break; } if (VOAUtilities.ChackEpisodeDate(page.AlbumID, year, month, day, out date) == true) { date = new DateTime(year, month, day); } else { date = new DateTime(year, month, day); } #endregion var newEpisode = new XEpisode(page.AlbumID, id, a.InnerText.Trim(), episodeUrl) { Date = date }; //process hasLrc,hasTranslation var images = li.Elements("img"); foreach (HtmlNode image in images) { var imgText = image.Attributes["src"].Value; if (imgText.Contains("lrc.gif") == true) { newEpisode.HasLrc = true; } if (imgText.Contains("yi.gif") == true) { newEpisode.HasTranslation = true; } } newEpisode = this.CheckEpisode(newEpisode); yield return(newEpisode); } } }