Ejemplo n.º 1
0
        public static void GetShowImage(Show show)
        {
            if (string.IsNullOrWhiteSpace(show.ImageUrl)) return;

            show.IsLoading = true;

            Task.Factory.StartNew(() =>
            {
                var extension = Path.GetExtension(show.ImageUrl);
                var file = string.Format("{0}{1}", show.ShowId, extension);
                var folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                    ConfigurationManager.AppSettings["IMAGE_CACHE"]);

                if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);

                var filename = Path.Combine(folder, file);

                if (!File.Exists(filename))
                {
                    using (var web = new WebClient())
                    {
                        web.DownloadFile(show.ImageUrl, filename);
                    }
                }

                Execute.BeginOnUIThread(() =>
                {
                    show.ImageSource = new BitmapImage(new Uri(filename));
                    show.IsLoading = false;
                });
            });
        }
        public string GetUrl(Show show)
        {
            var name = show.Name.Replace(" ", "-");
            name = name.Replace("'", "");

            var url = $"http://putlocker.is/watch-{name}-tvshow-online-free-putlocker.html";

            return url;
        }
        public string GetUrl(Show show)
        {
            var name = show.Name.Replace(" ", "-");
            name = name.Replace("'", "");

            var url = $"http://projectfreetv.so/free/{name}/";

            return url;
        }
Ejemplo n.º 4
0
        public static void LoadDefaultImages(Show show)
        {
            show.ImageSource = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Jarloo.Sojurn;component/Images/image_episode.png", UriKind.Absolute));
                }
            }
        }
        public List<Show> GetShows(string search)
        {
            var requestUri = string.Format("{0}search/shows?q={1}", BASE_URL, HttpUtility.HtmlEncode(search));
            var data = GetJsonData(requestUri);

            var shows = new List<Show>();
            foreach (var item in data)
            {
                var show = new Show
                {
                    ShowId = item.show.id,
                    Name = item.show.name
                };
                shows.Add(show);
            }
            return shows;
        }
        public List<Show> GetShows(string search)
        {
            var requestUri = $"{BASE_URL}search/shows?q={HttpUtility.HtmlEncode(search)}";
            var data = GetJsonData(requestUri);

            var shows = new List<Show>();
            foreach (var item in data)
            {
                var show = new Show
                {
                    ShowId = item.show.id,
                    Name = item.show.name,
                    ImageUrl = GetImage(item.show.image)
                };

                ImageHelper.GetShowImageUrl(show);

                shows.Add(show);
            }
            return shows;
        }
Ejemplo n.º 7
0
 private void RemoveFromTimeLine(Show show)
 {
     for (int i = timeLine.Count - 1; i >= 0; i--)
     {
         if (timeLine[i].Show == show) timeLine.RemoveAt(i);
     }
 }
Ejemplo n.º 8
0
        public void MarkAllAsNotViewed(Show s)
        {
            foreach (Episode episode in s.Seasons.SelectMany(season => season.Episodes))
            {
                episode.HasBeenViewed = false;
            }

            UpdateBacklog();
        }
Ejemplo n.º 9
0
        public void MarkAllAsViewed(Show s)
        {
            foreach (Episode episode in s.Seasons.SelectMany(season => season.Episodes))
            {
                if (episode.AirDate > DateTime.Today) continue;

                episode.HasBeenViewed = true;
            }

            UpdateBacklog();
        }
Ejemplo n.º 10
0
        public async void RefreshShow(Show oldShow)
        {
            oldShow.IsLoading = true;

            Show newShow = await Task<Show>.Factory.StartNew(() => infoProvider.GetFullDetails(oldShow.ShowId));

            oldShow.Country = newShow.Country;
            oldShow.Ended = newShow.Ended;
            oldShow.Link = newShow.Link;
            oldShow.Name = newShow.Name;
            oldShow.Started = newShow.Started;
            oldShow.Status = newShow.Status;
            oldShow.ImageUrl = newShow.ImageUrl;

            foreach (Season newSeason in newShow.Seasons)
            {
                Season oldSeason = oldShow.Seasons.FirstOrDefault(w => w.SeasonNumber == newSeason.SeasonNumber);

                if (oldSeason == null)
                {
                    oldShow.Seasons.Add(newSeason);
                    continue;
                }

                foreach (Episode newEpisode in newSeason.Episodes)
                {
                    Episode oldEpisode =
                        oldSeason.Episodes.FirstOrDefault(w => w.EpisodeNumber == newEpisode.EpisodeNumber);

                    if (oldEpisode == null)
                    {
                        oldSeason.Episodes.Add(newEpisode);
                        continue;
                    }

                    oldEpisode.AirDate = newEpisode.AirDate;
                    oldEpisode.ImageUrl = newEpisode.ImageUrl;
                    oldEpisode.Link = newEpisode.Link;
                    oldEpisode.Title = newEpisode.Title;
                }
            }

            ImageHelper.LoadDefaultImages(oldShow);
            ImageHelper.GetShowImage(oldShow);
            ImageHelper.GetEpisodeImages(oldShow);

            oldShow.IsLoading = false;
        }
Ejemplo n.º 11
0
 public void RemoveShow(Show s)
 {
     RemoveFromTimeLine(s);
     RemoveFromBacklog(s);
     shows.Remove(s);
 }
