Ejemplo n.º 1
0
        protected override void UpdateTorrentLinks(TvEpisodeTorrent torrent)
        {
            // Link is for page, need to get actual torrent
            WebClient pageClient = new WebClient();

            pageClient.Headers.Add("User-Agent: Other");

            Console.WriteLine("RARBG Pre  " + DateTime.Now.ToString());
            Limiter.DoWait();
            Console.WriteLine("RARBG Post  " + DateTime.Now.ToString());
            string page = pageClient.DownloadString(torrent.PageUrl);

            Regex torrentRegex = new Regex(@">\s*Torrent:\s*</td>.*?href=""(/download.php?[^\""]+)""");
            Regex magnetRegex  = new Regex(@">\s*Torrent:\s*</td>.*?href=""(magnet:[^""]+)""");

            Match torrentMatch = torrentRegex.Match(page);

            if (torrentMatch.Success)
            {
                torrent.File = BASE_URL + torrentMatch.Groups[1].Value;
            }

            Match magnetMatch = magnetRegex.Match(page);

            if (magnetMatch.Success)
            {
                torrent.Magnet = magnetMatch.Groups[1].Value;
            }
        }
Ejemplo n.º 2
0
        public override List <TvEpisodeTorrent> GetAvailableTvTorrents(TvEpisode episode)
        {
            // Download show episodes page
            string showPageUrl = BASE_URL + "/search/" + episode.BuildEpString().Replace(" ", "%20");

            Limiter.DoWait();

            WebClient client = new WebClient();

            client.Headers.Add("User-Agent: Other");
            string data = client.DownloadString(showPageUrl);

            Regex           baseRegex = new Regex("<div\\s+class=\\\"detName\\\">\\s+<a\\s+href=\\\"[^\\\"]+\\\"[^>]+>([^>]+)</a>\\s+</div>\\s+<a href=\\\"(magnet:[^\\\"]+)\\\"");
            MatchCollection matches   = baseRegex.Matches(data);

            List <TvEpisodeTorrent> torrents = new List <TvEpisodeTorrent>();

            foreach (Match match in matches)
            {
                string name   = match.Groups[1].Value;
                string magnet = match.Groups[2].Value;

                MatchCollection showMatches = episode.Show.MatchFileToContent(name);
                bool            matchShow   = showMatches != null && showMatches.Count > 0;

                int season, ep1, ep2;
                if (matchShow && FileHelper.GetEpisodeInfo(name, episode.Show.DisplayName, out season, out ep1, out ep2, true) && episode.Season == season && episode.DisplayNumber == ep1)
                {
                    // Don't want to get torrent with a bunch of episodes (double is okay)
                    if (ep2 > 0 && ep2 - ep1 > 1)
                    {
                        continue;
                    }

                    TorrentQuality quality = TorrentQuality.Sd480p;
                    if (name.ToLower().Contains("720p"))
                    {
                        quality = TorrentQuality.Hd720p;
                    }
                    else if (name.ToLower().Contains("1080p"))
                    {
                        quality = TorrentQuality.Hd1080p;
                    }

                    TvEpisodeTorrent torrentEp = new TvEpisodeTorrent();
                    torrentEp.Url      = showPageUrl;
                    torrentEp.Season   = season;
                    torrentEp.Episode  = ep1;
                    torrentEp.Episode2 = ep2;
                    torrentEp.Quality  = quality;
                    torrentEp.Title    = name;
                    torrentEp.Magnet   = magnet;

                    torrents.Add(torrentEp);
                }
            }

            return(torrents);
        }
Ejemplo n.º 3
0
 public TvEpisodeTorrent(TvEpisodeTorrent clone)
 {
     this.Url      = clone.Url;
     this.Season   = clone.Season;
     this.Episode  = clone.Episode;
     this.Episode2 = clone.Episode2;
     this.Quality  = clone.Quality;
     this.Flag     = clone.Flag;
     this.File     = clone.File;
     this.Magnet   = clone.Magnet;
 }
