Exemple #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            TVShow      tv = (TVShow)lbTVshows.SelectedItem;
            AdminUpdate au = new AdminUpdate(tv);

            au.ShowDialog();
        }
Exemple #2
0
        public static void _removeTVShow(TVShow todelete)
        {
            _instance.Cypher
            .OptionalMatch("(show:TVShow)-[r]->()")
            .Where((NeoTvShow show) => show.Id == todelete.Id)
            .DetachDelete("r, show")
            .ExecuteWithoutResults();

            _instance.Cypher
            .OptionalMatch("(show:TVShow)<-[r]-()")
            .Where((NeoTvShow show) => show.Id == todelete.Id)
            .DetachDelete("r, show")
            .ExecuteWithoutResults();

            _instance.Cypher
            .Match("(orphanNode)")
            .Where("not (orphanNode)-[]-()")
            .Delete("orphanNode")
            .ExecuteWithoutResults();

            _instance.Cypher
            .Match("(show:TVShow)")
            .Where((NeoTvShow show) => show.Id == todelete.Id)
            .Delete("show")
            .ExecuteWithoutResults();
        }
Exemple #3
0
 public AdminUpdate(TVShow tv)
 {
     InitializeComponent();
     this.tvshow = tv;
     actors      = new List <Actor>();
     creators    = new List <Creator>();
 }
        public bool CreateTVShow(TVShowCreate model)
        {
            var entity =
                new TVShow()
            {
                MediaType = model.MediaType,
                Title     = model.Title,
                Creator   = model.Creator,
                Stars     = model.Stars,
                Synopsis  = model.Synopsis,
                Genre1    = model.Genre1,
                Genre2    = model.Genre2,
                Network   = model.Network,
                Year      = model.Year,
                Released  = model.Released,
                Rating    = model.Rating,
                Runtime   = model.Runtime
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.TVShows.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemple #5
0
        private void TVShowWrapper_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            TVShow tappedTVShow = (sender as Grid).DataContext as TVShow;

            GlobalVariables.CurrentTVShow = tappedTVShow;
            NavigationService.Navigate(new Uri("/Pages/Video/TVShowDetailsPanorama.xaml", UriKind.Relative));
        }
        public async Task <IActionResult> Add(ScheduleForWeek scheduleForWeek, TVShow tvShow)
        {
            scheduleForWeek.TVShowID = _context.TVShows.Where(o => o.NameShow == tvShow.NameShow).FirstOrDefault().TVShowID;
            if (scheduleForWeek == null)
            {
                return(View());
            }

            try
            {
                _context.SchedulesForWeek.Add(scheduleForWeek);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ScheduleForWeekExists(scheduleForWeek.ScheduleForWeekID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToAction("Index"));
        }
 public TVShowDetailsPage(TVShow myShow)
 {
     InitializeComponent();
     BindingContext   = ViewModel;
     ViewModel.TVShow = myShow;
     ViewModel.LoadTVShowCommand.Execute(null);
 }
 public static TVShowDTO ToDto(this TVShow model)
 {
     return(new TVShowDTO(
                model.Id,
                model.Name,
                model.TVShowCastMember?.Select(x => x.CastMember.ToDto()).ToList()));
 }
Exemple #9
0
        public TVShow FindByName(string seriesName)
        {
            TVShow show = _context.Shows.FirstOrDefault(b =>
                                                        b.SeriesName.ToUpper().RemoveNonAlphanumeric() == seriesName.ToUpper().RemoveNonAlphanumeric());

            return(show);
        }
 public TVShowCastMember(int tvShowId, TVShow tvShow, int castMemberId, CastMember castMember)
 {
     this.TVShowId     = tvShowId;
     this.TvShow       = tvShow;
     this.CastMemberId = castMemberId;
     this.CastMember   = castMember;
 }
Exemple #11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,TVChannelId,ShowName")] TVShow tVShow)
        {
            if (id != tVShow.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tVShow);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TVShowExists(tVShow.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TVChannelId"] = new SelectList(_context.TVChannel, "Id", "Id", tVShow.TVChannelId);
            return(View(tVShow));
        }
Exemple #12
0
        public IActionResult Index(TVShow tvShow)
        {
            var       sessionSortState = HttpContext.Session.GetString("SortStateTVShow");
            SortState sortOrder        = new SortState();

            if (sessionSortState != null)
            {
                sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
            }

            int?page = HttpContext.Session.GetInt32("Page");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("Page", 0);
            }

            IQueryable <TVShow> tvShows = Sort(db.TVShows, sortOrder,
                                               tvShow.NameShow, (int)page);

            HttpContext.Session.SetObject("Disease", tvShow);

            TVShowsViewModel tvShowsView = new TVShowsViewModel
            {
                TVShowViewModel = tvShow,
                PageViewModel   = tvShows,
                PageNumber      = (int)page
            };

            return(View(tvShowsView));
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JToken obj = JToken.Load(reader);

            using (reader = obj.CreateReader())
            {
                if (typeof(Movie) == objectType)
                {
                    Movie movie = new Movie();
                    serializer.Populate(reader, movie);
                    movie.Backdrops = GetImages(obj.SelectToken("images.backdrops"), serializer);
                    movie.Posters   = GetImages(obj.SelectToken("images.posters"), serializer);
                    return(movie);
                }
                if (typeof(TVShow) == objectType)
                {
                    TVShow show = new TVShow();
                    serializer.Populate(reader, show);
                    show.Backdrops = GetImages(obj.SelectToken("images.backdrops"), serializer);
                    show.Posters   = GetImages(obj.SelectToken("images.posters"), serializer);
                    return(show);
                }
                if (typeof(Person) == objectType)
                {
                    Person person = new Person();
                    serializer.Populate(reader, person);
                    person.Profiles = GetImages(obj.SelectToken("images.profiles"), serializer);
                    return(person);
                }
            }

            return(existingValue);
        }
Exemple #14
0
        public IActionResult Index(TVShow tvShow, int page)
        {
            var       sessionSortState = HttpContext.Session.GetString("SortStateTVShow");
            SortState sortOrder        = new SortState();

            if (sessionSortState != null)
            {
                sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
            }

            IQueryable <TVShow> tvShows = Sort(_context.TVShows, sortOrder,
                                               tvShow.NameShow, (int)page);

            HttpContext.Session.SetObject("TVShow", tvShow);

            PageViewModel pageViewModel = new PageViewModel(NoteCount(_context.TVShows,
                                                                      _tvShow.NameShow), page, pageSize);

            TVShowsViewModel tvShowsView = new TVShowsViewModel
            {
                TVShowViewModel = tvShow,
                PageViewModel   = tvShows,
                Pages           = pageViewModel
            };

            return(View(tvShowsView));
        }
Exemple #15
0
        public async Task <IActionResult> Add(TVShow tvShow, Genre genre)
        {
            tvShow.GenreID = _context.Genres.Where(o => o.NameGenre == genre.NameGenre).FirstOrDefault().GenreID;
            if (tvShow == null)
            {
                return(View());
            }

            try
            {
                _context.TVShows.Add(tvShow);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TVShowExists(tvShow.TVShowID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToAction("Index"));
        }
Exemple #16
0
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var main = Utils.GetJSON(SignURL("http://app.imdb.com/title/maindetails?tconst=tt" + id));
            var show = new TVShow();

            show.Title       = (string)main["data"]["title"];
            show.Source      = GetType().Name;
            show.SourceID    = id;
            show.Description = (string)main["data"]["plot"]["outline"];
            show.Cover       = (string)main["data"]["image"]["url"];
            show.Airing      = (string)main["data"]["year_end"] == "????";
            show.Runtime     = (int)main["data"]["runtime"]["time"] / 60;
            show.Language    = "en";
            show.URL         = "http://www.imdb.com/title/tt" + id + "/";
            show.Episodes    = new List <Episode>();

            foreach (var genre in main["data"]["genres"])
            {
                show.Genre += (string)genre + ", ";
            }

            show.Genre = show.Genre.TrimEnd(", ".ToCharArray());

            var epdata = Utils.GetJSON(SignURL("http://app.imdb.com/title/episodes?tconst=tt" + id));

            foreach (var season in epdata["data"]["seasons"])
            {
                var snr = int.Parse((string)season["token"]);
                var enr = 0;

                foreach (var episode in season["list"])
                {
                    if (episode["type"] != "tv_episode")
                    {
                        continue;
                    }

                    var ep = new Episode();

                    ep.Season = snr;
                    ep.Number = ++enr;
                    ep.Title  = (string)episode["title"];
                    ep.URL    = "http://www.imdb.com/title/" + (string)episode["tconst"] + "/";

                    DateTime dt;
                    ep.Airdate = DateTime.TryParseExact((string)episode["release_date"]["normal"] ?? string.Empty, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)
                               ? dt
                               : Utils.UnixEpoch;

                    show.Episodes.Add(ep);
                }
            }

            if (show.Episodes.Count != 0)
            {
                show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString();
            }

            return(show);
        }
        /// <summary>
        /// Generates a regular expression for matching the show's name.
        /// </summary>
        /// <param name="show">The show's name.</param>
        /// <param name="db">The database entry, if any.</param>
        /// <returns>
        /// Regular expression which matches to the show's name.
        /// </returns>
        public static Regex GenerateTitleRegex(string show = null, TVShow db = null)
        {
            if (show == null)
            {
                show = db.Title;
            }

            // see if the show has a different name
            show = show.Trim();
            if (db != null && !string.IsNullOrWhiteSpace(db.Data.Get("scene")))
            {
                show = db.Data["scene"];
            }
            else if (Regexes.Exclusions.ContainsKey(show))
            {
                show = Regexes.Exclusions[show];
            }

            // see if the show already has a hand-written regex
            if (Regexes.Pregenerated.ContainsKey(show))
            {
                return(new Regex(Regexes.Pregenerated[show], RegexOptions.IgnoreCase));
            }

            // the CLR is optimized for uppercase string matching
            show = show.ToUpper();

            // replace apostrophes which occur in contractions to a null placeholder
            show = Regexes.Contractions.Replace(show, "\0");

            // replace "&" to "and"
            show = Regexes.Ampersand.Replace(show, "AND");

            // remove special characters
            show = Regexes.SpecialChars.Replace(show, " ").Trim();

            // remove parentheses
            //show = show.Replace("(", string.Empty).Replace(")", string.Empty);

            // make year optional
            show = Regexes.Year.Replace(show, m => "(?:" + m.Groups[1].Value + ")?");

            // make common words and single characters optional
            show = Regexes.Common.Replace(show, m => "(?:" + m.Groups[1].Value + ")?");
            show = Regexes.OneChar.Replace(show, m => "(?:" + m.Groups[1].Value + ")?");

            // replace null placeholder for apostrophes
            show = show.Replace("\0", @"(?:\\?['`’\._])?");

            // replace whitespace to non-letter matcher
            show = Regexes.Whitespace.Replace(show.Trim(), "[^A-Z0-9]+");

            // quick fix for ending optional tags
            show = show.Replace("[^A-Z0-9]+(?:", "[^A-Z0-9]*(?:").Replace(")?(?:", ")?[^A-Z0-9]*(?:");

            // add boundary restrictions
            show = @"(?:\b|_)" + show + @"(?:\b|_)";

            return(new Regex(show, RegexOptions.IgnoreCase));
        }
Exemple #18
0
        public async Task Create(TVShowsCreateModel input)
        {
            var tvshow = new TVShow()
            {
                ImageUrl     = input.ImageUrl,
                Title        = input.Title,
                Year         = input.Year,
                Description  = input.Description,
                HomePageLink = input.HomePageLink,
                IMDBLink     = input.IMDBLink,
                TrailerLink  = input.TrailerLink,
                FacebookLink = input.FacebookLink,
                Creater      = input.Creater,
                Producer     = input.Producer,
                Country      = input.Country,
                Seasons      = input.Seasons,
                ReleaseDate  = input.ReleaseDate,
                EndDate      = input.EndDate,
            };

            var tvshowGenre = this.genresRepository
                              .All()
                              .FirstOrDefault(x => x.Id == input.GenreId);

            tvshow.Genres.Add(tvshowGenre);

            await this.tvshowRepository.AddAsync(tvshow);

            await this.tvshowRepository.SaveChangesAsync();
        }
Exemple #19
0
        private async Task <ActorTVShow> AddActorTVShowRelation(Actor actor, TVShow tvShow)
        {
            try
            {
                _logger.LogInformation($"Add Actor ({actor.ID}) TVShow ({tvShow.ID}) relation to DB.");
                var newRelation = new ActorTVShow()
                {
                    Actor    = actor,
                    ActorID  = actor.ID,
                    TVShow   = tvShow,
                    TVShowID = tvShow.ID
                };

                await _showContext.ActorsTVShows.AddAsync(newRelation);

                await _showContext.SaveChangesAsync();

                return(newRelation);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Something bad happend whilst Actor ({actor.ID}) TVShow ({tvShow.ID}) relation update.");
                throw;
            }
        }
Exemple #20
0
        public void Add_ShowInDB_DoesNotWriteToDB()
        {
            var options2 = new DbContextOptionsBuilder <EpisodeContext>()
                           .UseInMemoryDatabase(databaseName: "Add_ShowInDB_DoesNotWriteToDB")
                           .Options;
            TVShow show = new TVShow()
            {
                SeriesId            = 281662,
                SeriesName          = "Marvel's Daredevil",
                SeriesNamePreferred = "Daredevil"
            };
            TVShow sameShow = new TVShow()
            {
                SeriesId            = 281662,
                SeriesName          = "Marvel's Daredevil",
                SeriesNamePreferred = "Beastie"
            };

            using (var context = new EpisodeContext(options2)) {
                var service = new TVShowService(context);
                service.Add(show);
                service.Add(sameShow);
            }
            using (var context = new EpisodeContext(options2)) {
                // Assert.Equal("Not real", context.Shows.First().SeriesNamePreferred);
                var shows = context.Shows.Where(b => b.Id >= 0);
                foreach (var s in shows)
                {
                    output.WriteLine($"{s.Id}: SeriesId: {s.SeriesId}; Name: {s.SeriesName}");
                }
                Assert.Equal(1, context.Shows.Count());
                Assert.Equal("Daredevil", context.Shows.Single().SeriesNamePreferred);
            }
        }
Exemple #21
0
        public void FindByName_ShowInDB_ReturnsShow()
        {
            var options = new DbContextOptionsBuilder <EpisodeContext>()
                          .UseInMemoryDatabase(databaseName: "FindByName_ShowInDB_ReturnsShow")
                          .Options;
            TVShow show1 = new TVShow()
            {
                SeriesId            = 281662,
                SeriesName          = "Marvel's Daredevil",
                SeriesNamePreferred = "Daredevil"
            };
            TVShow show2 = new TVShow()
            {
                SeriesId   = 328487,
                SeriesName = "The Orville"
            };

            using (var context = new EpisodeContext(options)) {
                var service = new TVShowService(context);
                context.Database.EnsureCreated();
                service.Add(show1);
                service.Add(show2);
            }
            using (var context = new EpisodeContext(options)) {
                var    service = new TVShowService(context);
                TVShow result  = service.FindByName("marvels daredevil");
                Assert.Equal(2, context.Shows.Count());
                Assert.Equal("Marvel's Daredevil", result.SeriesName);
            }
        }
Exemple #22
0
        public void GetSeriesIdsNotInDatabase_IdsNotPresent_ReturnsList()
        {
            var options = new DbContextOptionsBuilder <EpisodeContext>()
                          .UseInMemoryDatabase(databaseName: "GetSeriesIdsNotInDatabase_IdsNotPresent_ReturnsList")
                          .Options;
            TVShow show1 = new TVShow()
            {
                SeriesId            = 281662,
                SeriesName          = "Marvel's Daredevil",
                SeriesNamePreferred = "Daredevil"
            };

            using (var context = new EpisodeContext(options)) {
                var service = new TVShowService(context);
                service.Add(show1);
            }
            List <int> seriesIdsToCheck = new List <int>()
            {
                134, 16690, 281662, 300000
            };
            int expectedCount = 3;

            using (var context = new EpisodeContext(options)) {
                var service = new TVShowService(context);
                var result  = service.GetSeriesIdsNotInDatabase(seriesIdsToCheck);

                Assert.Equal(expectedCount, result.Count);
                Assert.Equal(0, result.Find(c => c == 281662));
            }
        }
Exemple #23
0
        public void GetSeriesIdsNotInDatabase_AllIdsPresent_ReturnsList()
        {
            var options = new DbContextOptionsBuilder <EpisodeContext>()
                          .UseInMemoryDatabase(databaseName: "GetSeriesIdsNotInDatabase_AllIdsPresent_ReturnsList")
                          .Options;
            TVShow show1 = new TVShow()
            {
                SeriesId            = 281662,
                SeriesName          = "Marvel's Daredevil",
                SeriesNamePreferred = "Daredevil"
            };
            TVShow show2 = new TVShow()
            {
                SeriesId   = 328487,
                SeriesName = "The Orville"
            };

            using (var context = new EpisodeContext(options)) {
                var service = new TVShowService(context);
                service.Add(show1);
                service.Add(show2);
            }
            List <int> seriesIdsToCheck = new List <int>()
            {
                281662, 328487
            };
            int expectedCount = 0;

            using (var context = new EpisodeContext(options)) {
                var service = new TVShowService(context);
                var result  = service.GetSeriesIdsNotInDatabase(seriesIdsToCheck);

                Assert.Equal(expectedCount, result.Count);
            }
        }
        public async Task CreateMediaListToTVShowRelationship(MediaList mediaList, TVShow tvShow)
        {
            var relation = Relation.Instanciate(MediaList.ENTITY_CATEGORY_ID, mediaList.GetId(),
                                                TVShow.ENTITY_CATEGORY_ID, tvShow.GetId(), Relation.RELATION_STATUS_ACTIVE_ID, DateTime.Now);

            await Save(relation);
        }
Exemple #25
0
        private void TVShowWrapper_Tapped(object sender, TappedRoutedEventArgs e)
        {
            TVShow tappedTVShow = (sender as Grid).DataContext as TVShow;

            GlobalVariables.CurrentTVShow = tappedTVShow;
            Frame.Navigate(typeof(TVShowDetailsHub));
        }
Exemple #26
0
        public override void AddItem(string result)
        {
            Website website = null;

            if (!EditMode && bool.Parse(result))
            {
                if (Regular)
                {
                    website = new Website(Title, Path.GetFileName(ImageLocation), EdgeColor, MiddleColor, HighlightColor, Description, Link);
                }
                else if (TVShow)
                {
                    website = new TVShow(Title, Path.GetFileName(ImageLocation), EdgeColor, MiddleColor, HighlightColor, Description, Link, 0, 0, 0, 0, DateTime.Now);
                }

                website.ContextMenuMap = this.ContextMenuMap;

                OnItemAdded?.Invoke(this, new DialogRoutedEventArgs()
                {
                    Object = website
                });
            }
            else
            {
                OnItemAdded?.Invoke(this, new DialogRoutedEventArgs()
                {
                    Object = null
                });
            }
        }
        /// <summary>
        /// Sends metadata information about the TV show into lab.rolisoft.net cache.
        /// </summary>
        /// <param name="tv">The TV show.</param>
        public static void UpdateRemoteCache(TVShow tv)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    var info = new Remote.Objects.ShowInfo
                    {
                        Title       = tv.Title,
                        Description = tv.Description,
                        Genre       = tv.Genre,
                        Cover       = tv.Cover,
                        Started     = (long)tv.Episodes[0].Airdate.ToUnixTimestamp(),
                        Airing      = tv.Airing,
                        AirTime     = tv.AirTime,
                        AirDay      = tv.AirDay,
                        Network     = tv.Network,
                        Runtime     = tv.Runtime,
                        Seasons     = tv.Episodes.Last().Season,
                        Episodes    = tv.Episodes.Count,
                        Source      = tv.Source,
                        SourceID    = tv.SourceID
                    };

                    var hash = BitConverter.ToString(new HMACSHA256(Encoding.ASCII.GetBytes(Utils.GetUUID() + "\0" + Signature.Version)).ComputeHash(Encoding.UTF8.GetBytes(
                                                                                                                                                         info.Title + info.Description + string.Join(string.Empty, info.Genre) + info.Cover + info.Started + (info.Airing ? "true" : "false") + info.AirTime + info.AirDay + info.Network + info.Runtime + info.Seasons + info.Episodes + info.Source + info.SourceID
                                                                                                                                                         ))).ToLower().Replace("-", string.Empty);

                    API.SetShowInfo(info, hash);
                } catch { }
            });
        }
        public int Save(TVShow show)
        {
            string sqlString = $@"UPDATE 
                                Show
                                SET ShowName = @showname
                                ,ReleaseDate = @releaseDate
                                ,NumOfSeasons = @numOfSeason
                                ,PDCompanyID = @pdCompanyId
                                ,GenreID = @genreID
                                ,RatingID = @ratingId
                                ,PlatformID = @platformId
                                ,ShowDescription = @showDescription
                                 WHERE ShowID = @showId";

            SqlCommand cmd = new SqlCommand(sqlString);

            cmd.Parameters.AddWithValue("@showname", show.ShowName);
            cmd.Parameters.AddWithValue("@releaseDate", show.ReleaseDate);
            cmd.Parameters.AddWithValue("@numOfSeason", show.NumOfSeasons);
            cmd.Parameters.AddWithValue("@pdCompanyId", show.PDCompanyID);
            cmd.Parameters.AddWithValue("@genreID", show.GenreID);
            cmd.Parameters.AddWithValue("@ratingId", show.RatingID);
            cmd.Parameters.AddWithValue("@platformId", show.PlatformID);
            cmd.Parameters.AddWithValue("@showDescription", show.ShowDescription);
            cmd.Parameters.AddWithValue("@showId", show.ShowID);

            int rowAffected = DataAccess.DataAccessHelper.ExecuteNonQuery(cmd);

            return(rowAffected);
        }
