Ejemplo n.º 1
0
 private void LoadCatalog()
 {
     _rootCatalog = _opdsClient.GetRootPage(out _nsmgr, out _feedTitle);
     if (!String.IsNullOrWhiteSpace(_options.LanguageName) || !String.IsNullOrEmpty(_options.Publisher))
     {
         _filteredCatalog = _opdsClient.GetFilteredCatalog(_rootCatalog);
         if (_filteredCatalog == null)
         {
             Console.WriteLine("ERROR: creating the filtered catalog failed!");
             Environment.Exit(2);
         }
     }
 }
Ejemplo n.º 2
0
        public int RunFetch()
        {
            if (!VerifyOptions())
            {
                return(1);
            }

            if (_options.DryRun)
            {
                Console.WriteLine("DRY RUN MESSAGES");
            }
            _rootCatalog = _opdsClient.GetRootPage(out _nsmgr, out _feedTitle);
            // Fill in the language specific catalog if the language name is given.
            if (!String.IsNullOrWhiteSpace(_options.LanguageName) || !String.IsNullOrWhiteSpace(_options.Publisher))
            {
                _filteredCatalog = _opdsClient.GetFilteredCatalog(_rootCatalog);                        // also applies Publisher if set
            }
            if (_filteredCatalog == null)
            {
                return(2);
            }
            // Don't overwrite an input catalog file.
            if (!String.IsNullOrWhiteSpace(_options.Url) || !String.IsNullOrWhiteSpace(_options.Source))
            {
                // Write the catalog file if the catalog filename is given.  If either the language name or the
                // publisher is given, write out the filtered catalog.  Otherwise write out whatever catalog was
                // loaded from the original root url.
                if (!String.IsNullOrEmpty(_options.CatalogFile))
                {
                    if (String.IsNullOrEmpty(_options.LanguageName) && String.IsNullOrEmpty(_options.Publisher))
                    {
                        File.WriteAllText(_options.CatalogFile, _rootCatalog.OuterXml);
                    }
                    else
                    {
                        File.WriteAllText(_options.CatalogFile, _filteredCatalog.OuterXml);
                    }
                }
            }
            // Retrieve and save a book if the title is provided.  The author and output filepath may optionally
            // be provided as well.  If the language name is given, search the language specific catalog.  Otherwise,
            // search the catalog loaded for the root url.
            if (!String.IsNullOrEmpty(_options.BookTitle))
            {
                return(FetchAndSaveBook());
            }
            return(0);
        }