コード例 #1
0
        protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
        {
            _proxy.AddTorrentFromUrl(magnetLink, Settings);

            var tries      = 10;
            var retryDelay = 500;

            if (WaitForTorrent(hash, tries, retryDelay))
            {
                _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings);

                SetPriority(remoteEpisode, hash);
                SetDownloadDirectory(hash);

                _proxy.StartTorrent(hash, Settings);

                return(hash);
            }
            else
            {
                _logger.Debug("rTorrent could not resolve magnet {0}. Removing", magnetLink);

                RemoveItem(hash, true);

                return(null);
            }
        }
コード例 #2
0
ファイル: RTorrent.cs プロジェクト: PearsonFlyer/Librarr
        protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
        {
            _proxy.AddTorrentFromUrl(magnetLink, Settings);

            // Download the magnet to the appropriate directory.
            _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings);
            SetPriority(remoteEpisode, hash);
            SetDownloadDirectory(hash);

            // Once the magnet meta download finishes, rTorrent replaces it with the actual torrent download with default settings.
            // Schedule an event to apply the appropriate settings when that happens.
            var priority = (RTorrentPriority)(remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority);

            _proxy.SetDeferredMagnetProperties(hash, Settings.TvCategory, Settings.TvDirectory, priority, Settings);

            _proxy.StartTorrent(hash, Settings);

            // Wait for the magnet to be resolved.
            var tries      = 10;
            var retryDelay = 500;

            if (WaitForTorrent(hash, tries, retryDelay))
            {
                return(hash);
            }
            else
            {
                _logger.Warn("rTorrent could not resolve magnet within {0} seconds, download may remain stuck: {1}.", tries * retryDelay / 1000, magnetLink);

                return(hash);
            }
        }
コード例 #3
0
        public override void MarkItemAsImported(DownloadClientItem downloadClientItem)
        {
            // Set post-import label
            if (Settings.TvImportedCategory.IsNotNullOrWhiteSpace() &&
                Settings.TvImportedCategory != Settings.TvCategory)
            {
                try
                {
                    _proxy.SetTorrentLabel(downloadClientItem.DownloadId.ToLower(), Settings.TvImportedCategory, Settings);
                }
                catch (Exception ex)
                {
                    _logger.Warn(ex, "Failed to set torrent post-import label \"{0}\" for {1} in rTorrent. Does the label exist?",
                                 Settings.TvImportedCategory, downloadClientItem.Title);
                }
            }

            // Set post-import view
            try
            {
                _proxy.PushTorrentUniqueView(downloadClientItem.DownloadId.ToLower(), _imported_view, Settings);
            }
            catch (Exception ex)
            {
                _logger.Warn(ex, "Failed to set torrent post-import view \"{0}\" for {1} in rTorrent.",
                             _imported_view, downloadClientItem.Title);
            }
        }
コード例 #4
0
        protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
        {
            _proxy.AddTorrentFromUrl(magnetLink, Settings);

            // Wait until url has been resolved before returning
            var TRIES       = 5;
            var RETRY_DELAY = 500; //ms
            var ready       = false;

            for (var i = 0; i < TRIES; i++)
            {
                ready = _proxy.HasHashTorrent(hash, Settings);
                if (ready)
                {
                    break;
                }

                Thread.Sleep(RETRY_DELAY);
            }

            if (ready)
            {
                _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings);

                SetPriority(remoteEpisode, hash);
                SetDownloadDirectory(hash);

                _proxy.StartTorrent(hash, Settings);

                return(hash);
            }
            else
            {
                _logger.Debug("Magnet {0} could not be resolved in {1} tries at {2} ms intervals.", magnetLink, TRIES, RETRY_DELAY);
                // Remove from client, since it is discarded
                RemoveItem(hash, true);

                return(null);
            }
        }