diff --git a/Model/Applications/InvidiousAPI.swift b/Model/Applications/InvidiousAPI.swift index 101157a1..e224bd66 100644 --- a/Model/Applications/InvidiousAPI.swift +++ b/Model/Applications/InvidiousAPI.swift @@ -92,15 +92,18 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI { } configureTransformer(pathPattern("search"), requestMethods: [.get]) { (content: Entity) -> SearchPage in - let results = content.json.arrayValue.compactMap { json -> ContentItem in + let results = content.json.arrayValue.compactMap { json -> ContentItem? in let type = json.dictionaryValue["type"]?.stringValue if type == "channel" { return ContentItem(channel: self.extractChannel(from: json)) } else if type == "playlist" { return ContentItem(playlist: self.extractChannelPlaylist(from: json)) + } else if type == "video" { + return ContentItem(video: self.extractVideo(from: json)) } - return ContentItem(video: self.extractVideo(from: json)) + + return nil } return SearchPage(results: results, last: results.isEmpty) diff --git a/Model/Search/SearchModel.swift b/Model/Search/SearchModel.swift index 3758a0c9..a426f017 100644 --- a/Model/Search/SearchModel.swift +++ b/Model/Search/SearchModel.swift @@ -115,7 +115,7 @@ final class SearchModel: ObservableObject { resource?.removeObservers(ownedBy: store) - resource = accounts.api.search(query, page: page?.nextPage) + resource = accounts.api.search(query, page: pageToLoad.nextPage) resource.addObserver(store) resource