mirror of
https://github.com/Superredstone/spotiflac-cli.git
synced 2026-03-07 20:18:07 +01:00
fix: remove spotiflac libraries
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,3 @@
|
|||||||
lib/
|
|
||||||
app/
|
|
||||||
build/
|
build/
|
||||||
downloads/
|
downloads/
|
||||||
Unknown/
|
Unknown/
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -2,8 +2,6 @@ module github.com/Superredstone/spotiflac-cli
|
|||||||
|
|
||||||
go 1.24.4
|
go 1.24.4
|
||||||
|
|
||||||
replace github.com/Superredstone/spotiflac-cli/app => ./app
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bogem/id3v2/v2 v2.1.4 // indirect
|
github.com/bogem/id3v2/v2 v2.1.4 // indirect
|
||||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
|
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
|
||||||
|
|||||||
7
lib/app.go
Normal file
7
lib/app.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package pkg
|
||||||
|
|
||||||
|
type App struct {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4,8 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/Superredstone/spotiflac-cli/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -13,7 +11,7 @@ const (
|
|||||||
DEFAULT_DOWNLOAD_OUTPUT_FOLDER = "."
|
DEFAULT_DOWNLOAD_OUTPUT_FOLDER = "."
|
||||||
)
|
)
|
||||||
|
|
||||||
func Download(application *app.App, url string, output_folder string, service string) error {
|
func Download(app *App, url string, output_folder string, service string) error {
|
||||||
if output_folder == "" {
|
if output_folder == "" {
|
||||||
output_folder = DEFAULT_DOWNLOAD_OUTPUT_FOLDER
|
output_folder = DEFAULT_DOWNLOAD_OUTPUT_FOLDER
|
||||||
}
|
}
|
||||||
@@ -23,7 +21,7 @@ func Download(application *app.App, url string, output_folder string, service st
|
|||||||
}
|
}
|
||||||
|
|
||||||
if service == "amazon" || service == "qobuz" {
|
if service == "amazon" || service == "qobuz" {
|
||||||
isInstalled, err := application.CheckFFmpegInstalled()
|
isInstalled, err := app.CheckFFmpegInstalled()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -37,7 +35,7 @@ func Download(application *app.App, url string, output_folder string, service st
|
|||||||
|
|
||||||
switch url_type {
|
switch url_type {
|
||||||
case UrlTypeTrack:
|
case UrlTypeTrack:
|
||||||
metadata, err := GetMetadata[MetadataSong](application, url)
|
metadata, err := GetMetadata[MetadataSong](app, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -55,10 +53,10 @@ func Download(application *app.App, url string, output_folder string, service st
|
|||||||
SpotifyID: track.SpotifyID,
|
SpotifyID: track.SpotifyID,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = application.DownloadTrack(downloadRequest)
|
_, err = app.DownloadTrack(downloadRequest)
|
||||||
return err
|
return err
|
||||||
case UrlTypePlaylist:
|
case UrlTypePlaylist:
|
||||||
metadata, err := GetMetadata[MetadataPlaylist](application, url)
|
metadata, err := GetMetadata[MetadataPlaylist](app, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -80,7 +78,7 @@ func Download(application *app.App, url string, output_folder string, service st
|
|||||||
PlaylistName: metadata.Info.Owner.Name,
|
PlaylistName: metadata.Info.Owner.Name,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = application.DownloadTrack(downloadRequest)
|
_, err = app.DownloadTrack(downloadRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Unable to download " + track.Name + " - " + track.Artists)
|
fmt.Println("Unable to download " + track.Name + " - " + track.Artists)
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Superredstone/spotiflac-cli/app"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MetadataSong struct {
|
type MetadataSong struct {
|
||||||
@@ -53,7 +51,7 @@ type MetadataPlaylistOwner struct {
|
|||||||
Images string `json:"images"`
|
Images string `json:"images"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMetadata[T MetadataPlaylist | MetadataSong](application *app.App, url string) (T, error) {
|
func GetMetadata[T MetadataPlaylist | MetadataSong](app *App, url string) (T, error) {
|
||||||
var result T
|
var result T
|
||||||
|
|
||||||
metadataRequest := app.SpotifyMetadataRequest{
|
metadataRequest := app.SpotifyMetadataRequest{
|
||||||
@@ -62,7 +60,7 @@ func GetMetadata[T MetadataPlaylist | MetadataSong](application *app.App, url st
|
|||||||
Timeout: 5,
|
Timeout: 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata, err := application.GetSpotifyMetadata(metadataRequest)
|
metadata, err := app.GetSpotifyMetadata(metadataRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -75,10 +73,10 @@ func GetMetadata[T MetadataPlaylist | MetadataSong](application *app.App, url st
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func PrintMetadata(application *app.App, url string) error {
|
func PrintMetadata(app *App, url string) error {
|
||||||
switch GetUrlType(url) {
|
switch GetUrlType(url) {
|
||||||
case UrlTypeTrack:
|
case UrlTypeTrack:
|
||||||
metadata, err := GetMetadata[MetadataSong](application, url)
|
metadata, err := GetMetadata[MetadataSong](app, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -98,7 +96,7 @@ Images: %s`
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
case UrlTypePlaylist:
|
case UrlTypePlaylist:
|
||||||
metadata, err := GetMetadata[MetadataPlaylist](application, url)
|
metadata, err := GetMetadata[MetadataPlaylist](app, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
9
main.go
9
main.go
@@ -5,15 +5,14 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Superredstone/spotiflac-cli/app"
|
"github.com/Superredstone/spotiflac-cli/lib"
|
||||||
"github.com/Superredstone/spotiflac-cli/pkg"
|
|
||||||
"github.com/urfave/cli/v3"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var output_folder, service string
|
var output_folder, service string
|
||||||
|
|
||||||
application := app.NewApp()
|
app := lib.NewApp()
|
||||||
|
|
||||||
cmd := &cli.Command{
|
cmd := &cli.Command{
|
||||||
Name: "spotiflac-cli",
|
Name: "spotiflac-cli",
|
||||||
@@ -41,7 +40,7 @@ func main() {
|
|||||||
},
|
},
|
||||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||||
song_url := cmd.Args().First()
|
song_url := cmd.Args().First()
|
||||||
err := pkg.Download(application, song_url, output_folder, service)
|
err := pkg.Download(app, song_url, output_folder, service)
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -51,7 +50,7 @@ func main() {
|
|||||||
Usage: "view song metadata",
|
Usage: "view song metadata",
|
||||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||||
url := cmd.Args().First()
|
url := cmd.Args().First()
|
||||||
return pkg.PrintMetadata(application, url)
|
return pkg.PrintMetadata(app, url)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user