feat: allow for custom music folder path alias

closes #259
This commit is contained in:
sentriz
2022-11-21 20:17:55 +00:00
parent 92a73b2d61
commit 7e097c9bdf
6 changed files with 81 additions and 32 deletions

View File

@@ -5,7 +5,6 @@ import (
"log"
"net/http"
"os"
"path/filepath"
"time"
"github.com/gorilla/mux"
@@ -14,6 +13,7 @@ import (
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/jukebox"
"go.senan.xyz/gonic/paths"
"go.senan.xyz/gonic/podcasts"
"go.senan.xyz/gonic/scanner"
"go.senan.xyz/gonic/scanner/tags"
@@ -29,7 +29,7 @@ import (
type Options struct {
DB *db.DB
MusicPaths []string
MusicPaths paths.MusicPaths
PodcastPath string
CachePath string
CoverCachePath string
@@ -48,15 +48,9 @@ type Server struct {
}
func New(opts Options) (*Server, error) {
for i, musicPath := range opts.MusicPaths {
opts.MusicPaths[i] = filepath.Clean(musicPath)
}
opts.CachePath = filepath.Clean(opts.CachePath)
opts.PodcastPath = filepath.Clean(opts.PodcastPath)
tagger := &tags.TagReader{}
scanner := scanner.New(opts.MusicPaths, opts.DB, opts.GenreSplit, tagger)
scanner := scanner.New(opts.MusicPaths.Paths(), opts.DB, opts.GenreSplit, tagger)
base := &ctrlbase.Controller{
DB: opts.DB,
ProxyPrefix: opts.ProxyPrefix,