private void ReadEpubAsZip(MetadataResult <Book> result, string path, CancellationToken cancellationToken)
        {
            using var epub = ZipFile.OpenRead(path);

            var opfFilePath = EpubUtils.ReadContentFilePath(epub);

            if (opfFilePath == null)
            {
                return;
            }

            var opf = epub.GetEntry(opfFilePath);

            if (opf == null)
            {
                return;
            }

            using var opfStream = opf.Open();

            var opfDocument = new XmlDocument();

            opfDocument.Load(opfStream);

            OpfReader.ReadOpfData(result, opfDocument, cancellationToken, _logger);
        }
Ejemplo n.º 2
0
        private MetadataResult <Book>?ReadEpubAsZip(string path, CancellationToken cancellationToken)
        {
            using var epub = ZipFile.OpenRead(path);

            var opfFilePath = EpubUtils.ReadContentFilePath(epub);

            if (opfFilePath == null)
            {
                return(null);
            }

            var opf = epub.GetEntry(opfFilePath);

            if (opf == null)
            {
                return(null);
            }

            using var opfStream = opf.Open();

            var opfDocument = new XmlDocument();

            opfDocument.Load(opfStream);

            var utilities = new OpfReader <EpubMetadataProvider>(opfDocument, _logger);

            return(utilities.ReadOpfData(cancellationToken));
        }
Ejemplo n.º 3
0
        private Task <DynamicImageResponse> GetFromZip(BaseItem item)
        {
            using var epub = ZipFile.OpenRead(item.Path);

            var opfFilePath = EpubUtils.ReadContentFilePath(epub);

            if (opfFilePath == null)
            {
                return(Task.FromResult(new DynamicImageResponse {
                    HasImage = false
                }));
            }

            var opfRootDirectory = Path.GetDirectoryName(opfFilePath);

            var opfFile = epub.GetEntry(opfFilePath);

            if (opfFile == null)
            {
                return(Task.FromResult(new DynamicImageResponse {
                    HasImage = false
                }));
            }

            using var opfStream = opfFile.Open();

            var opfDocument = new XmlDocument();

            opfDocument.Load(opfStream);

            return(LoadCover(epub, opfDocument, opfRootDirectory));
        }