Esempio n. 1
0
        /// <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) { }

            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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public async Task <List <TvShow> > getTracker()
        {
            if (!hasInternet() && tracker != null)
            {
                return(tracker);
            }
            tracker = new List <TvShow>();

            Response resp = await(new Response("http://followshows.com/viewStyleTracker?viewStyle=expanded")).call();

            if (resp.somethingWentWrong)
            {
                return(tracker);
            }

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(resp.page);

            HtmlNode tbody = doc.GetElementbyId("tracker");
            HtmlNode head  = HTML.getChild(tbody);

            if (head == null)
            {
                return(tracker);
            }

            foreach (HtmlNode tvshow in head.ChildNodes)
            {
                try
                {
                    TvShow   show  = new TvShow(true);
                    HtmlNode title = HTML.getChild(tvshow);
                    show.Name  = System.Net.WebUtility.HtmlDecode(title.InnerText);
                    show.Image = new BitmapImage()
                    {
                        UriSource = new Uri(HTML.getAttribute(title.ChildNodes, "src"))
                    };
                    show.showUrl      = HTML.getAttribute(title.ChildNodes, "href").Replace("/show/", "");
                    show.stillToWatch = HTML.getChild(tvshow.ChildNodes, "class", "towatch").InnerHtml;
                    string perc = HTML.getChild(tvshow.ChildNodes, "role", "progressbar").InnerText.Replace("%", "");
                    show.percentageWatched = float.Parse(perc) / 100 * 150;
                    tracker.Add(show);
                }
                catch (Exception)
                {
                }
            }
            return(tracker);
        }
Esempio n. 4
0
        /// <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);

            HtmlNode netDate = HTML.getChild(node);

            res.network = HTML.getAttribute(netDate.ChildNodes, "network");

            HtmlNode posterNode = HTML.getChild(node, "class", "column_poster");

            BitmapImage bitmapImage = new BitmapImage();

            bitmapImage.UriSource     = new Uri(HTML.getAttribute(HTML.getChild(HTML.getChild(posterNode)), "src").Replace("180", "360").Replace("104", "207"));
            bitmapImage.CreateOptions = BitmapCreateOptions.None;
            res.Image = bitmapImage;

            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, 1);

            split       = dateNode.InnerText.Split(' ');
            res.airdate = DateTime.Parse(split[0]);

            res.summary = HTML.getChild(locDateSum, 2).InnerText;

            res.id = HTML.getAttribute(node.ChildNodes, "episodeid");

            return(res);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public async Task <List <Episode> > getCalendar()
        {
            calendar = new List <Episode>();

            string url = "http://followshows.com/api/calendar?date="
                         + (DateTime.UtcNow.Date.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds.ToString()
                         + "&days=14";

            Response resp = await(new Response(url)).call();

            HtmlDocument doc = new HtmlDocument();

            if (resp.page == null)
            {
                return(calendar);
            }
            doc.LoadHtml(resp.page);

            HtmlNode table    = HTML.getChild(doc.DocumentNode, "class", "calendar");
            HtmlNode tableRow = HTML.getChild(table, 1);

            bool check = false;

            foreach (HtmlNode day in tableRow.ChildNodes)
            {
                if (!HTML.getAttribute(day, "class").Contains("today") && check == false)
                {
                    continue;
                }
                check = true;

                HtmlNode ul = HTML.getChild(day);
                if (ul != null)
                {
                    foreach (HtmlNode li in ul.ChildNodes)
                    {
                        calendar.Add(Episode.getCalendarEpisode(li));
                    }
                }
            }

            return(calendar);
        }