//
//  MPPositive_JsonArtistMore.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/5/15.
//

import UIKit

struct JsonArtistMore: Codable {
    ///数据展示
    let contents:Contents?
    ///扩展数据展示，continuation编码获取
    let continuationContents:ContinuationContents?
    enum CodingKeys: String, CodingKey {
        case contents = "contents"
        case continuationContents = "continuationContents"
    }
    init(from decoder: Decoder) throws {
        let values = try decoder.container(keyedBy: CodingKeys.self)
        contents = try values.decodeIfPresent(Contents.self, forKey: .contents)
        continuationContents = try values.decodeIfPresent(ContinuationContents.self, forKey: .continuationContents)
    }
    struct Contents: Codable {
        let singleColumnBrowseResultsRenderer:SingleColumnBrowseResultsRenderer?
        enum CodingKeys: String, CodingKey {
            case singleColumnBrowseResultsRenderer = "singleColumnBrowseResultsRenderer"
        }
        init(from decoder: Decoder) throws {
            let values = try decoder.container(keyedBy: CodingKeys.self)
            singleColumnBrowseResultsRenderer = try values.decodeIfPresent(SingleColumnBrowseResultsRenderer.self, forKey: .singleColumnBrowseResultsRenderer)
        }
        struct SingleColumnBrowseResultsRenderer: Codable {
            ///通常只有1位数据
            let tabs : [Tab]?
            enum CodingKeys: String, CodingKey {
                case tabs = "tabs"
            }
            init(from decoder: Decoder) throws {
                let values = try decoder.container(keyedBy: CodingKeys.self)
                tabs = try values.decodeIfPresent([Tab].self, forKey: .tabs)
            }
            struct Tab : Codable {
                let tabRenderer : TabRenderer?
                enum CodingKeys: String, CodingKey {
                    case tabRenderer = "tabRenderer"
                }
                init(from decoder: Decoder) throws {
                    let values = try decoder.container(keyedBy: CodingKeys.self)
                    tabRenderer = try values.decodeIfPresent(TabRenderer.self, forKey: .tabRenderer)
                }
                struct TabRenderer: Codable {
                    let content:Content?
                    
                    enum CodingKeys: String, CodingKey {
                        case content = "content"
                    }
                    init(from decoder: Decoder) throws {
                        let values = try decoder.container(keyedBy: CodingKeys.self)
                        content = try values.decodeIfPresent(Content.self, forKey: .content)
                    }
                    struct Content: 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 musicPlaylistShelfRenderer:MusicPlaylistShelfRenderer?
                                ///专辑列表内容
                                let gridRenderer:GridRenderer?
                                enum CodingKeys: String, CodingKey {
                                    case musicPlaylistShelfRenderer = "musicPlaylistShelfRenderer"
                                    case gridRenderer = "gridRenderer"
                                }
                                init(from decoder: Decoder) throws {
                                    let values = try decoder.container(keyedBy: CodingKeys.self)
                                    musicPlaylistShelfRenderer = try values.decodeIfPresent(MusicPlaylistShelfRenderer.self, forKey: .musicPlaylistShelfRenderer)
                                    gridRenderer = try values.decodeIfPresent(GridRenderer.self, forKey: .gridRenderer)
                                }
                                struct MusicPlaylistShelfRenderer: Codable {
                                    ///歌单列表id
                                    let playlistId:String?
                                    ///内容组
                                    let contents:[Content]?
                                    ///继续编码
                                    let continuations:[Continuation]?
                                    enum CodingKeys: String, CodingKey {
                                        case playlistId = "playlistId"
                                        case contents = "contents"
                                        case continuations = "continuations"
                                    }
                                    init(from decoder: Decoder) throws {
                                        let values = try decoder.container(keyedBy: CodingKeys.self)
                                        playlistId = try values.decodeIfPresent(String.self, forKey: .playlistId)
                                        contents = try values.decodeIfPresent([Content].self, forKey: .contents)
                                        continuations = try values.decodeIfPresent([Continuation].self, forKey: .continuations)
                                    }
                                    struct Content: Codable {
                                        let musicResponsiveListItemRenderer: RootMusicResponsiveListItemRenderer?
                                        enum CodingKeys: String, CodingKey {
                                            case musicResponsiveListItemRenderer = "musicResponsiveListItemRenderer"
                                        }
                                        init(from decoder: Decoder) throws {
                                            let values = try decoder.container(keyedBy: CodingKeys.self)
                                            musicResponsiveListItemRenderer = try values.decodeIfPresent(RootMusicResponsiveListItemRenderer.self, forKey: .musicResponsiveListItemRenderer)
                                        }
                                    }
                                    struct Continuation: Codable {
                                        let nextContinuationData:NextContinuationData?
                                        enum CodingKeys: String, CodingKey {
                                            case nextContinuationData = "nextContinuationData"
                                        }
                                        init(from decoder: Decoder) throws {
                                            let values = try decoder.container(keyedBy: CodingKeys.self)
                                            nextContinuationData = try values.decodeIfPresent(NextContinuationData.self, forKey: .nextContinuationData)
                                        }
                                        struct NextContinuationData: Codable {
                                            let continuation:String?
                                            let clickTrackingParams:String?
                                            enum CodingKeys: String, CodingKey {
                                                case continuation = "continuation"
                                                case clickTrackingParams = "clickTrackingParams"
                                            }
                                            init(from decoder: Decoder) throws {
                                                let values = try decoder.container(keyedBy: CodingKeys.self)
                                                continuation = try values.decodeIfPresent(String.self, forKey: .continuation)
                                                clickTrackingParams = try values.decodeIfPresent(String.self, forKey: .clickTrackingParams)
                                            }
                                            
                                            
                                        }
                                    }
                                }
                                struct GridRenderer: Codable {
                                    ///内容组
                                    let items:[Item]?
                                    ///继续编码
                                    let continuations:[Continuation]?
                                    enum CodingKeys: String, CodingKey {
                                        case items = "items"
                                        case continuations = "continuations"
                                    }
                                    init(from decoder: Decoder) throws {
                                        let values = try decoder.container(keyedBy: CodingKeys.self)
                                        items = try values.decodeIfPresent([Item].self, forKey: .items)
                                        continuations = try values.decodeIfPresent([Continuation].self, forKey: .continuations)
                                    }
                                    struct Item: Codable {
                                        let musicTwoRowItemRenderer: RootMusicTwoRowItemRenderer?
                                        
