Exemple #1
0
        public async Task AddTorrentAsync(MovieMagnet magnet)
        {
            _logger?.LogInformation("Add Torrent for movie {movieNumber}: {hash}", magnet.MovieNumber, magnet.Hash);
            await EnsureLoggedInAsync();

            AddTorrentUrlsRequest request = new AddTorrentUrlsRequest(new Uri(magnet.MagnetUrl));
            await _client.AddTorrentsAsync(request);

            string savePath = Path.Combine(_qbittorrentSetting.DownloadRootPath, magnet.MovieNumber.ToUpper() + "_" + magnet.IdMovieMag);
            await _client.SetLocationAsync(magnet.Hash, savePath);

            await _client.SetTorrentCategoryAsync(magnet.Hash, _qbittorrentSetting.Category);

            magnet.IdStatus = MagnetStatus.Downloading;
            magnet.SavePath = savePath;
            magnet.DtStart  = DateTime.Now;
            _logger?.LogInformation("Add Torrent for movie {movieNumber} ended", magnet.MovieNumber);
        }
                protected override async Task <int> OnExecuteAuthenticatedAsync(QBittorrentClient client, CommandLineApplication app, IConsole console)
                {
                    var request = new AddTorrentFilesRequest(Files)
                    {
                        Category                   = Category,
                        Cookie                     = Cookie,
                        CreateRootFolder           = CreateRootFolder,
                        DownloadFolder             = Folder,
                        DownloadLimit              = DownloadLimit,
                        FirstLastPiecePrioritized  = FirstLastPiecePrioritized,
                        Paused                     = Paused,
                        Rename                     = Rename,
                        SequentialDownload         = SequentialDownload,
                        SkipHashChecking           = SkipChecking,
                        UploadLimit                = UploadLimit,
                        AutomaticTorrentManagement = AutomaticTorrentManagement
                    };
                    await client.AddTorrentsAsync(request);

                    await WarnAutomaticTorrentManagement(client, console);

                    return(ExitCodes.Success);
                }