YoutubeKit icon indicating copy to clipboard operation
YoutubeKit copied to clipboard

Unable to Fetch Items from YouTube Playlist

Open quochuywdm opened this issue 11 months ago • 2 comments

Thank you for this awesome library!

Other requests work fine, but this playlist request is not working: I'm trying to fetch items from the following YouTube playlist: https://www.youtube.com/playlist?list=PLq3UZa7STrbpX13PljcNH6hmyrSbcMYK8 When I run the following code, I encounter an error:

result: failure(Swift.DecodingError.keyNotFound(CodingKeys(stringValue: "status", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "items", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: "status", intValue: nil) ("status").", underlyingError: nil)))

Failed to fetch videos: The data couldn’t be read because it is missing.

private func fetchPlaylistVideos() {
    let playlistID = "PLq3UZa7STrbpX13PljcNH6hmyrSbcMYK8"
    let request = PlaylistItemsListRequest.init(part: [.snippet, .contentDetails], filter: .playlistID(playlistID), maxResults: 10)
    
    YoutubeAPI.shared.send(request) { [weak self] result in
        print("result:", result)
        switch result {
        case .success(let response):
            print("response: ", response)
        case .failure(let error):
            print("Failed to fetch videos:", error.localizedDescription)
        }
    }
}

Any guidance would be greatly appreciated.

Thanks!

quochuywdm avatar Jan 17 '25 05:01 quochuywdm

Fixed in #103 (although may not be up to @rinov standards, did the bare minimum to get it working)

danperks avatar Apr 15 '25 09:04 danperks

@quochuywdm Can you please update to the latest version and test again. As the PR #103 from @danperks have been merged, it should be good now. Try it and keep us updated with your results. Thanks in advance.

Tibimac avatar Aug 15 '25 22:08 Tibimac