2017-05-27 19:43:27 +02:00
|
|
|
//
|
|
|
|
// FeedTitleDownloader.swift
|
|
|
|
// Evergreen
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 9/3/16.
|
2017-05-29 22:17:58 +02:00
|
|
|
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
2017-05-27 19:43:27 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2017-07-02 02:22:19 +02:00
|
|
|
import RSParser
|
2017-05-27 19:43:27 +02:00
|
|
|
import RSWeb
|
|
|
|
|
|
|
|
func downloadTitleForFeed(_ url: URL, _ completionHandler: @escaping (_ title: String?) -> ()) {
|
|
|
|
|
|
|
|
download(url) { (data, response, error) in
|
|
|
|
|
|
|
|
guard let data = data else {
|
|
|
|
completionHandler(nil)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-02 02:22:19 +02:00
|
|
|
let parserData = ParserData(url: url.absoluteString, data: data)
|
|
|
|
FeedParser.parse(parserData) { (parsedFeed, error) in
|
2017-05-27 19:43:27 +02:00
|
|
|
completionHandler(parsedFeed?.title)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|