public override bool AddShow(ShowBindingModel show)
        {
            string urlPath = String.Format(Constants.GetSearch, GetSlug(show.Name));

            SearchInfoRoot data = WebParser <SearchInfoRoot> .GetInfo(urlPath);

            BingeShow newShow = new BingeShow()
            {
                Id             = data.data[0].id,
                Title          = data.data[0].seriesName,
                CurrentEpisode = show.CurrentEpisode,
                CurrentSeason  = show.CurrentSeason,
            };

            BingeViewModel newView = new BingeViewModel(newShow);

            if (BingeEnd(newView, newShow))
            {
                return(false);
            }

            Thread save = new Thread(AddAndSave);

            save.Start(newShow);

            views.Add(newView);

            return(true);
        }
Exemple #2
0
        public bool AddShow(ShowBindingModel show)
        {
            string urlPath = String.Format(Constants.GetSearch, GetSlug(show.Name));

            SearchInfoRoot data = WebParser <SearchInfoRoot> .GetInfo(urlPath);

            Show newShow = new Show()
            {
                Id             = data.data[0].id,
                Title          = data.data[0].seriesName,
                CurrentEpisode = show.CurrentEpisode,
                CurrentSeason  = show.CurrentSeason,
                Status         = show.Status
            };

            ShowViewModel newView = new ShowViewModel(newShow);

            if (!AddEpisodeInfo(newView))
            {
                if (data.data[0].status != "Continuing")
                {
                    return(false);
                }
            }

            Thread save = new Thread(AddAndSave);

            save.Start(newShow);

            //Insert the view into the collection
            HelperFunctions.PutInTheRightPlace <ShowViewModel>(views, newView);

            return(true);
        }
Exemple #3
0
        private bool AddEpisodeInfo(ShowViewModel model)
        {
            string          urlPath = String.Format(Constants.GetEpisode, model.Id, model.CurrentSeason, model.CurrentEpisode);
            EpisodeInfoRoot ep;

            try
            {
                ep = WebParser <EpisodeInfoRoot> .GetInfo(urlPath);
            }
            catch (Exception)
            {
                return(false);
            }

            model.UpdateEpisodeInfo(ep.data);

            return(true);
        }
        private bool IsOngoing(BingeShow chosen)
        {
            string path = String.Format(Constants.GetSeries, chosen.Id);

            try
            {
                ShowInfoRoot data = WebParser <ShowInfoRoot> .GetInfo(path);

                if (data.data.status == "Continuing")
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                //Unautorized
                return(false);
            }

            return(false);
        }
        private bool AddEpisodeInfo(BaseViewModel model)
        {
            string          epPath = String.Format(Constants.GetAllEpisodes, model.Id, model.CurrentSeason);
            EpisodeInfoRoot ep;

            string         totalPath = String.Format(Constants.GetTotal, model.Id);
            SeasonDataRoot total;

            try
            {
                ep = WebParser <EpisodeInfoRoot> .GetInfo(epPath);

                total = WebParser <SeasonDataRoot> .GetInfo(totalPath);
            }
            catch (HttpRequestException e)
            {
                if (e.HResult == 404)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }

            try
            {
                model.UpdateEpisodeInfo(ep.data, total.data);
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
        public static string GetPosterSorce(int showId, int showSeason)
        {
            string srcBase = "https://www.thetvdb.com/banners/";

            while (showSeason > 0)
            {
                string path = String.Format(Constants.GetPoster, showId, showSeason);

                try
                {
                    ImageInfoRoot data = WebParser <ImageInfoRoot> .GetInfo(path);

                    data.data.OrderByDescending(p => p.ratingsInfo.average);

                    return(srcBase + data.data[0].fileName);
                }
                catch (Exception)
                {
                    --showSeason;
                }
            }

            return("");
        }