示例#1
0
文件: Parser.cs 项目: conradkoh/Buddy
 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;
 }
示例#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;
        }
示例#3
0
 public bool HasMoreCommentsThan(Episode ep)
 {
     if (_commentCount > ep._commentCount)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
示例#4
0
文件: Series.cs 项目: conradkoh/Buddy
 public void Load(string latestViewedEpisodeData)
 {
     Episode ep = new Episode();
     ep.DecodeAndLoad(latestViewedEpisodeData);
     if (ep.IsValid())
     {
         _title = ep.Title().Trim();
         latestViewedEpisode = ep;
         latestEpisodeInSeries = ep;
     }
 }
示例#5
0
文件: Series.cs 项目: conradkoh/Buddy
 public NewEpisodeEventArgs(Episode ep)
 {
     episode = ep;
 }
示例#6
0
文件: Series.cs 项目: conradkoh/Buddy
 public BetterEpisodeEventArgs(Episode oldEp, Episode newEp)
 {
     oldEpisode = oldEp;
     newEpisode = newEp;
 }
示例#7
0
文件: Series.cs 项目: conradkoh/Buddy
 void SetLatestWatched()
 {
     foreach (Episode ep in unwatchedEpisodes)
     {
         if (latestViewedEpisode == null || ep.IsNewerThan(latestViewedEpisode))
         {
             latestViewedEpisode = ep;
         }
     }
 }
示例#8
0
文件: Series.cs 项目: conradkoh/Buddy
 void SetLatestInSeries()
 {
     foreach(Episode ep in unwatchedEpisodes)
     {
         if(latestEpisodeInSeries == null || ep.IsNewerThan(latestEpisodeInSeries))
         {
             latestEpisodeInSeries = ep;
         }
     }
 }
示例#9
0
文件: Series.cs 项目: conradkoh/Buddy
        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));
        }
示例#10
0
文件: Series.cs 项目: conradkoh/Buddy
 public void SetLatestViewedEpisode(int season, int episode)
 {
     latestViewedEpisode = new Episode(_title, "", season, episode, -1);
 }
示例#11
0
文件: Series.cs 项目: conradkoh/Buddy
        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;
        }
示例#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;
     }
 }
示例#13
0
 public bool IsSameEpisodeAs(Episode ep)
 {
     if(_title.ToLower() == ep.Title().ToLower() && _episode == ep._episode && _season == ep._season)
     {
         return true;
     }
     else
     {
         return false;
     }
 }