update cli

This commit is contained in:
aynakeya
2025-09-02 22:45:41 +08:00
parent b02c6f0142
commit 15cadb4e5f
2 changed files with 11 additions and 4 deletions

View File

@@ -17,13 +17,15 @@ import (
)
var (
writeMetadata bool
downloadQuality string
writeMetadata bool
downloadQuality string
specifiedFilename string
)
func init() {
CmdDownload.Flags().BoolVar(&writeMetadata, "metadata", false, "Write metadata (tags, cover, lyrics) to the file")
CmdDownload.Flags().StringVar(&downloadQuality, "quality", "", "Quality preference (e.g., 128k, 320k, flac)")
CmdDownload.Flags().StringVar(&specifiedFilename, "filename", "", "Filename to use for download")
}
var CmdDownload = &cobra.Command{
@@ -105,9 +107,12 @@ Supported formats for metadata include MP3 and FLAC.`,
if ext == "" {
ext = mimetype.Detect(downloadedBytes[:min(512, len(downloadedBytes))]).Extension()
}
// Step 5: Save the file from the buffer
filename := sanitizeFilename(fmt.Sprintf("%s - %s%s", info.Artist, info.Title, ext))
// Step 5: Save the file from the buffer
if specifiedFilename != "" {
filename = specifiedFilename
}
err = os.WriteFile(filename, downloadedBytes, 0644)
if err != nil {
fmt.Printf("Error saving file to disk: %v\n", err)

View File

@@ -16,10 +16,12 @@ import (
func (p *QQMusicProvider) makeApiRequest(module, method string, params map[string]interface{}) (gjson.Result, error) {
expiredTime := time.UnixMilli(p.cred.CreatedAt * 1000).Add(7 * 24 * time.Hour)
//fmt.Println(expiredTime.Format("2006-01-02 15:04:05"))
if expiredTime.Before(time.Now().Add(24*time.Hour)) && !p.tokenRefreshed {
//if true && !p.tokenRefreshed {
//if !p.tokenRefreshed {
//only refresh once
//fmt.Println("Token expired")
p.tokenRefreshed = true
p.qimeiUpdated = false
_ = p.refreshToken()