-
-
Save sturdysturge/b11408c12db2ba34f8ed9a714ffaba31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| struct YTResponse: Codable { | |
| let items: [Item]? | |
| } | |
| struct Item: Codable, Identifiable { | |
| let fullID: ID? | |
| let snippet: Snippet? | |
| var id: String { fullID?.videoID ?? "" } | |
| var defaultThumbnailURL: URL? { | |
| URL(string: snippet?.thumbnails?.thumbnailsDefault?.url ?? "") | |
| } | |
| enum CodingKeys: String, CodingKey { | |
| case snippet, fullID = "id" | |
| } | |
| } | |
| struct ID: Codable { | |
| let videoID: String? | |
| enum CodingKeys: String, CodingKey { | |
| case videoID = "videoId" | |
| } | |
| } | |
| struct Snippet: Codable { | |
| let title, description: String? | |
| let thumbnails: Thumbnails? | |
| } | |
| struct Thumbnails: Codable { | |
| let thumbnailsDefault, medium, high: Default? | |
| enum CodingKeys: String, CodingKey { | |
| case thumbnailsDefault = "default" | |
| case medium, high | |
| } | |
| } | |
| struct Default: Codable { | |
| let url: String? | |
| let width, height: Int? | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment