Skip to content

Unable to Fetch Items from YouTube Playlist #102

@quochuywdm

Description

@quochuywdm

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions