import_spotify function ported over

This commit is contained in:
2025-11-30 02:11:34 -08:00
parent e7c76a2bd5
commit ee7973b1a5

22
muzi.go
View File

@@ -7,6 +7,26 @@ import "strings"
import "os" import "os"
import "io" import "io"
func importSpotify() {
path := filepath.Join(".", "spotify-data", "zip")
targetBase := filepath.Join(".", "spotify-data", "extracted")
entries, err := os.ReadDir(path)
if err != nil {
panic(err)
}
for _, f:= range entries {
_, err := zip.OpenReader(filepath.Join(path, f.Name()))
if (err == nil) {
fileName := f.Name()
fileFullPath := filepath.Join(path, fileName)
fileBaseName := fileName[:(strings.LastIndex(fileName, "."))]
targetDirFullPath := filepath.Join(targetBase, fileBaseName)
extract(fileFullPath, targetDirFullPath)
}
}
}
func extract(path string, target string) { func extract(path string, target string) {
archive, err := zip.OpenReader(path) archive, err := zip.OpenReader(path)
if (err != nil) { if (err != nil) {
@@ -27,7 +47,7 @@ func extract(path string, target string) {
return return
} }
if f.FileInfo().IsDir() { if f.FileInfo().IsDir() {
fmt.Println("Creating Directory") fmt.Println("Creating Directory", filePath)
os.MkdirAll(filePath, os.ModePerm) os.MkdirAll(filePath, os.ModePerm)
continue continue
} }