Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Add methods returning Epub's title and Author #179

Merged
merged 1 commit into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/EPUBCore/FRBook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ open class FRBook: NSObject {
return metadata.titles.first
}

func authorName() -> String? {
return metadata.creators.first?.name
}

// MARK: - Media Overlay Metadata
// http://www.idpf.org/epub/301/spec/epub-mediaoverlays.html#sec-package-metadata

Expand Down
18 changes: 18 additions & 0 deletions Source/EPUBCore/FREpubParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ class FREpubParser: NSObject, SSZipArchiveDelegate {
}
return UIImage(contentsOfFile: coverImage.fullHref)
}

func parseTitle(_ epubPath: String) -> String? {

guard let book = readEpub(epubPath: epubPath, removeEpub: false), let title = book.title() else {
return nil
}
return title
}

func parseAuthorName(_ epubPath: String) -> String? {
guard let book = readEpub(epubPath: epubPath, removeEpub: false), let authorName = book.authorName() else {
return nil
}
return authorName
}




/**
Unzip, delete and read an epub file.
Expand Down
10 changes: 10 additions & 0 deletions Source/FolioReaderKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ open class FolioReader: NSObject {
return FREpubParser().parseCoverImage(epubPath)
}


// MARK: - Get Title
open class func getTitle(_ epubPath: String) -> String? {
return FREpubParser().parseTitle(epubPath)
}

open class func getAuthorName(_ epubPath: String) -> String? {
return FREpubParser().parseAuthorName(epubPath)
}

// MARK: - Present Folio Reader

/**
Expand Down