mirror of
https://github.com/yattee/yattee.git
synced 2025-01-08 22:07:10 +00:00
Fix Invidious channel videos
This commit is contained in:
parent
2b238c9b7b
commit
cfd85a018e
@ -114,7 +114,7 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configureTransformer(pathPattern("channels/*/latest"), requestMethods: [.get]) { (content: Entity<JSON>) -> [Video] in
|
configureTransformer(pathPattern("channels/*/latest"), requestMethods: [.get]) { (content: Entity<JSON>) -> [Video] in
|
||||||
content.json.arrayValue.map(self.extractVideo)
|
content.json.dictionaryValue["videos"]?.arrayValue.map(self.extractVideo) ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
configureTransformer(pathPattern("channels/*/playlists"), requestMethods: [.get]) { (content: Entity<JSON>) -> [ContentItem] in
|
configureTransformer(pathPattern("channels/*/playlists"), requestMethods: [.get]) { (content: Entity<JSON>) -> [ContentItem] in
|
||||||
|
@ -72,14 +72,21 @@ struct FavoriteItemView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case let .channel(_, id, name):
|
case let .channel(_, id, name):
|
||||||
let channel = Channel(app: .invidious, id: id, name: name)
|
var channel = Channel(app: .invidious, id: id, name: name)
|
||||||
if let cache = ChannelsCacheModel.shared.retrieve(channel.cacheKey) {
|
if let cache = ChannelsCacheModel.shared.retrieve(channel.cacheKey),
|
||||||
|
!cache.videos.isEmpty
|
||||||
|
{
|
||||||
contentItems = ContentItem.array(of: cache.videos)
|
contentItems = ContentItem.array(of: cache.videos)
|
||||||
}
|
}
|
||||||
|
|
||||||
onSuccess = { response in
|
onSuccess = { response in
|
||||||
if let channel: Channel = response.typedContent() {
|
if let channel: Channel = response.typedContent() {
|
||||||
ChannelsCacheModel.shared.store(channel)
|
ChannelsCacheModel.shared.store(channel)
|
||||||
|
store.contentItems = ContentItem.array(of: channel.videos)
|
||||||
|
} else if let videos: [Video] = response.typedContent() {
|
||||||
|
channel.videos = videos
|
||||||
|
ChannelsCacheModel.shared.store(channel)
|
||||||
|
store.contentItems = ContentItem.array(of: videos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case let .channelPlaylist(_, id, title):
|
case let .channelPlaylist(_, id, title):
|
||||||
|
Loading…
Reference in New Issue
Block a user