private async void Item_Tapped(object sender, DoubleTappedRoutedEventArgs e) { item = sender as Grid; ep = item.DataContext as Episode; Image ima = item.FindName("ima") as Image; if (ima.Opacity > 0.5) { if (!ep.Aired) { Helper.message("This episode hasn't aired yet. You cannot mark it as watched", "EPISODE NOT AIRED"); return; } if (await api.hasInternet()) { await ep.markAsWatched(); await Memory.storeMostRecentQueueEpisode(q); } else { Memory.addCommand(new Command() { episode = ep, watched = true }); } DoubleAnimation ani = new DoubleAnimation(); Storyboard.SetTarget(ani, ima); Storyboard board = new Storyboard(); board.Completed += board_Completed; Storyboard.SetTargetProperty(ani, "Opacity"); ani.To = 0.2; ep.Opacity = 0.2; board.Duration = new Duration(TimeSpan.FromSeconds(1)); board.Children.Add(ani); ep.Seen = true; board.Begin(); ep.OnPropertyChanged("redo"); } else { item = sender as Grid; ep = item.DataContext as Episode; DoubleAnimation ani = new DoubleAnimation(); Storyboard.SetTarget(ani, ima); Storyboard board = new Storyboard(); Storyboard.SetTargetProperty(ani, "Opacity"); ani.To = 0.9; board.Duration = new Duration(TimeSpan.FromSeconds(1)); board.Children.Add(ani); board.Begin(); ep.Seen = false; ep.OnPropertyChanged("redo"); ep.OnPropertyChanged("Opacity"); if (await api.hasInternet()) { await ep.markNotAsWatched(); } else { Command com = new Command(); com.episode = ep; com.watched = false; Memory.addCommand(com); } } //Update the last new queue item await Memory.storeMostRecentQueueEpisode((queue.ItemsSource as Queue)); }
public async Task<List<Episode>> getSeason(TvShow show, int seasonNr) { List<Episode> season = new List<Episode>(); Response resp = await (new Response("http://followshows.com/api/show/" + show.showUrl + "/season/" + seasonNr, false)).call(); if (resp.somethingWentWrong) return season; foreach (HtmlNode episode in HTML.getChild(resp.firstNode.ChildNodes, "class", "clearfix").ChildNodes) { Episode ep = new Episode(false, false); ep.ShowName = show.Name; HtmlNode name = HTML.getChild(episode.ChildNodes, "class", "episode-link"); if (name != null) { ep.Aired = true; ep.EpisodeName = name.InnerText; ep.Image = new BitmapImage(new Uri(HTML.getAttribute(HTML.getChild(episode.ChildNodes, "class", "poster").ChildNodes, "src").Replace("130x75", "360x207"))); string[] build = HTML.getChild(episode.ChildNodes, "class", "episode-label").InnerText.Split(new char[] { ' ' }); ep.ISeason = int.Parse(build[1]); ep.IEpisode = int.Parse(build[3].Split(new char[] { ',' })[0]); ep.EpisodePos = "S" + ep.ISeason + "E" + ep.IEpisode; ep.id = HTML.getAttribute(episode.ChildNodes, "episodeid"); if (!episode.InnerText.Contains("Mark as watched")) { ep.Seen = true; } } else { ep.Aired = false; ep.Image = new BitmapImage(new Uri("ms-appx:Assets/basicQueueItem.png")); string[] build = episode.InnerText.Split(new char[] { ',' }); ep.EpisodeName = build[0]; string[] seasonThing = build[1].Split(new char[] { ' ' }); ep.ISeason = int.Parse(seasonThing[1]); ep.IEpisode = int.Parse(seasonThing[3]); ep.EpisodePos = "S" + ep.ISeason + "E" + ep.IEpisode; } season.Add(ep); } return season; }
/// <summary> /// Converts Html to a Episode object /// DONT LOOK AT ME, I AM UGLY /// </summary> /// <param name="li"></param> /// <returns></returns> public static Episode getCalendarEpisode(HtmlNode li) { HtmlNode a = HTML.getChild(li); Episode ep = new Episode(false, false); ep.ShowName = HTML.getAttribute(a, "data-show"); ep.network = HTML.getChild(a.ChildNodes, "class", "network").InnerText; ep.Image = new BitmapImage(new Uri(Regex.Match(HTML.getAttribute(HTML.getChild(a, "class", "poster"), "style"), @"(?<=\().+(?!\))").ToString().Replace(@");", ""))); //Season Position and episode url HtmlDocument data = new HtmlDocument(); data.LoadHtml(HTML.getAttribute(a, "data-content")); ep.EpisodeName = HTML.getChild(HTML.getChild(data.DocumentNode)).InnerText; string air = HTML.getChild(data.DocumentNode, 1).InnerText.Replace("Airs on ", "").Replace(", on " + ep.network + " at ", " "); try { ep.airtime = DateTime.Parse(air); ep.airdate = DateTime.Parse(air).Date; } catch (Exception e) { Memory.writeErrorToFile("getCalendarEpisode", e).RunSynchronously(); } ep.url = HTML.getAttribute(HTML.getChild(HTML.getChild(data.DocumentNode, 2)), "href"); string[] build = HTML.getChild(HTML.getChild(data.DocumentNode, 2)).InnerText.Split(' '); ep.ISeason = int.Parse(build[1]); ep.IEpisode = int.Parse(build[3]); ep.EpisodePos = "S" + build[1] + "E" + build[3].Replace(":", ""); return ep; }
public static Episode getWatchListEpisode(HtmlNode episode) { Episode res = new Episode(true, false); res.ShowName = HTML.getChild(episode.ChildNodes, "class", "title").InnerText; res.id = HTML.getAttribute(episode.ChildNodes, "episodeId"); HtmlNode Ename = HTML.getChild(episode.ChildNodes, "class", "subtitle"); res.EpisodeName = HTML.getChild(Ename).InnerText; res.Image = new BitmapImage(new Uri(HTML.getAttribute(episode.ChildNodes, "style").Replace("background-image: url(", "").Replace(");", ""))); string[] build = HTML.getChild(episode.ChildNodes, "class", "description").InnerText.Split(new char[] { ' ' }); res.ISeason = int.Parse(build[1]); res.IEpisode = int.Parse(build[3].Replace(".", "")); res.EpisodePos = "Season " + res.ISeason + " Episode " + res.IEpisode; return res; }
/// <summary> /// Converts Html to a Episode object /// </summary> /// <param name="node"></param> /// <returns></returns> public static Episode getQueueEpisode(HtmlNode node) { Episode res = new Episode(true, false); if (HTML.getChild(node.ChildNodes, "class", "label label-warning") != null) { res.New = true; } HtmlNode netDate = HTML.getChild(node); res.network = HTML.getAttribute(netDate.ChildNodes, "network"); HtmlNode posterNode = HTML.getChild(node, "class", "column_poster"); res.imageUrl = HTML.getAttribute(posterNode.ChildNodes, "src").Replace("180", "360").Replace("104", "207"); try { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.UriSource = new Uri(res.imageUrl); bitmapImage.CreateOptions = BitmapCreateOptions.None; //await bitmapImage.SetSourceAsync(await RandomAccessStreamReference.CreateFromUri(new Uri(res.imageUrl)).OpenReadAsync()); res.Image = bitmapImage; } catch { } HtmlNode rest = HTML.getChild(node.ChildNodes, "class", "column_infos"); HtmlNode one = HTML.getChild(rest, "class", "title "); HtmlNode two = HTML.getChild(one); res.url = HTML.getAttribute(two, "href"); res.ShowName = HTML.getChild(rest, "class", "title ").InnerText; HtmlNode locDateSum = HTML.getChild(rest, "class", "infos"); string entire = HTML.getChild(locDateSum).InnerText; string[] split = entire.Split(':'); string[] seasonEps = split[0].Replace("Season ", "").Replace("Episode ", "").Split(' '); res.ISeason = int.Parse(seasonEps[0]); res.IEpisode = int.Parse(seasonEps[1]); res.EpisodePos = "S" + res.ISeason + "E" + res.IEpisode; res.EpisodeName = split[1].Remove(0,1); HtmlNode dateNode = HTML.getChild(locDateSum.ChildNodes, "class", "visible-xs visible-sm xs-infos"); split = dateNode.InnerText.Split(' '); try { res.airdate = DateTime.Parse(split[0]); } catch { } res.summary = HTML.getChild(locDateSum, 2).InnerText; res.id = HTML.getAttribute(node.ChildNodes, "episodeid"); return res; }