Switch to the Swift chapter importer.
This commit is contained in:
1 parent
0ada574509
commit
c44e74d193
13 files changed
+297
-744
No files matched your search
@@ -7,16 +7,16 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
class ChapterDB : ChapterService {
|
||||
public struct ChapterDB : ChapterService {
|
||||
|
||||
func search(title: String, duration: UInt64) -> [ChapterResult] {
|
||||
public func search(title: String, duration: UInt64) -> [ChapterResult] {
|
||||
|
||||
guard let url = URL(string: "http://www.chapterdb.org/chapters/search?title=\(title.urlEncoded())"),
|
||||
let data = fetch(url: url)
|
||||
else { return [] }
|
||||
|
||||
let delta: UInt64 = 10000
|
||||
return parse(data: data).filter { $0.duration < (duration + delta) && $0.duration > (duration - delta) }
|
||||
let delta: Int64 = 10000
|
||||
return parse(data: data).filter { $0.duration < (Int64(duration) + delta) && $0.duration > (Int64(duration) - delta) }
|
||||
}
|
||||
|
||||
private func fetch(url: URL) -> Data? {
|
||||
|
||||
Reference in new issue
Block a user