Exemple #29
0
        public async Task <IHttpActionResult> PutTVShow(int id, TVShow tVShow)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tVShow.Id)
            {
                return(BadRequest());
            }

            db.Entry(tVShow).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TVShowExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #30
0
        public TVShowResponse GetShowResponse(TVShow from, List <Cast> casts)
        {
            var result = Mapper.Map <TVShowResponse>(from);

            result.Casts = casts.Select(s => s.Person).ToList();
            return(result);
        }
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var info = Utils.GetXML("http://api.anidb.net:9001/httpapi?request=anime&client=rstvshowtracker&clientver=2&protover=1&aid=" + id);
            var show = new TVShow();

            try { show.Title = info.Descendants("title").First(t => t.Attributes().First().Value == language).Value; }
            catch
            {
                try   { show.Title = info.Descendants("title").First(t => t.Attributes().First().Value == "en").Value; }
                catch { show.Title = info.GetValue("title"); }
            }

            show.Genre       = info.Descendants("category").Aggregate(string.Empty, (current, g) => current + (g.GetValue("name") + ", ")).TrimEnd(", ".ToCharArray());
            show.Description = info.GetValue("description");
            show.Airing      = string.IsNullOrWhiteSpace(info.GetValue("enddate"));
            show.Runtime     = info.GetValue("length").ToInteger();
            show.TimeZone    = "Tokyo Standard Time";
            show.Language    = language;
            show.URL         = Site + "perl-bin/animedb.pl?show=anime&aid=" + id;
            show.Episodes    = new List<TVShow.Episode>();

            show.Cover = info.GetValue("picture");
            if (!string.IsNullOrWhiteSpace(show.Cover))
            {
                show.Cover = "http://img7.anidb.net/pics/anime/" + show.Cover;
            }

            foreach (var node in info.Descendants("episode"))
            {
                try { node.GetValue("epno").ToInteger(); }
                catch
                {
                    continue;
                }

                var ep = new TVShow.Episode();

                ep.Season = 1;
                ep.Number = node.GetValue("epno").ToInteger();
                ep.URL    = Site + "perl-bin/animedb.pl?show=ep&eid=" + node.Attribute("id").Value;

                try { ep.Title = node.Descendants("title").First(t => t.Attributes().First().Value == language).Value; }
                catch
                {
                    try   { ep.Title = node.Descendants("title").First(t => t.Attributes().First().Value == "en").Value; }
                    catch { ep.Title = node.GetValue("title"); }
                }

                DateTime dt;
                ep.Airdate = DateTime.TryParse(node.GetValue("airdate"), out dt)
                           ? dt
                           : Utils.UnixEpoch;

                show.Episodes.Add(ep);
            }

            show.Episodes = show.Episodes.OrderBy(e => e.Number).ToList();

            if (show.Episodes.Count != 0)
            {
                show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString();
            }

            return show;
        }
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var summary = Utils.GetXML("http://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime=" + id);
            var show    = new TVShow();
            
            show.Title       = GetDescendantItemValue(summary, "info", "type", "Main title");
            show.Source      = GetType().Name;
            show.SourceID    = id;
            show.Description = GetDescendantItemValue(summary, "info", "type", "Plot Summary");
            show.Cover       = GetDescendantItemAttribute(summary, "info", "type", "Picture", "src");
            show.Airing      = !Regex.IsMatch(GetDescendantItemValue(summary, "info", "type", "Vintage"), " to ");
            show.AirTime     = "20:00";
            show.Language    = "en";
            show.URL         = Site + "encyclopedia/anime.php?id=" + id;
            show.Episodes    = new List<Episode>();

            var runtxt = Regex.Match(GetDescendantItemValue(summary, "info", "type", "Running time"), "([0-9]+)");
            show.Runtime = runtxt.Success
                         ? int.Parse(runtxt.Groups[1].Value)
                         : 30;

            var genre = GetDescendantItemValues(summary, "info", "type", "Genres");
            if (genre.Count() != 0)
            {
                foreach (var gen in genre)
                {
                    show.Genre += gen.ToUppercaseFirst() + ", ";
                }

                show.Genre = show.Genre.TrimEnd(", ".ToCharArray());
            }

            var listing = Utils.GetHTML(Site + "encyclopedia/anime.php?id=" + id + "&page=25");
            var nodes   = listing.DocumentNode.SelectNodes("//table[@class='episode-list']/tr");

            if (nodes == null)
            {
                return show;
            }

            foreach (var node in nodes)
            {
                var epnr = Regex.Match(node.GetTextValue("td[@class='n'][1]") ?? string.Empty, "([0-9]+)");
                if (!epnr.Success)
                {
                    continue;
                }

                var ep = new Episode();

                ep.Season = 1;
                ep.Number = epnr.Groups[1].Value.ToInteger();
                ep.Title  = HtmlEntity.DeEntitize(node.GetTextValue("td[@valign='top'][1]/div[1]").Trim());
                ep.URL    = show.URL + "&page=25";

                DateTime dt;
                ep.Airdate = DateTime.TryParse(node.GetTextValue("td[@class='d'][1]/div") ?? string.Empty, out dt)
                           ? dt
                           : Utils.UnixEpoch;

                show.Episodes.Add(ep);
            }

            if (show.Episodes.Count != 0)
            {
                show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString();
            }

            return show;
        }