                                        enum CodingKeys: String, CodingKey {
                                            case musicTwoRowItemRenderer = "musicTwoRowItemRenderer"
                                            
                                        }
                                        init(from decoder: Decoder) throws {
                                            let values = try decoder.container(keyedBy: CodingKeys.self)
                                            musicTwoRowItemRenderer = try values.decodeIfPresent(RootMusicTwoRowItemRenderer.self, forKey: .musicTwoRowItemRenderer)
                                        }
                                    }
                                    struct Continuation: Codable {
                                        let nextContinuationData:NextContinuationData?
                                        enum CodingKeys: String, CodingKey {
                                            case nextContinuationData = "nextContinuationData"
                                        }
                                        init(from decoder: Decoder) throws {
                                            let values = try decoder.container(keyedBy: CodingKeys.self)
                                            nextContinuationData = try values.decodeIfPresent(NextContinuationData.self, forKey: .nextContinuationData)
                                        }
                                        struct NextContinuationData: Codable {
                                            let continuation:String?
                                            let clickTrackingParams:String?
                                            enum CodingKeys: String, CodingKey {
                                                case continuation = "continuation"
                                                case clickTrackingParams = "clickTrackingParams"
                                            }
                                            init(from decoder: Decoder) throws {
                                                let values = try decoder.container(keyedBy: CodingKeys.self)
                                                continuation = try values.decodeIfPresent(String.self, forKey: .continuation)
                                                clickTrackingParams = try values.decodeIfPresent(String.self, forKey: .clickTrackingParams)
                                            }
                                            
                                            
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    struct ContinuationContents: Codable {
        let musicPlaylistShelfContinuation:MusicPlaylistShelfContinuation?
        enum CodingKeys: String, CodingKey {
            case musicPlaylistShelfContinuation = "musicPlaylistShelfContinuation"
        }
        init(from decoder: Decoder) throws {
            let values = try decoder.container(keyedBy: CodingKeys.self)
            musicPlaylistShelfContinuation = try values.decodeIfPresent(MusicPlaylistShelfContinuation.self, forKey: .musicPlaylistShelfContinuation)
        }
        struct MusicPlaylistShelfContinuation: Codable {
            ///内容组
            let contents:[Content]?
            ///继续编码组
            let continuations : [Continuation]?
            enum CodingKeys: String, CodingKey {
                case contents = "contents"
                case continuations = "continuations"
            }
            init(from decoder: Decoder) throws {
                let values = try decoder.container(keyedBy: CodingKeys.self)
                contents = try values.decodeIfPresent([Content].self, forKey: .contents)
                continuations = try values.decodeIfPresent([Continuation].self, forKey: .continuations)
            }
            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)
                }
            }
            ///续页编码
            struct Continuation: Codable {
                let nextContinuationData:NextContinuationData?
                enum CodingKeys: String, CodingKey {
                    case nextContinuationData = "nextContinuationData"
                }

                init(from decoder: Decoder) throws {
                    let values = try decoder.container(keyedBy: CodingKeys.self)
                    nextContinuationData = try values.decodeIfPresent(NextContinuationData.self, forKey: .nextContinuationData)
                }
                //MARK: - 续页编码
                struct NextContinuationData: Codable {
                    let continuation:String?
                    let clickTrackingParams:String?
                    enum CodingKeys: String, CodingKey {
                        case continuation = "continuation"
                        case clickTrackingParams = "clickTrackingParams"
                    }

                    init(from decoder: Decoder) throws {
                        let values = try decoder.container(keyedBy: CodingKeys.self)
                        continuation = try values.decodeIfPresent(String.self, forKey: .continuation)
                        clickTrackingParams = try values.decodeIfPresent(String.self, forKey: .clickTrackingParams)
                    }
                }
            }
        }
    }
}
