package com.base.scanqrclear.bean

import com.base.scanqrclear.bean.FunctionUIBean.Companion.KEY_SPOTIFY

data class SpotifyUIBean(
    val singerName: String,
    val song: String
) : ScanBean(KEY_SPOTIFY) {


    companion object {

        fun isSpotifyQR(qrCodeValue: String): Boolean {
            return qrCodeValue.startsWith("spotify:")
        }

        fun createSpotifyUIBean(qrCodeValue: String): SpotifyUIBean {
            val sub = qrCodeValue.subSequence("spotify:search:".length, qrCodeValue.length)
            val split = sub.split(";")
            var singerName = ""
            var song = ""
            kotlin.runCatching {
                singerName = split[0]
                song = split[1]
            }
            return SpotifyUIBean(singerName, song)
        }

        //    spotify:search:wanglei;唱山歌
        fun SpotifyUIBean.createSpotifyQrString(): String {
            return "spotify:search:$singerName;$song"
        }
    }
}