Ejemplo n.º 12
0
        public void ShowShow(Show s)
        {
            if (s == null) return;

            wm.ShowDialog(new ShowViewModel(s));
        }
        public Show GetFullDetails(int showId)
        {
            try
            {
                var requestShowDetailUri = $"{BASE_URL}shows/{HttpUtility.HtmlEncode(showId)}";
                var shdata = GetJsonData(requestShowDetailUri);

                var show = new Show
                {
                    ShowId = shdata.id,
                    Name = shdata.name,
                    Started = GetDate(shdata.premiered),
                    Ended = null,
                    Country = GetCountryCode(shdata),
                    Status = shdata.status,
                    ImageUrl = GetImage(shdata.image),
                    AirTimeHour = GetTime(shdata.schedule.time, 'H'),
                    AirTimeMinute = GetTime(shdata.schedule.time, 'M')
                };

                var requestShowEpisodsUri = $"{BASE_URL}shows/{HttpUtility.HtmlEncode(showId)}/episodes";
                var epdata = GetJsonData(requestShowEpisodsUri);

                //I could not use linq becuase the json data is dynamic
                //use old reliable foreach
                DateTime? lastEpisodeAirDate = null;
                var seasonNumber = 0;
                Season season = null;
                foreach (var ep in epdata)
                {
                    if (ep.season != seasonNumber)
                    {
                        season = new Season {SeasonNumber = ep.season};
                        show.Seasons.Add(season);
                        seasonNumber = ep.season;
                    }
                    //the season can't be null because the ep.season starts from 1 in TvMaze API
                    //and the 'if' statment above initialize the vavriable
                    season?.Episodes.Add(new Episode
                    {
                        EpisodeNumber = ep.number,
                        AirDate = GetDate(ep.airdate),
                        Title = ep.name,
                        Link = ep.url,
                        ImageUrl = GetImage(ep.image),
                        ShowName = shdata.name,
                        SeasonNumber = ep.season,
                        Summary = RemoveHtmlTags(ep.summary.ToString())
                    });
                    
                    //if needed (check by status) get the value for the last Episode AirDate as the show's end date 
                    if (show.Status == "Ended")
                        lastEpisodeAirDate = GetDate(ep.airdate);
                }
                show.Ended = lastEpisodeAirDate;

                //check if there are seasons
                //if not return null for an exception
                if (season == null)
                    return null;

                foreach (var t in show.Seasons)
                {
                    for (var e = 0; e < t.Episodes.Count; e++)
                    {
                        t.Episodes[e].EpisodeNumberThisSeason = e + 1;
                    }
                }

                show.LastUpdated = DateTime.Now;

                return show;
            }
            catch
            {
                return null;
            }
        }
Ejemplo n.º 14
0
 public ShowViewModel(Show s)
 {
     Show = s;
     DisplayName = s.Name;
 }
Ejemplo n.º 15
0
 private void RemoveFromBacklog(Show show)
 {
     for (int i = backlog.Count - 1; i >= 0; i--)
     {
         if (backlog[i].Show == show) backlog.RemoveAt(i);
     }
 }
Ejemplo n.º 16
0
        public void AddShow()
        {
            var win = new AddShowViewModel(infoProvider, shows.ToList());
            if (wm.ShowDialog(win) != true) return;
            if (win.Show == null) return;

            Show show = win.Show;
            if (show.Seasons.Count > 0)
            {
                show.SelectedSeason = show.Seasons[show.Seasons.Count - 1];
            }

            shows.Add(show);
            SelectedShow = show;

            SaveShows();

            ImageHelper.LoadDefaultImages(show);
            ImageHelper.GetShowImage(show);
            ImageHelper.GetEpisodeImages(show);

            UpdateTimeline();
            UpdateBacklog();
        }
Ejemplo n.º 17
0
        public static void GetEpisodeImages(Show show)
        {
            foreach (var episode in show.Seasons.SelectMany(season => season.Episodes))
            {
                episode.IsLoading = true;
            }

            Task.Factory.StartNew(() =>
            {
                foreach (var season in show.Seasons.OrderByDescending(w => w.SeasonNumber))
                {
                    foreach (var episode in season.Episodes.OrderByDescending(w => w.EpisodeNumber))
                    {
                        var e = episode;

                        if (episode.ImageUrl != null)
                        {
                            var extension = Path.GetExtension(e.ImageUrl);
                            var file = $"{show.ShowId}_{season.SeasonNumber}_{e.EpisodeNumber}{extension}";
                            var folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                ConfigurationManager.AppSettings["IMAGE_CACHE"]);

                            if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);

                            var filename = Path.Combine(folder, file);

                            if (!File.Exists(filename))
                            {
                                using (var web = new WebClient())
                                {
                                    web.DownloadFile(e.ImageUrl, filename);
                                }
                            }

                            Execute.BeginOnUIThread(() =>
                            {
                                try
                                {
                                    if (extension?.ToUpper() == ".PNG")
                                    {
                                        Stream imageStreamSource = new FileStream(filename, FileMode.Open,
                                            FileAccess.Read, FileShare.Read);
                                        var decoder = new PngBitmapDecoder(imageStreamSource,
                                            BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                                        e.ImageSource = decoder.Frames[0];
                                    }
                                    else
                                    {
                                        try
                                        {
                                            e.ImageSource = new BitmapImage(new Uri(filename));
                                        }
                                        catch
                                        {
                                            //File most likely corrupted
                                            File.Delete(filename);
                                        }
                                    }
                                }
                                catch
                                {
                                    //supress
                                }
                            });
                        }

                        Execute.BeginOnUIThread(() => e.IsLoading = false);
                    }
                }
            });
        }