rename var

This commit is contained in:
Данил 2022-09-19 02:06:17 +03:00
parent 8adce860b7
commit 01cdf12b54

View file

@ -22,7 +22,7 @@ func GetWallpaper() string {
panic(marshalErr) panic(marshalErr)
} }
type Wallpaper struct { type WallpaperStruct struct {
Hdurl string `json:"hdurl"` Hdurl string `json:"hdurl"`
Url string `json:"url"` Url string `json:"url"`
Media_type string `json:"media_type"` Media_type string `json:"media_type"`
@ -39,20 +39,19 @@ func GetWallpaper() string {
panic(StringErr) panic(StringErr)
} }
var wallpaper Wallpaper var Wallpaper WallpaperStruct
jsonErr := json.Unmarshal([]byte(body), &wallpaper) jsonErr := json.Unmarshal([]byte(body), &Wallpaper)
if jsonErr != nil { if jsonErr != nil {
panic(jsonErr) panic(jsonErr)
} }
if wallpaper.Media_type == "video" { if Wallpaper.Media_type == "video" {
wallpaper.Url = wallpaper.Url[30 : len(wallpaper.Url)-6] Wallpaper.Url = Wallpaper.Url[30 : len(Wallpaper.Url)-6]
return "https://img.youtube.com/vi/" + Wallpaper.Url + "/0.jpg"
return "https://img.youtube.com/vi/" + wallpaper.Url + "/0.jpg"
} }
return wallpaper.Hdurl return Wallpaper.Hdurl
} }
func SetWallpaper() { func SetWallpaper() {