//
//  MPPositive_Recommend.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/5/20.
//

import UIKit

struct JsonRecommend: Codable {
    let contents:Contents?
    enum CodingKeys: String, CodingKey {
        case contents = "contents"
    }
    init(from decoder: Decoder) throws {
        let values = try decoder.container(keyedBy: CodingKeys.self)
        contents = try values.decodeIfPresent(Contents.self, forKey: .contents)
    }
    struct Contents: Codable {
        let sectionListRenderer:SectionListRenderer?
        enum CodingKeys: String, CodingKey {
            case sectionListRenderer = "sectionListRenderer"
        }
        init(from decoder: Decoder) throws {
            let values = try decoder.container(keyedBy: CodingKeys.self)
            sectionListRenderer = try values.decodeIfPresent(SectionListRenderer.self, forKey: .sectionListRenderer)
        }
        struct SectionListRenderer: Codable {
            let contents:[Content]?
            enum CodingKeys: String, CodingKey {
                case contents = "contents"
            }
            init(from decoder: Decoder) throws {
                let values = try decoder.container(keyedBy: CodingKeys.self)
                contents = try values.decodeIfPresent([Content].self, forKey: .contents)
            }
            struct Content: Codable {
                let musicCarouselShelfRenderer:MusicCarouselShelfRenderer?
                enum CodingKeys: String, CodingKey {
                    case musicCarouselShelfRenderer = "musicCarouselShelfRenderer"
                }
                init(from decoder: Decoder) throws {
                    let values = try decoder.container(keyedBy: CodingKeys.self)
                    musicCarouselShelfRenderer = try values.decodeIfPresent(MusicCarouselShelfRenderer.self, forKey: .musicCarouselShelfRenderer)
                }
                struct MusicCarouselShelfRenderer: Codable {
                    ///头部标题文本
                    let header:Header?
                    ///内容组
                    let contents:[Content]?
                    enum CodingKeys: String, CodingKey {
                        case header = "header"
                        case contents = "contents"
                    }
                    init(from decoder: Decoder) throws {
                        let values = try decoder.container(keyedBy: CodingKeys.self)
                        header = try values.decodeIfPresent(Header.self, forKey: .header)
                        contents = try values.decodeIfPresent([Content].self, forKey: .contents)
                    }
                    struct Header: Codable {
                        let musicCarouselShelfBasicHeaderRenderer:MusicCarouselShelfBasicHeaderRenderer?
                        enum CodingKeys: String, CodingKey {
                            case musicCarouselShelfBasicHeaderRenderer = "musicCarouselShelfBasicHeaderRenderer"
                        }
                        init(from decoder: Decoder) throws {
                            let values = try decoder.container(keyedBy: CodingKeys.self)
                            musicCarouselShelfBasicHeaderRenderer = try values.decodeIfPresent(MusicCarouselShelfBasicHeaderRenderer.self, forKey: .musicCarouselShelfBasicHeaderRenderer)
                        }
                        struct MusicCarouselShelfBasicHeaderRenderer: Codable {
                            let title:Title?
                            enum CodingKeys: String, CodingKey {
                                case title = "title"
                            }
                            init(from decoder: Decoder) throws {
                                let values = try decoder.container(keyedBy: CodingKeys.self)
                                title = try values.decodeIfPresent(Title.self, forKey: .title)
                            }
                            struct Title: Codable {
                                let runs:[Run]?
                                enum CodingKeys: String, CodingKey {
                                    case runs = "runs"
                                }
                                init(from decoder: Decoder) throws {
                                    let values = try decoder.container(keyedBy: CodingKeys.self)
                                    runs = try values.decodeIfPresent([Run].self, forKey: .runs)
                                }
                                
                                struct Run: Codable {
                                    ///歌词
                                    let text:String?
                                    enum CodingKeys: String, CodingKey {
                                        case text = "text"
                                    }
                                    init(from decoder: Decoder) throws {
                                        let values = try decoder.container(keyedBy: CodingKeys.self)
                                        text = try values.decodeIfPresent(String.self, forKey: .text)
                                    }
                                }
                            }
                        }
                    }
                    struct Content: Codable {
                        let musicResponsiveListItemRenderer:RootMusicResponsiveListItemRenderer?
                        let musicTwoRowItemRenderer:RootMusicTwoRowItemRenderer?
                        enum CodingKeys: String, CodingKey {
                            case musicResponsiveListItemRenderer = "musicResponsiveListItemRenderer"
                            case musicTwoRowItemRenderer = "musicTwoRowItemRenderer"
                        }
                        init(from decoder: Decoder) throws {
                            let values = try decoder.container(keyedBy: CodingKeys.self)
                            musicResponsiveListItemRenderer = try values.decodeIfPresent(RootMusicResponsiveListItemRenderer.self, forKey: .musicResponsiveListItemRenderer)
                            musicTwoRowItemRenderer = try values.decodeIfPresent(RootMusicTwoRowItemRenderer.self, forKey: .musicTwoRowItemRenderer)
                        }
                    }
                }
            }
        }
    }
}
