You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: apiservice.go
    path of file: ./repos/ZeroBot-Plugin/plugin/guessmusic
    
    the code of the file until where you have to start completion: package guessmusic

import (
	"encoding/json"
	"math/rand"
	"net/url"
	"os"
	"strconv"
	"strings"
	"time"

	wyy "github.com/FloatTech/AnimeAPI/neteasemusic"
	"github.com/FloatTech/floatbox/file"
	"github.com/FloatTech/floatbox/web"
	"github.com/FloatTech/zbputils/ctxext"
	"github.com/pkg/errors"
	zero "github.com/wdvxdr1123/ZeroBot"
	"github.com/wdvxdr1123/ZeroBot/message"
)

func init() {
	// API配置
	engine.OnPrefix("设置猜歌API", zero.SuperUserPermission).SetBlock(true).
		Handle(func(ctx *zero.Ctx) {
			option := ctx.State["args"].(string)
			if option == "帮助" {
				ctx.SendChain(message.Text(
					"项目地址:binaryify.github.io/NeteaseCloudMusicApi" +
						"\n网上有基于该框架的API,可以自行搜索白嫖。\n" +
						"添加API指令:\n设置猜歌API [API首页网址]"))
				return
			}
			if !strings.HasSuffix(option, "/") {
				option += "/"
			}
			cfg.APIURL = option
			err := saveConfig(cfgFile)
			if err == nil {
				ctx.SendChain(message.Text("成功！"))
			} else {
				ctx.Se
    
func drawByAPI(playlistID int64, musicPath string) (musicName string, err error) {
	APIURL := cfg.APIURL + "playlist/track/all?id=" + strconv.FormatInt(playlistID, 10)
	data, err := web.GetData(APIURL)
	if err != nil {
		err = errors.Errorf("无法获取歌单列表\n%s", err)
		return
	}
	var parsed musicListOfApI
	err = json.Unmarshal(data, &parsed)
	if err != nil {
		err = errors.Errorf("无法读取歌单列表\n%s", err)
		return
	}
	listlen := len(parsed.Songs)
	randidx := rand.Intn(listlen)
	// 将"/"符号去除,不然无法生成文件
	name := strings.ReplaceAll(parsed.Songs[randidx].Name, "/", "·")
	musicID := parsed.Songs[randidx].ID
	artistName := ""
	for i, ARInfo := range parsed.Songs[randidx].Ar {
		if i != 0 {
			artistName += "&" + ARInfo.Name
		} else {
			artistName += ARInfo.Name
		}
	}
	cource := ""
	if parsed.Songs[randidx].Alia != nil {
		cource = strings.Join(parsed.Songs[randidx].Alia, "&")
		// 将"/"符号去除,不然无法下载
		cource = strings.ReplaceAll(cource, "/", "&")
	}
	if name == "" || musicID == 0 {
		err = errors.New("无法获API取歌曲信息")
		return
	}
	if cource != "" {
		name += " - " + artistName + " - " + cource
	} else {
		name += " - " + artistName
	}
	// 下载歌曲
	err = wyy.DownloadMusic(musicID, name, musicPath)
	if err == nil {
		musicName = name + ".mp3"
		if cfg.Local {
			// 下载歌词
			_ = wyy.DownloadLrc(musicID, name, musicPath+"歌词/")
		}
	}
	return
}