Compare commits

..

No commits in common. "8f6a42f8b48826de82f7a926b4277156d36dd07b" and "40c516dcc865ccbfa28b52559f6e7ff0115062a6" have entirely different histories.

5 changed files with 4 additions and 73 deletions

View File

@ -2,11 +2,10 @@
Tools to manage an UltraStar DX song library. Features include:
1. Web-based catalogue UI
2. Deduplication
3. Organization
4. Recoding
5. Jsonification
1. Deduplication
2. Organization
3. Recoding
4. Jsonification
## Setup
@ -24,22 +23,6 @@ We assume that your song library is stored at `$SONG_LIBRARY`. Replace this plac
export SONG_LIBRARY=/path/to/library
```
### Web-based catalogue UI
**A web-based UI to browse the song library.** It supports searching by title and artist, and allows to mark and unmark favorites on the client side (using local storage).
#### Serve
**Launch a server for the catalogue UI** on localhost. Mostly useful for development purposes.
This is completely risk-free, as it does not change files.
```bash
python3 -m karaokatalog.ui.serve $SONG_LIBRARY
```
To speed up the start, use jsonification to create and persist a JSON of all songs in the library root dir before starting this UI.
### Deduplication
**Find and delete exactly duplicated songs**, i.e., songs with the same title and artist that also consist of exactly the same files in the directory.

View File

@ -1,32 +0,0 @@
import json
import logging
from karaokatalog.get_parser import get_parser
from karaokatalog.Library import Library
from karaokatalog.ui.serve.get_flask_app import get_flask_app
logging.basicConfig(
format="%(asctime)s [%(levelname)s] %(message)s", level=logging.INFO
)
if __name__ == "__main__":
args = get_parser(
"ui.serve", "Serve a web UI to browse the Karaokatalog"
).parse_args()
songs_json_path = args.library_path / "songs.json"
if songs_json_path.exists():
logging.info(f"Loading {songs_json_path}")
with songs_json_path.open("r", encoding="utf-8") as f:
songs = json.load(f)
else:
logging.info("Loading library")
library = Library.from_dir(args.library_path)
logging.info("Library loaded")
songs = [song.as_dict() for song in library.songs]
logging.info("Starting UI")
app = get_flask_app(songs)
app.run(port=5657)

View File

@ -1,20 +0,0 @@
from collections.abc import Sequence
from flask import Flask, Response
def get_flask_app(songs: Sequence[dict[str, str]]) -> Flask:
app = Flask("karaokatalog.ui", static_url_path="/")
# This is only to make the type checker happy.
songs_list = list(songs)
@app.get("/songs.json")
def get_songs() -> list[dict[str, str]]:
return songs_list
@app.get("/")
def get_index() -> Response:
return app.send_static_file("index.html")
return app