Exemple #33
0
        public static TVShow[] getTVShows(string ProviderCode, string ZipCode, string Search)
        {
            bool finished = false;
            TVShowCollection shows = new TVShowCollection();
            string html = WebZap.ObtainWebPage("http://www.tvguide.com/listings/search/SearchResults.asp?I=" + ProviderCode + "&Zip=" + ZipCode + "&FormText=" + Search);

            int lastday = 0; int month = 0;
            int after = 0;

            while (!finished)
            {
                TVShow tv = new TVShow();

                // Obtain the day of the show
                string day = WebZap.getHTML(html, ref after, "<td ALIGN=\"LEFT\" valign=\"top\" nowrap>", "									", "\n").Trim();
                day = day.Substring(4, day.Length - 4).Trim();

                // Obtain the time of the show
                string time = WebZap.getHTML(html, ref after, "<td ALIGN=\"LEFT\" valign=\"top\" nowrap>", "									", "\n").Trim();

                // Check to see if we were at the end of the month and starting a new month
                if (int.Parse(day) < lastday) month++;
                lastday = int.Parse(day);

                // Build the date & time for this show
                string daytime = DateTime.Now.Month + month + "/" + day + "/" + DateTime.Now.Year + " " + time;
                tv.Time = DateTime.Parse(daytime);

                // Obtain the TitleID from the java script line
                tv.TitleID = int.Parse(WebZap.getHTML(html, ref after, "','", "','"));

                // Get the title of the show
                string show = WebZap.getHTML(html, ref after, "<font SIZE=\"-1\" COLOR=\"MidnightBlue\" STYLE=\"text-decoration:none\">", "										", "\n").Trim();

                // Determain if this show is an episode
                if (show.LastIndexOf(": ") > -1)
                {
                    tv.Show = show.Substring(0, show.LastIndexOf(": "));
                    tv.Episode = show.Substring(tv.Show.Length + 2, show.Length - (tv.Show.Length + 2));
                }
                else tv.Show = show;

                // Obtain the channel
                string channel = WebZap.getHTML(html, ref after, "<font SIZE=\"-1\" COLOR=\"MidnightBlue\" face=\"arial,helvetica\">", "									", "\n").Trim();
                tv.Channel = int.Parse(channel);

                // Obtain the network
                string network = WebZap.getHTML(html, ref after, "<font SIZE=\"-1\" COLOR=\"MidnightBlue\" face=\"arial,helvetica\">", "									", "\n").Trim();
                tv.Network = network;

                // Display the show
                // Console.WriteLine(tv.Show + ", " + tv.Episode + ", " + tv.Time + ", " + channel + ", " + network);

                // Add to the collection.
                shows.Add(tv);

                finished = (html.IndexOf("</table>", after, 500) > -1);
            }

            return shows.ToArray();
        }
