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