示例#1
0
        /// <summary>
        /// Fetch the epub file for the given book and write it to the standard RoseGarden/Downloads folder.
        /// If desired, fetch the image file and also write it to the standard RoseGarden/Downloads folder.
        /// Also write the catalog entry as a single-entry OPDS catalog file.
        /// </summary>
        private void FetchBook(XmlElement entry)
        {
            var pathEpub  = ComputeEpubPathFromEntryTitle(entry);
            var pathImage = Path.ChangeExtension(pathEpub, "jpg");
            var pathOpds  = Path.ChangeExtension(pathEpub, "opds");
            var obsolete  = false;

            if (File.Exists(pathOpds))
            {
                obsolete = IsExistingDownloadObsolete(entry, pathOpds);
            }
            if (!File.Exists(pathEpub) || !File.Exists(pathOpds) || obsolete)
            {
                _opdsClient.DownloadBook(entry, "epub", _feedTitle, pathEpub);
                if (_options.DownloadImage)
                {
                    _opdsClient.DownloadImage(entry, pathImage);
                }
                _opdsClient.WriteCatalogEntryFile(_rootCatalog, entry, pathOpds);
            }
            else
            {
                Console.WriteLine("INFO: skipping download of \"{0}\" because we apparently already have it.", Path.GetFileName(pathEpub));
            }
        }
示例#2
0
        public int DownloadBook(XmlElement bookEntry, string type)
        {
            string path;

            if (String.IsNullOrEmpty(_options.OutputFile))
            {
                path = Path.Combine(OpdsClient.DownloadFolder, Program.SanitizeNameForFileSystem(_options.BookTitle) + "." + type);
            }
            else
            {
                path = _options.OutputFile;
                if (type == "pdf")
                {
                    path = Path.ChangeExtension(path, type);
                }
            }
            return(_opdsClient.DownloadBook(bookEntry, type, _feedTitle, path));
        }