mirror of
https://github.com/riwiwa/muzi.git
synced 2025-12-30 04:35:26 -08:00
Cleaned up project structure more and simplified the app installation
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1 @@
|
||||
lastfm-data
|
||||
spotify-data
|
||||
imports
|
||||
|
||||
47
README.md
47
README.md
@@ -1,27 +1,30 @@
|
||||
# muzi
|
||||
|
||||
Self hosted music listening statistics
|
||||
# Muzi
|
||||
## Self-hosted music listening statistics
|
||||
|
||||
### Dependencies
|
||||
- PostgreSQL
|
||||
|
||||
### Spotify Import Instructions (for testing and development):
|
||||
- Navigate to the muzi project root dir
|
||||
- Create a folder called "spotify-data"
|
||||
- Inside the new "spotify-data" folder create a folder called "zip"
|
||||
- Place all zip archives that you obtained from Spotify in this folder.
|
||||
- Ensure the PostgreSQL server is running locally on port 5432.
|
||||
- Run muzi.go
|
||||
- All Spotify tracks that have > 20 second playtime will congregate into the muzi PostgreSQL database
|
||||
### Installation Instructions (for testing and development) \[Only Supports Spotify Imports ATM\]:
|
||||
1. Clone the repo:<br>```git clone https://github.com/riwiwa/muzi```
|
||||
2. Copy over all zip archives obtained from Spotify into the ```imports/spotify-data/zip/``` directory.
|
||||
3. Ensure PostgreSQL is installed and running locally on port 5432.
|
||||
4. Run the app with:<br>```go run main.go```
|
||||
5. Navigate to ```localhost:1234/history``` to see your sorted listening history.
|
||||
6. Comment out ```importsongs.ImportSpotify()``` from ```main.go``` to prevent the app's attempts to import the Spotify data again
|
||||
|
||||
### plans:
|
||||
- Ability to import all listening statistics and scrobbles from lastfm, spotify, apple music
|
||||
- daily, weekly, monthly, yearly, lifetime presets for listening reports
|
||||
- ability to specify a certain point in time from one datetime to another to list data
|
||||
- grid maker (3x3-10x10)
|
||||
- multi artist scrobbling
|
||||
- ability to change artist image
|
||||
- webUI
|
||||
- ability to "sync" scrobbles (send from a device to the server)
|
||||
- live scrobbling to the server
|
||||
- batch scrobble editor
|
||||
### Roadmap:
|
||||
- Ability to import all listening statistics and scrobbles from: \[In Progress\]
|
||||
- lastfm
|
||||
- spotify \[Complete\]
|
||||
- apple music
|
||||
|
||||
- WebUI \[In Progress\]
|
||||
- Full listening history with time \[Functional\]
|
||||
- Daily, weekly, monthly, yearly, lifetime presets for listening reports
|
||||
- Ability to specify a certain point in time from one datetime to another to list data
|
||||
- Grid maker (3x3-10x10)
|
||||
- Ability to change artist image
|
||||
- Multi artist scrobbling
|
||||
- Ability to "sync" offline scrobbles (send from a device to the server)
|
||||
- Live scrobbling to the server
|
||||
- Batch scrobble editor
|
||||
|
||||
@@ -31,7 +31,6 @@ func TableExists(name string, conn *pgx.Conn) bool {
|
||||
func DbExists() bool {
|
||||
conn, err := pgx.Connect(context.Background(), "postgres://postgres:postgres@localhost:5432/muzi")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Cannot connect to muzi database: %v\n", err)
|
||||
return false
|
||||
}
|
||||
defer conn.Close(context.Background())
|
||||
@@ -152,8 +151,8 @@ func AddDirToDB(path string, platform int) {
|
||||
}
|
||||
|
||||
func ImportSpotify() {
|
||||
path := filepath.Join(".", "spotify-data", "zip")
|
||||
targetBase := filepath.Join(".", "spotify-data", "extracted")
|
||||
path := filepath.Join(".", "imports", "spotify", "zip")
|
||||
targetBase := filepath.Join(".", "imports", "spotify", "extracted")
|
||||
entries, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
65
main.go
65
main.go
@@ -1,10 +1,73 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
//"muzi/importsongs"
|
||||
"errors"
|
||||
"fmt"
|
||||
"muzi/importsongs"
|
||||
"muzi/web"
|
||||
"os"
|
||||
)
|
||||
|
||||
func dbCheck() error {
|
||||
if !importsongs.DbExists() {
|
||||
err := importsongs.CreateDB()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error creating muzi DB: %v\n", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func dirCheck(path string) error {
|
||||
|
||||
_, err := os.Stat(path)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
os.MkdirAll(path, os.ModePerm)
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "Error checking dir: %s: %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
dirImports := "./imports/"
|
||||
|
||||
dirSpotify := "./imports/spotify/"
|
||||
dirSpotifyZip := "./imports/spotify/zip/"
|
||||
dirSpotifyExt := "./imports/spotify/extracted/"
|
||||
|
||||
dirLastFM := "./imports/lastfm/"
|
||||
|
||||
err := dirCheck(dirImports)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dirCheck(dirSpotify)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dirCheck(dirSpotifyZip)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dirCheck(dirSpotifyExt)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dirCheck(dirLastFM)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dbCheck()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//importsongs.ImportSpotify()
|
||||
web.Start()
|
||||
}
|
||||
|
||||
@@ -143,11 +143,13 @@ func tmp(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func Start() {
|
||||
addr := ":1234"
|
||||
r := chi.NewRouter()
|
||||
r.Use(middleware.Logger)
|
||||
r.Get("/static/style.css", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "./static/style.css")
|
||||
})
|
||||
r.Get("/history", tmp)
|
||||
http.ListenAndServe(":1234", r)
|
||||
fmt.Printf("WebUI starting on %s\n", addr)
|
||||
http.ListenAndServe(addr, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user