Ejemplo n.º 4
0
 public TvEpisodeTorrent(TvEpisodeTorrent clone)
 {
     this.Url = clone.Url;
     this.Season = clone.Season;
     this.Episode = clone.Episode;
     this.Episode2 = clone.Episode2;
     this.Quality = clone.Quality;
     this.Flag = clone.Flag;
     this.File = clone.File;
     this.Magnet = clone.Magnet;
 }
Ejemplo n.º 5
0
 public static TvEpisodeTorrent GetEpisodeTorrent(TvEpisode episode)
 {
     try
     {
         PirateBayTorrentSite site    = new PirateBayTorrentSite();
         TvEpisodeTorrent     torrent = site.GetBestTvTorrent(episode);
         return(torrent);
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 6
0
        protected override void UpdateTorrentLinks(TvEpisodeTorrent torrent)
        {
            // Link is for page, need to get actual torrent
            WebClient pageClient = new WebClient();
            pageClient.Headers.Add("User-Agent: Other");
            string page = pageClient.DownloadString(torrent.PageUrl);

            Regex torrentRegex = new Regex(@">\s*Torrent:\s*</td>.*?href=""(/download.php?[^\""]+)""");
            Regex magnetRegex = new Regex(@">\s*Torrent:\s*</td>.*?href=""(magnet:[^""]+)""");

            Match torrentMatch = torrentRegex.Match(page);
            if (torrentMatch.Success)
                torrent.File = BASE_URL + torrentMatch.Groups[1].Value;

            Match magnetMatch = magnetRegex.Match(page);
            if (magnetMatch.Success)
                torrent.Magnet = magnetMatch.Groups[1].Value;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Run through all TV shows all looks for episodes that may need to be renamed and for missing episodes.
        /// For missing episodes it attempts to match them to files from the search directories.
        /// </summary>
        /// <param name="shows">Shows to scan</param>
        /// <param name="queuedItems">Items currently in queue (to be skipped)</param>
        /// <returns></returns>
        public List <OrgItem> RunScan(List <Content> shows, List <OrgItem> queuedItems, bool fast)
        {
            // Set running flag
            scanRunning     = true;
            cancelRequested = false;

            // Do directory check on all directories (to look for missing episodes)
            while (!TvItemInScanDirHelper.Initialized)
            {
                Thread.Sleep(100);
            }

            List <OrgItem> directoryItems = TvItemInScanDirHelper.Items;

            // Initialiaze scan items
            List <OrgItem> missingCheckItem = new List <OrgItem>();

            // Initialize item numbers
            int number = 0;

            double progressPerShow = 1D / shows.Count * 100D;

            // Go through each show
            for (int i = 0; i < shows.Count; i++)
            {
                TvShow show = (TvShow)shows[i];

                if (cancelRequested)
                {
                    break;
                }

                double showsProgress = (double)i * progressPerShow;
                OnProgressChange(ScanProcess.TvMissing, shows[i].DatabaseName, (int)Math.Round(showsProgress));

                double progressPerEp = 1D / show.Episodes.Count * progressPerShow;

                // Go through missing episodes
                for (int j = 0; j < show.Episodes.Count; j++)
                {
                    // Get episode
                    TvEpisode ep = show.Episodes[j];

                    // Update progress
                    OnProgressChange(ScanProcess.TvMissing, shows[i].DatabaseName, (int)Math.Round(showsProgress + j * progressPerEp));

                    // Check for cancellation
                    if (cancelRequested)
                    {
                        break;
                    }

                    // Skipped ignored episodes
                    if (ep.Ignored || !show.DoMissingCheck)
                    {
                        continue;
                    }

                    // Init found flag
                    bool found = false;

                    // Check if episode is missing
                    if (ep.Missing == MissingStatus.Missing || ep.Missing == MissingStatus.InScanDirectory)
                    {
                        // Check directory item for episode
                        foreach (OrgItem item in directoryItems)
                        {
                            if ((item.Action == OrgAction.Move || item.Action == OrgAction.Copy) && item.TvEpisode != null && item.TvEpisode.Show.DatabaseName == show.DatabaseName)
                            {
                                // Only add item for first part of multi-part file
                                if (ep.Equals(item.TvEpisode))
                                {
                                    OrgItem newItem = new OrgItem(OrgStatus.Found, item.Action, item.SourcePath, item.DestinationPath, ep, item.TvEpisode2, FileCategory.TvVideo, item.ScanDirectory);
                                    newItem.Enable = true;
                                    newItem.Number = number++;
                                    if (!show.DoMissingCheck)
                                    {
                                        newItem.Category = FileCategory.Ignored;
                                    }
                                    missingCheckItem.Add(newItem);
                                    found = true;
                                    break;
                                }
                                else if (ep.Equals(item.TvEpisode2))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }

                    // Add empty item for missing
                    if (!found && ep.Aired && show.DoMissingCheck)
                    {
                        OrgItem          newItem;
                        TvEpisodeTorrent ezTvEpisode = TvTorrentHelper.GetEpisodeTorrent(ep);
                        if (ezTvEpisode != null)
                        {
                            newItem = new OrgItem(OrgStatus.Missing, OrgAction.Torrent, ep, null, FileCategory.TvVideo, null);
                            newItem.BuildDestination();
                        }
                        else
                        {
                            newItem = new OrgItem(OrgStatus.Missing, OrgAction.None, ep, null, FileCategory.TvVideo, null);
                        }

                        newItem.Number = number++;
                        missingCheckItem.Add(newItem);
                    }
                }
            }

            // Update progress
            OnProgressChange(ScanProcess.TvMissing, string.Empty, 100);

            // Clear flags
            scanRunning = false;

            // Return results
            return(missingCheckItem);
        }
Ejemplo n.º 8
0
 protected virtual void UpdateTorrentLinks(TvEpisodeTorrent torrent)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
        public TvEpisodeTorrent GetBestTvTorrent(TvEpisode episode)
        {
            List <TvEpisodeTorrent> availableTorrents = GetAvailableTvTorrents(episode);

            if (availableTorrents.Count == 0)
            {
                return(null);
            }

            Dictionary <TorrentQuality, TvEpisodeTorrent> qualityTorrents = new Dictionary <TorrentQuality, TvEpisodeTorrent>();

            foreach (TvEpisodeTorrent torrent in availableTorrents)
            {
                TorrentQuality quality = torrent.Quality;

                if (!qualityTorrents.ContainsKey(quality))
                {
                    qualityTorrents.Add(quality, null);
                }

                if (qualityTorrents[quality] == null)
                {
                    qualityTorrents[quality] = torrent;
                }
            }

            // Go through matches to find closest quality to preferred
            TorrentQuality closestQuality = TorrentQuality.Sd480p;

            if (qualityTorrents.ContainsKey(Settings.General.PreferredTorrentQuality))
            {
                closestQuality = Settings.General.PreferredTorrentQuality;
            }
            else
            {
                switch (Settings.General.PreferredTorrentQuality)
                {
                case TorrentQuality.Sd480p:
                    if (qualityTorrents.ContainsKey(TorrentQuality.Hd720p))
                    {
                        closestQuality = TorrentQuality.Hd720p;
                    }
                    else
                    {
                        closestQuality = TorrentQuality.Hd1080p;
                    }
                    break;

                case TorrentQuality.Hd720p:
                    if (qualityTorrents.ContainsKey(TorrentQuality.Sd480p))
                    {
                        closestQuality = TorrentQuality.Sd480p;
                    }
                    else
                    {
                        closestQuality = TorrentQuality.Hd1080p;
                    }
                    break;

                case TorrentQuality.Hd1080p:
                    if (qualityTorrents.ContainsKey(TorrentQuality.Hd720p))
                    {
                        closestQuality = TorrentQuality.Hd720p;
                    }
                    else
                    {
                        closestQuality = TorrentQuality.Sd480p;
                    }
                    break;

                default:
                    throw new Exception("Unknown torrent quality");
                }
            }

            TvEpisodeTorrent closestTorrent = qualityTorrents[closestQuality];

            UpdateTorrentLinks(closestTorrent);

            return(closestTorrent);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Constructor for TV rename/missing check where file was not found.
 /// </summary>
 /// <param name="status">Status of rename/missing</param>
 /// <param name="action">action to be performed</param>
 /// <param name="episode">TV episode for file</param>
 /// <param name="episode2">2nd Tv epsidoe for file</param>
 /// <param name="category">file category</param>
 public OrgItem(OrgStatus status, OrgAction action, TvEpisode episode, TvEpisode episode2, FileCategory category, OrgFolder scanDir, TvEpisodeTorrent torrentEp)
     : this()
 {
     this.Status = status;
     this.Progress = 0;
     this.Action = action;
     this.SourcePath = string.Empty;
     if (action == OrgAction.Delete)
         this.DestinationPath = FileHelper.DELETE_DIRECTORY;
     else
         this.DestinationPath = string.Empty;
     this.TvEpisode = new TvEpisode(episode);
     if (episode2 != null)
         this.TvEpisode2 = new TvEpisode(episode2);
     this.TorrentTvEpisode = torrentEp;
     this.Category = category;
     this.Enable = action == OrgAction.Torrent;
     this.ScanDirectory = scanDir;
     this.Number = 0;
 }
Ejemplo n.º 11
0
        public static async Task <TvEpisodeTorrent> GetEpisodeTorrentAsync(TvEpisode episode)
        {
            TvEpisodeTorrent result = await Task.Run(() => GetEpisodeTorrent(episode));

            return(result);
        }
Ejemplo n.º 12
0
        public override List <TvEpisodeTorrent> GetAvailableTvTorrents(TvEpisode episode)
        {
            // Download show episodes page
            string showPageUrl = BASE_URL + "/torrents.php?search=" + episode.BuildEpString().Replace(" ", "+");

            Console.WriteLine("RARBG Pre  " + DateTime.Now.ToString());
            Limiter.DoWait();
            Console.WriteLine("RARBG Post  " + DateTime.Now.ToString());

            WebClient client = new WebClient();

            client.Headers.Add("User-Agent: Other");
            string data = client.DownloadString(showPageUrl);

            Regex baseRegex = new Regex(@"<tr\s+class=.lista2.>\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*</tr>");

            Regex titleRegex = new Regex(@"title=""([^""]+)""");
            Regex urlRegex   = new Regex("href=\"(/torrent/[^\"]+)\"");

            Regex sizeRegex = new Regex(@">(\S+)\s+MB<");

            MatchCollection matches = baseRegex.Matches(data);

            List <TvEpisodeTorrent> torrents = new List <TvEpisodeTorrent>();

            foreach (Match match in matches)
            {
                string name;
                Match  titleMatch = titleRegex.Match(match.Groups[2].Value);
                if (titleMatch.Success)
                {
                    name = titleMatch.Groups[1].Value;
                }
                else
                {
                    continue;
                }

                string pageUrl;
                Match  urlMatch = urlRegex.Match(match.Groups[2].Value);
                if (urlMatch.Success)
                {
                    pageUrl = BASE_URL + urlMatch.Groups[1].Value;
                }
                else
                {
                    continue;
                }

                MatchCollection showMatches = episode.Show.MatchFileToContent(name);
                bool            matchShow   = showMatches != null && showMatches.Count > 0;

                int season, ep1, ep2;
                if (matchShow && FileHelper.GetEpisodeInfo(name, episode.Show.DisplayName, out season, out ep1, out ep2, true) && episode.Season == season && episode.DisplayNumber == ep1)
                {
                    // Don't want to get torrent with a bunch of episodes (double is okay)
                    if (ep2 > 0 && ep2 - ep1 > 1)
                    {
                        continue;
                    }

                    TorrentQuality quality = TorrentQuality.Sd480p;
                    if (name.ToLower().Contains("720p"))
                    {
                        quality = TorrentQuality.Hd720p;
                    }
                    else if (name.ToLower().Contains("1080p"))
                    {
                        quality = TorrentQuality.Hd1080p;
                    }

                    TvEpisodeTorrent torrentEp = new TvEpisodeTorrent();
                    torrentEp.Url      = showPageUrl;
                    torrentEp.Season   = season;
                    torrentEp.Episode  = ep1;
                    torrentEp.Episode2 = ep2;
                    torrentEp.Quality  = quality;
                    torrentEp.Title    = name;
                    torrentEp.PageUrl  = pageUrl;

                    torrents.Add(torrentEp);
                }
            }

            return(torrents);
        }
Ejemplo n.º 13
0
 protected virtual void UpdateTorrentLinks(TvEpisodeTorrent torrent)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
 protected override void UpdateTorrentLinks(TvEpisodeTorrent torrent)
 {
 }
Ejemplo n.º 15
0
        public override List<TvEpisodeTorrent> GetAvailableTvTorrents(TvEpisode episode)
        {
            // Download show episodes page
            string showPageUrl = BASE_URL + "/torrents.php?search=" + episode.BuildEpString().Replace(" ", "+");
            WebClient client = new WebClient();
            client.Headers.Add("User-Agent: Other");
            string data = client.DownloadString(showPageUrl);

            Regex baseRegex = new Regex(@"<tr\s+class=.lista2.>\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*(<td.*?/td>)\s*</tr>");

            Regex titleRegex = new Regex(@"title=""([^""]+)""");
            Regex urlRegex = new Regex("href=\"(/torrent/[^\"]+)\"");

            Regex sizeRegex = new Regex(@">(\S+)\s+MB<");

            MatchCollection matches = baseRegex.Matches(data);

            List<TvEpisodeTorrent> torrents = new List<TvEpisodeTorrent>();
            foreach (Match match in matches)
            {
                string name;
                Match titleMatch = titleRegex.Match(match.Groups[2].Value);
                if (titleMatch.Success)
                    name = titleMatch.Groups[1].Value;
                else
                    continue;

                string pageUrl;
                Match urlMatch = urlRegex.Match(match.Groups[2].Value);
                if (urlMatch.Success)
                    pageUrl = BASE_URL + urlMatch.Groups[1].Value;
                else
                    continue;

                MatchCollection showMatches = episode.Show.MatchFileToContent(name);
                bool matchShow = showMatches != null && showMatches.Count > 0;

                int season, ep1, ep2;
                if (matchShow && FileHelper.GetEpisodeInfo(name, episode.Show.DisplayName, out season, out ep1, out ep2, true) && episode.Season == season && episode.DisplayNumber == ep1)
                {
                    // Don't want to get torrent with a bunch of episodes (double is okay)
                    if (ep2 > 0 && ep2 - ep1 > 1)
                        continue;

                    TorrentQuality quality = TorrentQuality.Sd480p;
                    if (name.ToLower().Contains("720p"))
                        quality = TorrentQuality.Hd720p;
                    else if (name.ToLower().Contains("1080p"))
                        quality = TorrentQuality.Hd1080p;

                    TvEpisodeTorrent torrentEp = new TvEpisodeTorrent();
                    torrentEp.Url = showPageUrl;
                    torrentEp.Season = season;
                    torrentEp.Episode = ep1;
                    torrentEp.Episode2 = ep2;
                    torrentEp.Quality = quality;
                    torrentEp.Title = name;
                    torrentEp.PageUrl = pageUrl;

                    torrents.Add(torrentEp);
                }
            }

            return torrents;
        }