Esempio n. 1
0
 public List<Episode> Parse(string htmlData)
 {
     List<string> cells = Conrad_Lib.StaticFunctions.RegexMatch(htmlData, "<TR(.|\\s)+?<\\/TR>");
     List<Episode> episodeList = new List<Episode>();
     foreach (string cell in cells)
     {
         string comment = Conrad_Lib.StaticFunctions.FirstRegexMatch(cell, "<A class=\"icommentjs.+?<\\/A>").Trim();
         string commentCount_s = Conrad_Lib.StaticFunctions.FirstRegexMatch(comment, "(?<=>)[0-9]+").Trim();
         List<string> title_tokens = Conrad_Lib.StaticFunctions.RegexMatch(cell, "(?<=STRONG class=red>).+?(?=<)");
         string title = String.Join(" ", title_tokens);
         string magnetLink = Conrad_Lib.StaticFunctions.FirstRegexMatch(cell, "magnet:\\?[^\"]+").Trim();
         string details = Conrad_Lib.StaticFunctions.FirstRegexMatch(cell, "(?<=<\\/strong>)(.|s)+?(?=<\\/a>)").Trim();
         string episodeID = Conrad_Lib.StaticFunctions.FirstRegexMatch(cell, "[s|S][0-9][0-9][e|E][0-9][0-9]").ToUpper().Trim();
         string season_s = Conrad_Lib.StaticFunctions.FirstRegexMatch(episodeID, "(?<=[s|S])[0-9][0-9](?=[e|E])").Trim();
         string episode_s = Conrad_Lib.StaticFunctions.FirstRegexMatch(episodeID, "(?<=[e|E])[0-9][0-9]").Trim();
         int season = -1;
         int episode = -1;
         int commentCount = -1;
         int.TryParse(season_s, out season);
         int.TryParse(episode_s, out episode);
         int.TryParse(commentCount_s, out commentCount);
         Buddy.Objects.Torrent.Episode curEp = new Buddy.Objects.Torrent.Episode(title,magnetLink, season, episode, commentCount);
         episodeList.Add(curEp);
        // result += "title: " + title + " episode: " + episode + " comments: " + commentCount + System.Environment.NewLine;
     }
     return episodeList;
 }
Esempio n. 2
0
        public static List<Episode> IdentifyEpisodes(string htmlData)
        {
            List<string> cells = Conrad_Lib.StaticFunctions.RegexMatch(htmlData, Constants.CELL_HEADER_REGEX);
            List<Episode> episodeList = new List<Episode>();
            foreach (string cell in cells)
            {
                string comment = Conrad_Lib.StaticFunctions.FirstRegexMatch(cell, Constants.COMMENT_HEADER_REGEX).Trim();
                string commentCount_s = Conrad_Lib.StaticFunctions.FirstRegexMatch(comment, Constants.TITLE_HEADER_REGEX).Trim();
                List<string> title_tokens = Conrad_Lib.StaticFunctions.RegexMatch(cell, Constants.TITLE_HEADER_REGEX);
                string title = String.Join(" ", title_tokens);
                string magnetLink = Conrad_Lib.StaticFunctions.FirstRegexMatch(cell, Constants.MAGNETLINK_REGEX).Trim();
                string details = Conrad_Lib.StaticFunctions.FirstRegexMatch(cell, Constants.DETAILS_REGEX).Trim();
                string episodeID = Conrad_Lib.StaticFunctions.FirstRegexMatch(cell, Constants.EPISODEID_REGEX).ToUpper().Trim();
                string season_s = Conrad_Lib.StaticFunctions.FirstRegexMatch(episodeID, Constants.EPISODEID_SEASON_REGEX).Trim();
                string episode_s = Conrad_Lib.StaticFunctions.FirstRegexMatch(episodeID, Constants.EPISODEID_EPISODE_REGEX).Trim();

                int season = -1;
                int episode = -1;
                int commentCount = -1;
                int.TryParse(season_s, out season);
                int.TryParse(episode_s, out episode);
                int.TryParse(commentCount_s, out commentCount);
                Episode curEp = new Episode(title, magnetLink, season, episode, commentCount);
                episodeList.Add(curEp);
                // result += "title: " + title + " episode: " + episode + " comments: " + commentCount + System.Environment.NewLine;
            }
            return episodeList;
        }
