fix: replace forbidden chars in output file name
This commit is contained in:
+5
-1
@@ -6,6 +6,7 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/flytam/filenamify"
|
||||
"github.com/mathismqn/godeez/internal/deezer"
|
||||
"github.com/mathismqn/godeez/internal/tags"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -128,7 +129,10 @@ func downloadContent(contentType string, args []string) {
|
||||
trackNumber = song.TrackNumber + "."
|
||||
}
|
||||
|
||||
filePath := path.Join(output, fmt.Sprintf("%s %s - %s.%s", trackNumber, songTitle, strings.Join(song.Contributors.MainArtists, ", "), ext))
|
||||
fileName := fmt.Sprintf("%s %s - %s.%s", trackNumber, songTitle, strings.Join(song.Contributors.MainArtists, ", "), ext)
|
||||
fileName, _ = filenamify.Filenamify(fileName, filenamify.Options{})
|
||||
filePath := path.Join(output, fileName)
|
||||
|
||||
err = media.Download(url, filePath, song.ID)
|
||||
if err != nil {
|
||||
fmt.Printf("\r Downloading %s... FAILED\n", songTitle)
|
||||
|
||||
@@ -30,6 +30,7 @@ require (
|
||||
|
||||
require (
|
||||
github.com/bogem/id3v2/v2 v2.1.4
|
||||
github.com/flytam/filenamify v1.2.0
|
||||
github.com/go-flac/flacpicture/v2 v2.0.2
|
||||
github.com/go-flac/flacvorbis/v2 v2.0.2
|
||||
github.com/go-flac/go-flac/v2 v2.0.1
|
||||
|
||||
@@ -5,6 +5,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/flytam/filenamify v1.2.0 h1:7RiSqXYR4cJftDQ5NuvljKMfd/ubKnW/j9C6iekChgI=
|
||||
github.com/flytam/filenamify v1.2.0/go.mod h1:Dzf9kVycwcsBlr2ATg6uxjqiFgKGH+5SKFuhdeP5zu8=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/flytam/filenamify"
|
||||
)
|
||||
|
||||
type Album struct {
|
||||
@@ -33,7 +35,12 @@ func (a *Album) GetSongs() []*Song {
|
||||
}
|
||||
|
||||
func (a *Album) GetOutputPath(outputDir string) string {
|
||||
return path.Join(outputDir, fmt.Sprintf("%s - %s", a.Data.Artist, a.Data.Title))
|
||||
base := fmt.Sprintf("%s - %s", a.Data.Artist, a.Data.Title)
|
||||
base, _ = filenamify.Filenamify(base, filenamify.Options{})
|
||||
outputPath := path.Join(outputDir, base)
|
||||
outputPath, _ = filenamify.Filenamify(outputPath, filenamify.Options{})
|
||||
|
||||
return outputPath
|
||||
}
|
||||
|
||||
func (a *Album) GetTitle() string {
|
||||
|
||||
@@ -3,6 +3,8 @@ package deezer
|
||||
import (
|
||||
"encoding/json"
|
||||
"path"
|
||||
|
||||
"github.com/flytam/filenamify"
|
||||
)
|
||||
|
||||
type Playlist struct {
|
||||
@@ -27,7 +29,11 @@ func (p *Playlist) GetSongs() []*Song {
|
||||
}
|
||||
|
||||
func (p *Playlist) GetOutputPath(outputDir string) string {
|
||||
return path.Join(outputDir, p.Data.Title)
|
||||
p.Data.Title, _ = filenamify.Filenamify(p.Data.Title, filenamify.Options{})
|
||||
outputPath := path.Join(outputDir, p.Data.Title)
|
||||
outputPath, _ = filenamify.Filenamify(outputPath, filenamify.Options{})
|
||||
|
||||
return outputPath
|
||||
}
|
||||
|
||||
func (p *Playlist) GetTitle() string {
|
||||
|
||||
Reference in New Issue
Block a user