Exemplo n.º 1
0
        public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
        {
            try
            {
                title = MediaFileProvider.CleanFilename(title);

                var filename = Path.Combine(_configProvider.BlackholeDirectory, title + ".nzb");

                if (_diskProvider.FileExists(filename))
                {
                    //Return true so a lesser quality is not returned.
                    logger.Info("NZB already exists on disk: {0}", filename);
                    return(true);
                }

                logger.Trace("Downloading NZB from: {0} to: {1}", url, filename);
                _httpProvider.DownloadFile(url, filename);

                logger.Trace("NZB Download succeeded, saved to: {0}", filename);
                return(true);
            }
            catch (Exception ex)
            {
                logger.WarnException("Failed to download NZB: " + url, ex);
                return(false);
            }
        }
Exemplo n.º 2
0
        public virtual bool Download(Series series)
        {
            var bannerPath = _environmentProvider.GetBannerPath();

            logger.Trace("Ensuring Banner Folder exists: ", bannerPath);
            _diskProvider.CreateDirectory(bannerPath);

            var bannerFilename = Path.Combine(bannerPath, series.SeriesId.ToString()) + ".jpg";

            logger.Trace("Downloading banner for '{0}'", series.Title);

            try
            {
                _httpProvider.DownloadFile(BANNER_URL_PREFIX + series.BannerUrl, bannerFilename);
                logger.Trace("Successfully download banner for '{0}'", series.Title);
            }
            catch (Exception)
            {
                logger.Debug("Failed to download banner for '{0}'", series.Title);
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public virtual void Start(ProgressNotification notification, dynamic options)
        {
            notification.CurrentMessage = "Checking for updates";

            var updatePackage = _updateProvider.GetAvilableUpdate(_environmentProvider.Version);

            //No updates available
            if (updatePackage == null)
            {
                return;
            }

            var packageDestination = Path.Combine(_environmentProvider.GetUpdateSandboxFolder(), updatePackage.FileName);

            if (_diskProvider.FolderExists(_environmentProvider.GetUpdateSandboxFolder()))
            {
                logger.Info("Deleting old update files");
                _diskProvider.DeleteFolder(_environmentProvider.GetUpdateSandboxFolder(), true);
            }

            logger.Info("Downloading update package from [{0}] to [{1}]", updatePackage.Url, packageDestination);
            notification.CurrentMessage = "Downloading Update " + updatePackage.Version;
            _httpProvider.DownloadFile(updatePackage.Url, packageDestination);
            logger.Info("Download completed for update package from [{0}]", updatePackage.FileName);

            logger.Info("Extracting Update package");
            notification.CurrentMessage = "Extracting Update";
            _archiveProvider.ExtractArchive(packageDestination, _environmentProvider.GetUpdateSandboxFolder());
            logger.Info("Update package extracted successfully");

            logger.Info("Preparing client");
            notification.CurrentMessage = "Preparing to start Update";
            _diskProvider.MoveDirectory(_environmentProvider.GetUpdateClientFolder(), _environmentProvider.GetUpdateSandboxFolder());


            logger.Info("Starting update client");
            var startInfo = new ProcessStartInfo
            {
                FileName  = _environmentProvider.GetUpdateClientExePath(),
                Arguments = string.Format("{0} {1}", _environmentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid)
            };

            var process = _processProvider.Start(startInfo);

            notification.CurrentMessage = "Update in progress. NzbDrone will restart shortly.";

            _processProvider.WaitForExit(process);
        }
        public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
        {
            try
            {
                //Todo: Allow full season releases
                if (Parser.ParseTitle(title).FullSeason)
                {
                    logger.Info("Skipping Full Season Release: {0}", title);
                    return(false);
                }

                title = MediaFileProvider.CleanFilename(title);

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

                if (_diskProvider.FileExists(filename))
                {
                    //Return true so a lesser quality is not returned.
                    logger.Info("NZB already exists on disk: {0}", filename);
                    return(true);
                }

                logger.Trace("Downloading NZB from: {0} to: {1}", url, filename);
                _httpProvider.DownloadFile(url, filename);

                logger.Trace("NZB Download succeeded, saved to: {0}", filename);

                var contents = String.Format("plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb={0}&nzbname={1}", filename, title);
                _diskProvider.WriteAllText(Path.Combine(_configProvider.DownloadClientTvDirectory, title + ".strm"), contents);

                return(true);
            }
            catch (Exception ex)
            {
                logger.WarnException("Failed to download NZB: " + url, ex);
                return(false);
            }
        }