private async Task<string> DownloadFromWebUrl(ReleaseInfo release, IIndexer indexer, string torrentUrl)
        {
            byte[] torrentFile = null;

            torrentFile = await indexer.Download(new Uri(torrentUrl));

            // handle magnet URLs
            if (torrentFile.Length >= 7
                && torrentFile[0] == 0x6d
                && torrentFile[1] == 0x61
                && torrentFile[2] == 0x67
                && torrentFile[3] == 0x6e
                && torrentFile[4] == 0x65
                && torrentFile[5] == 0x74
                && torrentFile[6] == 0x3a)
            {
                var magnetUrl = Encoding.UTF8.GetString(torrentFile);
                return DownloadFromMagnetUrl(release, magnetUrl);
            }

            var filename = string.Format("{0}.torrent", StringUtil.CleanFileName(release.Title));
            var hash = _torrentFileInfoReader.GetHashFromTorrentFile(torrentFile);
            var actualHash = AddFromTorrentFile(release, hash, filename, torrentFile);

            if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash)
            {
                _logger.Debug(
                    "{0} did not return the expected InfoHash for '{1}', Prowlarr could potentially lose track of the download in progress.",
                    Definition.Implementation,
                    release.DownloadUrl);
            }

            return actualHash;
        }
Beispiel #2
0
        public override async Task <string> Download(ReleaseInfo release, bool redirect, IIndexer indexer)
        {
            var url = new Uri(release.DownloadUrl);

            if (redirect)
            {
                return(AddFromLink(release));
            }

            var filename = StringUtil.CleanFileName(release.Title) + ".nzb";

            byte[] nzbData;

            nzbData = await indexer.Download(url);

            _logger.Info("Adding report [{0}] to the queue.", release.Title);
            return(AddFromNzbFile(release, filename, nzbData));
        }
Beispiel #3
0
        public override async Task <string> Download(ReleaseInfo release, bool redirect, IIndexer indexer)
        {
            var url   = new Uri(release.DownloadUrl);
            var title = release.Title;

            title = StringUtil.CleanFileName(title);

            //Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC)
            var nzbFile = Path.Combine(Settings.NzbFolder, title + ".nzb");

            _logger.Debug("Downloading NZB from: {0} to: {1}", url, nzbFile);

            var nzbData = await indexer.Download(url);

            File.WriteAllBytes(nzbFile, nzbData);

            _logger.Debug("NZB Download succeeded, saved to: {0}", nzbFile);

            var strmFile = WriteStrmFile(title, nzbFile);

            return(GetDownloadClientId(strmFile));
        }