fix: use filepath helpers for filesystem paths
This commit is contained in:
@@ -3,7 +3,7 @@ package deezer
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/flytam/filenamify"
|
"github.com/flytam/filenamify"
|
||||||
)
|
)
|
||||||
@@ -41,7 +41,7 @@ func (a *Album) SetTracks(t []*Track) {
|
|||||||
func (a *Album) OutputDir(outputDir string) string {
|
func (a *Album) OutputDir(outputDir string) string {
|
||||||
base := fmt.Sprintf("%s - %s", a.Results.Data.Artist, a.Results.Data.Title)
|
base := fmt.Sprintf("%s - %s", a.Results.Data.Artist, a.Results.Data.Title)
|
||||||
base, _ = filenamify.Filenamify(base, filenamify.Options{})
|
base, _ = filenamify.Filenamify(base, filenamify.Options{})
|
||||||
return path.Join(outputDir, base)
|
return filepath.Join(outputDir, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Album) decode(data []byte) error {
|
func (a *Album) decode(data []byte) error {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package deezer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/flytam/filenamify"
|
"github.com/flytam/filenamify"
|
||||||
)
|
)
|
||||||
@@ -32,7 +32,7 @@ func (a *Artist) SetTracks(t []*Track) {
|
|||||||
|
|
||||||
func (a *Artist) OutputDir(outputDir string) string {
|
func (a *Artist) OutputDir(outputDir string) string {
|
||||||
base, _ := filenamify.Filenamify(a.Results.Data.Name, filenamify.Options{})
|
base, _ := filenamify.Filenamify(a.Results.Data.Name, filenamify.Options{})
|
||||||
return path.Join(outputDir, base)
|
return filepath.Join(outputDir, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Artist) decode(data []byte) error {
|
func (a *Artist) decode(data []byte) error {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package deezer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/flytam/filenamify"
|
"github.com/flytam/filenamify"
|
||||||
)
|
)
|
||||||
@@ -34,7 +34,7 @@ func (p *Playlist) SetTracks(t []*Track) {
|
|||||||
|
|
||||||
func (p *Playlist) OutputDir(outputDir string) string {
|
func (p *Playlist) OutputDir(outputDir string) string {
|
||||||
base, _ := filenamify.Filenamify(p.Results.Data.Title, filenamify.Options{})
|
base, _ := filenamify.Filenamify(p.Results.Data.Title, filenamify.Options{})
|
||||||
return path.Join(outputDir, base)
|
return filepath.Join(outputDir, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Playlist) decode(data []byte) error {
|
func (p *Playlist) decode(data []byte) error {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package deezer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"path"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Single struct {
|
type Single struct {
|
||||||
@@ -28,7 +28,7 @@ func (s *Single) Tracks() []*Track {
|
|||||||
func (s *Single) SetTracks(tracks []*Track) {}
|
func (s *Single) SetTracks(tracks []*Track) {}
|
||||||
|
|
||||||
func (s *Single) OutputDir(outputDir string) string {
|
func (s *Single) OutputDir(outputDir string) string {
|
||||||
return path.Join(outputDir, "Singles")
|
return filepath.Join(outputDir, "Singles")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Single) decode(data []byte) error {
|
func (s *Single) decode(data []byte) error {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ func (d *Downloader) downloadTrack(ctx context.Context, resource deezer.Resource
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
fileName := track.Filename(d.kind, mediaFormat)
|
fileName := track.Filename(d.kind, mediaFormat)
|
||||||
outputPath := path.Join(outputDir, fileName)
|
outputPath := filepath.Join(outputDir, fileName)
|
||||||
|
|
||||||
key := deezer.BlowfishKey(track.ID)
|
key := deezer.BlowfishKey(track.ID)
|
||||||
if err := d.streamToFile(dlCtx, stream, outputPath, key); err != nil {
|
if err := d.streamToFile(dlCtx, stream, outputPath, key); err != nil {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package store
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
bolt "go.etcd.io/bbolt"
|
bolt "go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
@@ -12,7 +12,7 @@ type Store struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Open(dir string) (*Store, error) {
|
func Open(dir string) (*Store, error) {
|
||||||
db, err := bolt.Open(path.Join(dir, ".tracks.db"), 0600, nil)
|
db, err := bolt.Open(filepath.Join(dir, ".tracks.db"), 0600, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to open database: %w", err)
|
return nil, fmt.Errorf("failed to open database: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package tag
|
package tag
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/bogem/id3v2/v2"
|
"github.com/bogem/id3v2/v2"
|
||||||
"github.com/go-flac/flacvorbis/v2"
|
"github.com/go-flac/flacvorbis/v2"
|
||||||
@@ -39,7 +39,7 @@ type tagger interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newTagger(filePath string) (tagger, error) {
|
func newTagger(filePath string) (tagger, error) {
|
||||||
if path.Ext(filePath) == ".mp3" {
|
if filepath.Ext(filePath) == ".mp3" {
|
||||||
tag, err := id3v2.Open(filePath, id3v2.Options{Parse: true})
|
tag, err := id3v2.Open(filePath, id3v2.Options{Parse: true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user