Exemple #34
0
 public void Add(TVShow s)
 {
     List.Add(s);
 }
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var query = "[{" +
                            "\"mid\":\"/m/" + id + "\"," +
                            "\"type\":\"/tv/tv_program\"," +
                            "\"name\":null," +
                            "\"air_date_of_first_episode\":{" +
                                "\"value\":null," +
                                "\"optional\":true" +
                            "}," +
                            "\"/common/topic/image\":[{" +
                                "\"mid\":null," +
                                "\"optional\":true" +
                            "}]," +
                            "\"/common/topic/description\":[{" +
                                "\"value\":null," +
                                "\"optional\":true" +
                            "}]," +
                            "\"episode_running_time\":[{" +
                                "\"value\":null," +
                                "\"optional\":true" +
                            "}]," +
                            "\"currently_in_production\":{" +
                                "\"value\":null," +
                                "\"optional\":true" +
                            "}," +
                            "\"original_network\":[{" +
                                "\"network\":null," +
                                "\"optional\":true" +
                            "}]," +
                            "\"genre\":[{" +
                                "\"name\":null," +
                                "\"optional\":true" +
                            "}]," +
                            "\"episodes\":[{" +
                                "\"mid\":null," +
                                "\"name\":null," +
                                "\"season_number\":null," +
                                "\"episode_number\":null," +
                                "\"air_date\":{" +
                                    "\"value\":null," +
                                    "\"optional\":true" +
                                "}," +
                                "\"/common/topic/image\":[{" +
                                    "\"mid\":null," +
                                    "\"optional\":true" +
                                "}]," +
                                "\"/common/topic/description\":[{" +
                                    "\"value\":null," +
                                    "\"optional\":true" +
                                "}]," +
                                "\"limit\":65535" +
                            "}]" +
                        "}]";
            var json = (dynamic)JsonConvert.DeserializeObject(Utils.GetFastURL("https://www.googleapis.com/freebase/v1/mqlread?query=" + Utils.EncodeURL(query)));
            var main = json["result"][0];
            
            var show = new TVShow();

            show.Title       = (string)main["name"];
            show.Source      = GetType().Name;
            show.SourceID    = id;
            show.Description = main["/common/topic/description"].Count > 0 ? (string)main["/common/topic/description"][0]["value"] : null;
            show.Cover       = main["/common/topic/image"].Count > 0 ? "https://usercontent.googleapis.com/freebase/v1/image" + (string)main["/common/topic/image"][0]["mid"] + "?maxwidth=2048" : null;
            show.Airing      = main["currently_in_production"] != null && (bool)main["currently_in_production"]["value"];
            show.Runtime     = main["episode_running_time"].Count > 0 ? (int)main["episode_running_time"][0]["value"] : 30;
            show.Network     = main["original_network"].Count > 0 ? (string)main["original_network"][0]["value"] : null;
            show.Language    = "en";
            show.URL         = Site.TrimEnd("/".ToCharArray()) + (string)main["mid"];
            show.Episodes    = new List<Episode>();

            foreach (var genre in main["genre"])
            {
                show.Genre += (string)genre["name"] + ", ";
            }

            show.Genre = show.Genre.TrimEnd(", ".ToCharArray());

            if (string.IsNullOrWhiteSpace(show.Description))
            {
                var desc = (dynamic)JsonConvert.DeserializeObject(Utils.GetFastURL("https://www.googleapis.com/freebase/v1/topic/m/" + id + "?filter=/common/topic/description&limit=1"));

                if (desc["property"] != null && desc["property"]["/common/topic/description"] != null && desc["property"]["/common/topic/description"]["values"].Count > 0)
                {
                    show.Description = (string)desc["property"]["/common/topic/description"]["values"][0]["value"];
                }
            }

            foreach (var episode in main["episodes"])
            {
                if (episode["season_number"] == null || episode["episode_number"] == null) continue;

                var ep = new Episode();

                ep.Season  = (int)episode["season_number"];
                ep.Number  = (int)episode["episode_number"];
                ep.Title   = (string)episode["name"];
                ep.Summary = episode["/common/topic/description"].Count > 0 ? (string)episode["/common/topic/description"][0]["value"] : null;
                ep.Picture = episode["/common/topic/image"].Count > 0 ? "https://usercontent.googleapis.com/freebase/v1/image" + episode["/common/topic/image"][0]["mid"] + "?maxwidth=2048" : null;
                ep.URL     = Site.TrimEnd("/".ToCharArray()) + (string)episode["mid"];

                DateTime dt;
                ep.Airdate = DateTime.TryParseExact(episode["air_date"] != null ? (string)episode["air_date"]["value"] : string.Empty, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)
                            ? dt
                            : Utils.UnixEpoch;

                show.Episodes.Add(ep);
            }

            show.Episodes = show.Episodes.OrderBy(e => e.Number + (e.Season * 1000)).ToList();

            if (show.Episodes.Count != 0)
            {
                show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString();
            }

            return show;
        }
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var main = Utils.GetJSON("http://api.tvmaze.com/shows/" + id + "?embed=episodes");
            var show = new TVShow();

            show.Title       = main["name"];
            show.Source      = GetType().Name;
            show.SourceID    = id;
            show.Description = main["summary"];
            show.Airing      = main["status"] == "Running";
            show.AirTime     = (main["schedule"] == null || main["schedule"].Count == 0) ? null : (string)main["schedule"]["time"];
            show.Runtime     = main["runtime"];
            show.Network     = (main["network"] == null || main["network"].Count == 0) ? null : (string)main["network"]["name"];
            show.Language    = "en";
            show.URL         = main["url"];
            show.Episodes    = new List<Episode>();

            if (main["image"] != null && main["image"]["original"] != null)
            {
                show.Cover = main["image"]["original"];
            }
            else if (main["image"] != null && main["image"]["medium"] != null)
            {
                show.Cover = main["image"]["medium"];
            }

            if (main["genres"] != null)
            {
                show.Genre = string.Join(", ", main["genres"]);
            }

            if (main["_embedded"] != null && main["_embedded"]["episodes"] != null && main["_embedded"]["episodes"].Count > 0)
            {
                foreach (var episode in main["_embedded"]["episodes"])
                {
                    var ep = new Episode();
                    ep.Show = show;

                    ep.Season  = (int)episode["season"];
                    ep.Number  = (int)episode["number"];
                    ep.Title   = (string)episode["name"];
                    ep.Summary = (string)episode["summary"];
                    ep.URL     = (string)episode["url"];

                    if (episode["image"] != null && episode["image"]["original"] != null)
                    {
                        ep.Picture = main["image"]["original"];
                    }
                    else if (episode["image"] != null && episode["image"]["medium"] != null)
                    {
                        ep.Picture = main["image"]["medium"];
                    }

                    DateTime dt;
                    ep.Airdate = DateTime.TryParseExact((string)episode["airdate"] ?? string.Empty, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)
                               ? dt
                               : Utils.UnixEpoch;

                    show.Episodes.Add(ep);
                }
            }

            if (show.Episodes.Count != 0)
            {
                show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString();
            }

            return show;
        }
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var listing = Utils.GetHTML("http://www.episodeworld.com/show/" + id + "/season=all/" + Languages.List[language].ToLower() + "/episodeguide");
            var show    = new TVShow();

            show.Title       = HtmlEntity.DeEntitize(listing.DocumentNode.GetTextValue("//div[@class='orangecorner_content']//h1"));
            show.Source      = GetType().Name;
            show.SourceID    = id;
            show.Description = HtmlEntity.DeEntitize(listing.DocumentNode.GetTextValue("//table/tr/td[1]/table[1]/tr[@class='centerbox_orange']/td[@class='centerbox_orange']") ?? string.Empty).Trim();
            show.Cover       = listing.DocumentNode.GetNodeAttributeValue("//table/tr/td[1]/table[1]/tr[@class='centerbox_orange']/td[@class='centerbox_orange_l']//img", "src");
            show.Airing      = !Regex.IsMatch(listing.DocumentNode.GetTextValue("//div[@class='orangecorner_content']//th[4]") ?? string.Empty, "(Canceled|Ended)");
            show.AirTime     = "20:00";
            show.Language    = language;
            show.URL         = "http://www.episodeworld.com/show/" + id + "/season=all/" + Languages.List[language].ToLower() + "/episodeguide";
            show.Episodes    = new List<Episode>();

            var runtxt   = Regex.Match(listing.DocumentNode.GetTextValue("//td[@class='centerbox_orange']/b[text() = 'Runtime:']/following-sibling::text()[1]") ?? string.Empty, "([0-9]+)");
            show.Runtime = runtxt.Success
                         ? int.Parse(runtxt.Groups[1].Value)
                         : 30;

            var genre = listing.DocumentNode.SelectNodes("//td[@class='centerbox_orange']/a[starts-with(@href, '/browse/')]");
            if (genre != null)
            {
                foreach (var gen in genre)
                {
                    show.Genre += gen.InnerText + ", ";
                }

                show.Genre = show.Genre.TrimEnd(", ".ToCharArray());
            }

            var network = listing.DocumentNode.GetTextValue("//td[@class='centerbox_orange']/b[text() = 'Premiered on Network:']/following-sibling::text()[1]");
            if (!string.IsNullOrWhiteSpace(network))
            {
                show.Network = Regex.Replace(network, @" in .+$", string.Empty);
            }

            var nodes = listing.DocumentNode.SelectNodes("//table[@id='list']/tr");
            if (nodes == null)
            {
                return show;
            }

            foreach (var node in nodes)
            {
                var episode = Regex.Match(node.GetTextValue("td[2]") ?? string.Empty, "([0-9]{1,2})x([0-9]{1,3})");
                if (!episode.Success)
                {
                    continue;
                }

                var ep = new Episode();

                ep.Season  = episode.Groups[1].Value.ToInteger();
                ep.Number  = episode.Groups[2].Value.ToInteger();
                ep.Title   = HtmlEntity.DeEntitize(node.GetTextValue("td[3]").Trim());
                ep.URL     = node.GetNodeAttributeValue("td[3]/a", "href");

                if (ep.URL != null)
                {
                    ep.URL = Site.TrimEnd('/') + ep.URL;
                }

                DateTime dt;
                ep.Airdate = DateTime.TryParse(HtmlEntity.DeEntitize(node.GetTextValue("td[7]") ?? string.Empty).Trim(), out dt)
                           ? dt
                           : Utils.UnixEpoch;

                show.Episodes.Add(ep);
            }

            if (show.Episodes.Count != 0)
            {
                show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString();
            }

            return show;
        }