Esempio n. 3
0
 public bool HasMoreCommentsThan(Episode ep)
 {
     if (_commentCount > ep._commentCount)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 4
0
 public void Load(string latestViewedEpisodeData)
 {
     Episode ep = new Episode();
     ep.DecodeAndLoad(latestViewedEpisodeData);
     if (ep.IsValid())
     {
         _title = ep.Title().Trim();
         latestViewedEpisode = ep;
         latestEpisodeInSeries = ep;
     }
 }
Esempio n. 5
0
 public NewEpisodeEventArgs(Episode ep)
 {
     episode = ep;
 }
Esempio n. 6
0
 public BetterEpisodeEventArgs(Episode oldEp, Episode newEp)
 {
     oldEpisode = oldEp;
     newEpisode = newEp;
 }
Esempio n. 7
0
 void SetLatestWatched()
 {
     foreach (Episode ep in unwatchedEpisodes)
     {
         if (latestViewedEpisode == null || ep.IsNewerThan(latestViewedEpisode))
         {
             latestViewedEpisode = ep;
         }
     }
 }
Esempio n. 8
0
 void SetLatestInSeries()
 {
     foreach(Episode ep in unwatchedEpisodes)
     {
         if(latestEpisodeInSeries == null || ep.IsNewerThan(latestEpisodeInSeries))
         {
             latestEpisodeInSeries = ep;
         }
     }
 }
Esempio n. 9
0
        private void ScanForNewFromList(List<Episode> unknownEpisodes)
        {
            int newEpisodesFound = 0;

            foreach (Episode unknownEp in unknownEpisodes)
            {
                if(unknownEp.Title().ToLower() == _title.ToLower()) //Check titles
                {
                    if(unknownEp.IsNewerThan(latestViewedEpisode) && unknownEp.IsValid()) //Check if newer
                    {
                        bool isRepeatedEpisode = false;
                        bool betterVersionFound = false;
                        foreach(Episode unwatchedEpisode in unwatchedEpisodes)
                        {
                            if (unwatchedEpisode.IsSameEpisodeAs(unknownEp)) //Check if repeat
                            {
                                isRepeatedEpisode = true;
                                if (unknownEp.HasMoreCommentsThan(unwatchedEpisode)) //if repeated, check if better
                                {
                                    betterVersionFound = true;
                                    BetterEpisodeFound(this, new BetterEpisodeEventArgs(unwatchedEpisode, unknownEp));
                                    unwatchedEpisodes.Remove(unwatchedEpisode);
                                    unwatchedEpisodes.Add(unknownEp);
                                }
                            }
                        }
                        if(!isRepeatedEpisode && !betterVersionFound) //not repeated and not better
                        {
                            newEpisodesFound++;
                            NewEpisodeFound(this, new NewEpisodeEventArgs(unknownEp));
                            latestEpisodeInSeries = unknownEp;
                            unwatchedEpisodes.Add(unknownEp);
                        }
                    }
                }
            }
            CompletedScan(this, new ScanCompletedEventArgs(unknownEpisodes.Count(), newEpisodesFound));
        }
Esempio n. 10
0
 public void SetLatestViewedEpisode(int season, int episode)
 {
     latestViewedEpisode = new Episode(_title, "", season, episode, -1);
 }
Esempio n. 11
0
        public List<Episode> ScanForNew(List<Episode> newEpisodeList)
        {
            int episodesScanned = 0;
            int newEpisodesCount = 0;
            foreach (Episode curEp in newEpisodeList)
            {
                episodesScanned += 1;
                if (curEp.IsNewerThan(latestViewedEpisode) && curEp.IsValid())
                {
                    bool isRepeatEpisode = false;
                    bool betterVersionFound = false;
                    foreach(Episode unwatchedEp in unwatchedEpisodes)
                    {
                        if (unwatchedEp.IsSameEpisodeAs(curEp))
                        {
                            isRepeatEpisode = true;
                            if (curEp.HasMoreCommentsThan(unwatchedEp))
                            {
                                newEpisodesCount++;
                                BetterEpisodeFound(this, new BetterEpisodeEventArgs(unwatchedEp, curEp));
                                latestEpisodeInSeries = curEp;
                                unwatchedEpisodes.Remove(unwatchedEp);
                                unwatchedEpisodes.Add(curEp);
                                betterVersionFound = true;
                                break;
                            }
                        }
                    }
                    if (!isRepeatEpisode && !betterVersionFound)
                    {
                        newEpisodesCount++;
                        NewEpisodeFound(this, new NewEpisodeEventArgs(curEp));
                        latestEpisodeInSeries = curEp;
                        unwatchedEpisodes.Add(curEp);
                    }

                }
            }

            CompletedScan(this, new ScanCompletedEventArgs(episodesScanned, newEpisodesCount));
            return unwatchedEpisodes;
        }
Esempio n. 12
0
 public bool IsNewerThan(Episode ep)
 {
     if (_title.ToLower() == ep._title.ToLower())
     {
         if (_season > ep._season)
         {
             return true;
         }
         else if (_season < ep._season)
         {
             return false;
         }
         else //if (_season == ep._season)
         {
             if (_episode > ep._episode)
             {
                 return true;
             }
             else
             {
                 return false;
             }
         }
     }
     else
     {
         return false;
     }
 }
Esempio n. 13
0
 public bool IsSameEpisodeAs(Episode ep)
 {
     if(_title.ToLower() == ep.Title().ToLower() && _episode == ep._episode && _season == ep._season)
     {
         return true;
     }
     else
     {
         return false;
     }
 }