//
//  MPPositive_JsonLyrics.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/5/10.
//

import UIKit
///歌词结构体
struct JsonLyrics: 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 musicDescriptionShelfRenderer:MusicDescriptionShelfRenderer?
                enum CodingKeys: String, CodingKey {
                    case musicDescriptionShelfRenderer = "musicDescriptionShelfRenderer"
                }
                init(from decoder: Decoder) throws {
                    let values = try decoder.container(keyedBy: CodingKeys.self)
                    musicDescriptionShelfRenderer = try values.decodeIfPresent(MusicDescriptionShelfRenderer.self, forKey: .musicDescriptionShelfRenderer)
                }
                struct MusicDescriptionShelfRenderer: Codable{
                    let description:Description?
                    enum CodingKeys: String, CodingKey {
                        case description = "description"
                    }
                    init(from decoder: Decoder) throws {
                        let values = try decoder.container(keyedBy: CodingKeys.self)
                        description = try values.decodeIfPresent(Description.self, forKey: .description)
                    }
                    struct Description: 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)
                            }
                        }
                    }
                }
            }
        }
    }
}