Exemple #38
0
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var info = Utils.GetXML("http://www.thetvdb.com/api/{0}/series/{1}/all/{2}.xml".FormatWith(Key, id, language), timeout: 120000);
            var show = new TVShow();

            show.Title       = info.GetValue("SeriesName");
            show.Genre       = info.GetValue("Genre").Trim('|').Replace("|", ", ");
            show.Description = info.GetValue("Overview");
            show.Airing      = !Regex.IsMatch(info.GetValue("Status"), "(Canceled|Ended)");
            show.AirTime     = info.GetValue("Airs_Time");
            show.AirDay      = info.GetValue("Airs_DayOfWeek");
            show.Network     = info.GetValue("Network");
            show.Language    = language;
            show.URL         = "http://thetvdb.com/?tab=series&id=" + info.GetValue("id");
            show.Episodes    = new List<TVShow.Episode>();

            if (show.Network.StartsWith("BBC") || show.Network.StartsWith("ITV"))
            {
                show.TimeZone = "GMT+0";
            }

            show.Cover = info.GetValue("poster");
            if (!string.IsNullOrWhiteSpace(show.Cover))
            {
                show.Cover = "http://thetvdb.com/banners/" + show.Cover;
            }

            show.Runtime = info.GetValue("Runtime").ToInteger();
            show.Runtime = show.Runtime == 30
                           ? 20
                           : show.Runtime == 50 || show.Runtime == 60
                             ? 40
                             : show.Runtime;

            foreach (var node in info.Descendants("Episode"))
            {
                int sn;
                if ((sn = node.GetValue("SeasonNumber").ToInteger()) == 0)
                {
                    continue;
                }

                var ep = new TVShow.Episode();

                ep.Season  = sn;
                ep.Number  = node.GetValue("EpisodeNumber").ToInteger();
                ep.Title   = node.GetValue("EpisodeName");
                ep.Summary = node.GetValue("Overview");
                ep.URL     = "http://thetvdb.com/?tab=episode&seriesid={0}&seasonid={1}&id={2}".FormatWith(node.GetValue("seriesid"), node.GetValue("seasonid"), node.GetValue("id"));

                ep.Picture = node.GetValue("filename");
                if (!string.IsNullOrWhiteSpace(ep.Picture))
                {
                    ep.Picture = "http://thetvdb.com/banners/_cache/" + ep.Picture;
                }

                DateTime dt;
                ep.Airdate = DateTime.TryParse(node.GetValue("FirstAired"), out dt)
                           ? dt
                           : Utils.UnixEpoch;

                show.Episodes.Add(ep);
            }

            return show;
        }
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        /// <exception cref="Exception">Failed to extract the listing. Maybe the EPGuides.com regex is out of date.</exception>
        public override TVShow GetData(string id, string language = "en")
        {
            var db = _defaultDb;

            if (id.Contains('\0'))
            {
                var tmp = id.Split('\0');
                     id = tmp[0];
                     db = tmp[1];
            }

            var listing = Utils.GetURL(id, "list=" + db);
            var show = new TVShow
                {
                    Source   = GetType().Name,
                    SourceID = id,
                    AirTime  = "20:00",
                    Language = "en",
                    URL      = id,
                    Episodes = new List<Episode>()
                };

            var mc = _infoRegex.Matches(listing);

            foreach (Match m in mc)
            {
                if (m.Groups["title"].Success)
                {
                    show.Title = m.Groups["title"].Value;
                }

                if (m.Groups["airing"].Success)
                {
                    show.Airing = true;
                }

                if (m.Groups["runtime"].Success)
                {
                    show.Runtime = m.Groups["runtime"].Value.Trim().ToInteger();
                    show.Runtime = show.Runtime == 30
                                   ? 20
                                   : show.Runtime == 50 || show.Runtime == 60
                                     ? 40
                                     : show.Runtime;
                }
            }

            var prod = Regex.Match(listing, @"(?<start>_+\s{1,5}_+\s{1,5})(?<length>_+\s{1,5})_+\s{1,5}_+");
            listing = Regex.Replace(listing, @"(.{" + prod.Groups["start"].Value.Length + "})(.{" + prod.Groups["length"].Value.Length + "})(.+)", "$1$3");

            mc = _guideRegex.Matches(listing);

            if (mc.Count == 0)
            {
                throw new Exception("Failed to extract the listing. Maybe the EPGuides.com regex is out of date.");
            }

            foreach (Match m in mc)
            {
                var ep = new Episode();

                ep.Season = m.Groups["season"].Value.Trim().ToInteger();
                ep.Number = m.Groups["episode"].Value.Trim().ToInteger();
                ep.Title = HtmlEntity.DeEntitize(m.Groups["title"].Value);

                var dt = DateTime.MinValue;

                switch (db)
                {
                    case "tvrage.com":
                        DateTime.TryParseExact(m.Groups["airdate"].Value.Trim(), "dd/MMM/yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt);
                        break;

                    case "tv.com":
                        DateTime.TryParseExact(m.Groups["airdate"].Value.Trim(), "d MMM yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt);
                        break;
                }

                if (dt == DateTime.MinValue && !DateTime.TryParse(m.Groups["airdate"].Value.Trim(), out dt))
                {
                    dt = Utils.UnixEpoch;
                }

                ep.Airdate = dt;

                show.Episodes.Add(ep);
            }

            if (show.Episodes.Count != 0)
            {
                show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString();
            }

            return show;
        }
Exemple #40
0
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var summary = Utils.GetHTML("http://www.tv.com/shows/{0}/".FormatWith(id));
            var show    = new TVShow();

            show.Title       = HtmlEntity.DeEntitize(summary.DocumentNode.GetNodeAttributeValue("//meta[@property='og:title']", "content"));
            show.Source      = GetType().Name;
            show.SourceID    = id;
            show.Description = HtmlEntity.DeEntitize((summary.DocumentNode.GetTextValue("//div[@class='description']/span") ?? string.Empty).Replace("&nbsp;", " ").Replace("moreless", string.Empty).Trim());
            show.Genre       = Regex.Replace(summary.DocumentNode.GetTextValue("//div[contains(@class, 'categories')]") ?? string.Empty, @"\s+", string.Empty).Replace("Categories", string.Empty).Replace(",", ", ");
            show.Cover       = summary.DocumentNode.GetNodeAttributeValue("//meta[@property='og:image']", "content");
            show.Airing      = !Regex.IsMatch(summary.DocumentNode.GetTextValue("//ul[@class='stats']/li[2]") ?? string.Empty, "(Canceled|Ended)");
            show.Runtime     = 30;
            show.Language    = "en";
            show.URL         = "http://www.tv.com/shows/{0}/".FormatWith(id);
            show.Episodes    = new List<Episode>();

            var airinfo = summary.DocumentNode.GetTextValue("//div[@class='tagline']");
            if (airinfo != null)
            {
                airinfo = Regex.Replace(airinfo, @"\s+", " ").Trim();

                var airday = Regex.Match(airinfo, @"(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)");
                if (airday.Success)
                {
                    show.AirDay = airday.Groups[1].Value;
                }

                var airtime = Regex.Match(airinfo, @"(\d{1,2}:\d{2}(?: (?:AM|PM))?)", RegexOptions.IgnoreCase);
                if (airtime.Success)
                {
                    show.AirTime = airtime.Groups[1].Value;
                }

                var network = Regex.Match(airinfo, @"on ([^\s$\(]+)");
                if (network.Success)
                {
                    show.Network = network.Groups[1].Value;
                }
            }

            var epurl = "episodes";
            var snr   = -1;

              grabSeason:
            var listing = Utils.GetHTML("http://www.tv.com/shows/{0}/{1}/?expanded=1".FormatWith(id, epurl));
            var nodes   = listing.DocumentNode.SelectNodes("//li[starts-with(@class, 'episode')]");

            if (nodes == null)
            {
                show.Episodes.Reverse();
                return show;
            }

            foreach (var node in nodes)
            {
                var season = Regex.Match(node.GetTextValue("../../a[@class='season_name toggle']") ?? "Season " + snr, "Season ([0-9]+)");
                var epnr   = Regex.Match(node.GetTextValue(".//div[@class='ep_info']") ?? string.Empty, "Episode ([0-9]+)");

                if (!season.Success || !epnr.Success) { continue; }

                var ep = new Episode();

                ep.Season  = season.Groups[1].Value.ToInteger();
                ep.Number  = epnr.Groups[1].Value.ToInteger();
                ep.Title   = HtmlEntity.DeEntitize(node.GetTextValue(".//a[@class='title']"));
                ep.Summary = HtmlEntity.DeEntitize(node.GetTextValue(".//div[@class='description']").Replace("&nbsp;", " ").Replace("moreless", string.Empty).Trim());
                ep.Picture = node.GetNodeAttributeValue(".//img[@class='thumb']", "src");
                ep.URL     = node.GetNodeAttributeValue(".//a[@class='title']", "href");

                if (!string.IsNullOrWhiteSpace(ep.URL))
                {
                    ep.URL = "http://www.tv.com" + ep.URL;
                }

                DateTime dt;
                ep.Airdate = DateTime.TryParseExact(node.GetTextValue(".//div[@class='date']") ?? string.Empty, "M/d/yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)
                             ? dt
                             : Utils.UnixEpoch;

                show.Episodes.Add(ep);
            }

            if (show.Episodes.Count != 0 && show.Episodes.Last().Season > 1)
            {
                snr   = show.Episodes.Last().Season - 1;
                epurl = "season-" + snr;
                goto grabSeason; // this is a baaad fix, but this plugin is deprecated now, so it's a temorary one.
            }

            show.Episodes.Reverse();
            return show;
        }
 /// <summary>
 /// Selects the show.
 /// </summary>
 /// <param name="show">The TV show.</param>
 public void SelectShow(TVShow show)
 {
     for (int i = 0; i < comboBox.Items.Count; i++)
     {
         if (comboBox.Items[i] is GuideDropDownTVShowItem && ((GuideDropDownTVShowItem)comboBox.Items[i]).Show == show)
         {
             comboBox.SelectedIndex = i;
             break;
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GuideDropDownTVShowItem"/> class.
 /// </summary>
 /// <param name="tvShow">The TV show.</param>
 public GuideDropDownTVShowItem(TVShow tvShow)
 {
     Show = tvShow;
 }
Exemple #43
0
 public TVShow[] ToArray()
 {
     TVShow[] shows = new TVShow[List.Count];
     List.CopyTo(shows, 0);
     return shows;
 }
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var summary = Utils.GetHTML("http://www.tv.com/shows/{0}/".FormatWith(id));
            var listing = Utils.GetHTML("http://www.tv.com/shows/{0}/episodes/?printable=1".FormatWith(id));
            var show    = new TVShow();

            show.Title       = HtmlEntity.DeEntitize(summary.DocumentNode.GetNodeAttributeValue("//meta[@property='og:title']", "content"));
            show.Source      = GetType().Name;
            show.SourceID    = id;
            show.Description = HtmlEntity.DeEntitize((summary.DocumentNode.GetTextValue("//div[@class='description']/span") ?? string.Empty).Replace("&nbsp;", " ").Replace("moreless", string.Empty).Trim());
            show.Genre       = Regex.Replace(summary.DocumentNode.GetTextValue("//div[contains(@class, 'categories')]") ?? string.Empty, @"\s+", string.Empty).Replace("Categories", string.Empty).Replace(",", ", ");
            show.Cover       = summary.DocumentNode.GetNodeAttributeValue("//meta[@property='og:image']", "content");
            show.Airing      = !Regex.IsMatch(summary.DocumentNode.GetTextValue("//div[@class='tagline']") ?? string.Empty, "ended");
            show.Runtime     = 30;
            show.Language    = "en";
            show.URL         = "http://www.tv.com/shows/{0}/".FormatWith(id);
            show.Episodes    = new List<Episode>();

            var airinfo = summary.DocumentNode.GetTextValue("//div[@class='tagline']");
            if (airinfo != null)
            {
                airinfo = Regex.Replace(airinfo, @"\s+", " ").Trim();

                var airday = Regex.Match(airinfo, @"(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)");
                if (airday.Success)
                {
                    show.AirDay = airday.Groups[1].Value;
                }

                var airtime = Regex.Match(airinfo, @"(\d{1,2}:\d{2}(?: (?:AM|PM))?)", RegexOptions.IgnoreCase);
                if (airtime.Success)
                {
                    show.AirTime = airtime.Groups[1].Value;
                }

                var network = Regex.Match(airinfo, @"(?:on (?<n>[^\s$\(]+)|(?<n>.*)\s\(ended)");
                if (network.Success)
                {
                    show.Network = network.Groups["n"].Value;
                }
            }

            var nodes = listing.DocumentNode.SelectNodes("//li[@class='episode']");
            if (nodes == null)
            {
                return show;
            }

            foreach (var node in nodes)
            {
                var season = Regex.Match(node.GetTextValue("dl[1]/dd[2]") ?? string.Empty, "([0-9]+)");
                var epnr   = Regex.Match(node.GetTextValue("dl[1]/dd[3]") ?? string.Empty, "([0-9]+)");

                if (!season.Success || !epnr.Success) { continue; }

                var ep = new Episode();

                ep.Season  = season.Groups[1].Value.ToInteger();
                ep.Number  = epnr.Groups[1].Value.ToInteger();
                ep.Title   = HtmlEntity.DeEntitize(node.GetTextValue("a[@class='title']"));
                ep.Summary = HtmlEntity.DeEntitize(node.GetTextValue("div[contains(@class,'description')]").Replace("&nbsp;", " ").Trim());
                ep.URL     = node.GetNodeAttributeValue("a[@class='title']", "href");

                if (!string.IsNullOrWhiteSpace(ep.URL))
                {
                    ep.URL = "http://www.tv.com" + ep.URL;

                    var epid = Regex.Match(ep.URL, @"\-(\d+)\/?$");
                    if (epid.Success)
                    {
                        ep.Picture = "http://img2.tvtome.com/i/tve/em/" + epid.Groups[1].Value + ".jpg";
                    }
                }

                DateTime dt;
                ep.Airdate = DateTime.TryParseExact(node.GetTextValue("dl[1]/dd[1]") ?? string.Empty, "M/d/yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)
                             ? dt
                             : Utils.UnixEpoch;

                show.Episodes.Add(ep);
            }

            show.Episodes.Reverse();
            return show;
        }
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var main = Utils.GetJSON(SignURL("http://app.imdb.com/title/maindetails?tconst=tt" + id));
            var show = new TVShow();

            show.Title       = (string)main["data"]["title"];
            show.Source      = GetType().Name;
            show.SourceID    = id;
            show.Description = (string)main["data"]["plot"]["outline"];
            show.Cover       = (string)main["data"]["image"]["url"];
            show.Airing      = (string)main["data"]["year_end"] == "????";
            show.Runtime     = (int)main["data"]["runtime"]["time"] / 60;
            show.Language    = "en";
            show.URL         = "http://www.imdb.com/title/tt" + id + "/";
            show.Episodes    = new List<Episode>();

            foreach (var genre in main["data"]["genres"])
            {
                show.Genre += (string)genre + ", ";
            }

            show.Genre = show.Genre.TrimEnd(", ".ToCharArray());

            var epdata = Utils.GetJSON(SignURL("http://app.imdb.com/title/episodes?tconst=tt" + id));

            foreach (var season in epdata["data"]["seasons"])
            {
                var snr = int.Parse((string)season["token"]);
                var enr = 0;

                foreach (var episode in season["list"])
                {
                    if (episode["type"] != "tv_episode") continue;
                    
                    var ep = new Episode();

                    ep.Season = snr;
                    ep.Number = ++enr;
                    ep.Title  = (string)episode["title"];
                    ep.URL    = "http://www.imdb.com/title/" + (string)episode["tconst"] + "/";
                    
                    DateTime dt;
                    ep.Airdate = DateTime.TryParseExact((string)episode["release_date"]["normal"] ?? string.Empty, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)
                               ? dt
                               : Utils.UnixEpoch;

                    show.Episodes.Add(ep);
                }
            }

            if (show.Episodes.Count != 0)
            {
                show.AirDay = show.Episodes.Last().Airdate.DayOfWeek.ToString();
            }

            return show;
        }
        /// <summary>
        /// Extracts the data available in the database.
        /// </summary>
        /// <param name="id">The ID of the show.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>TV show data.</returns>
        public override TVShow GetData(string id, string language = "en")
        {
            var info = Utils.GetXML("http://services.tvrage.com/myfeeds/showinfo.php?key={0}&sid={1}".FormatWith(Key, id), timeout: 120000);
            var list = Utils.GetXML("http://services.tvrage.com/myfeeds/episode_list.php?key={0}&sid={1}".FormatWith(Key, id), timeout: 120000);
            var show = new TVShow();

            show.Title       = info.GetValue("showname");
            show.Source      = GetType().Name;
            show.SourceID    = id;
            show.Description = info.GetValue("summary");
            show.Genre       = info.Descendants("genre").Aggregate(string.Empty, (current, g) => current + (g.Value + ", ")).TrimEnd(", ".ToCharArray());
            show.Cover       = info.GetValue("image");
            show.Airing      = !Regex.IsMatch(info.GetValue("status"), "(Canceled|Ended)");
            show.AirTime     = info.GetValue("airtime");
            show.AirDay      = info.GetValue("airday");
            show.Network     = info.GetValue("network");
            show.TimeZone    = info.GetValue("timezone");
            show.Language    = "en";
            show.URL         = info.GetValue("showlink");
            show.Episodes    = new List<Episode>();

            show.Runtime = (info.GetValue("runtime") ?? "20").ToInteger();
            show.Runtime = show.Runtime == 30
                           ? 20
                           : show.Runtime == 50 || show.Runtime == 60
                             ? 40
                             : show.Runtime;

            foreach (var node in list.Descendants("episode"))
            {
                int sn;
                try { sn = node.Parent.Attribute("no").Value.ToInteger(); }
                catch
                {
                    continue;
                }

                var ep = new Episode();

                ep.Season  = sn;
                ep.Number  = node.GetValue("seasonnum").ToInteger();
                ep.Title   = node.GetValue("title");
                ep.Summary = node.GetValue("summary");
                ep.Picture = node.GetValue("screencap");
                ep.URL     = node.GetValue("link");

                DateTime dt;
                ep.Airdate = DateTime.TryParse(node.GetValue("airdate"), out dt)
                           ? dt
                           : Utils.UnixEpoch;

                show.Episodes.Add(ep);
            }

            return show;
        }