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

Commit

Permalink
Add methods returning Epub's title and Author (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandetho authored and hebertialmeida committed Nov 15, 2016
1 parent b18e2cf commit f0d223e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
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

0 comments on commit f0d223e

Please sign in to comment.