Add games library with IGDB, file explorer and static files script
This commit is contained in:
1 parent
a16444451a
commit
ec57bd73b3
65 files changed
+2230
-352
No files matched your search
@@ -22,11 +22,12 @@ The site recreates my [blomarchy](https://git.sirblob.co/SirBlob/blomarchy) setu
|
||||
- **Floating windows** - Alt + V or the title bar button pops a window out of the tiling layout so it can be dragged and resized.
|
||||
- **btop** - a system monitor window with my real GitHub commit graph, repos as processes and some very scientific CPU and caffeine readings.
|
||||
- **Image viewer** - click any image to open it in an imv window with zoom, pan, rotate, pinch and swipe.
|
||||
- **File explorer** - a thunar window that browses `static/files` with grid and list views, a gallery of image thumbnails, previews for images, video and audio, and the image viewer for opening pictures.
|
||||
- **Kitty terminals** - a real command line with history and tab completion. Try `fastfetch`, `whoami` or `cowsay`.
|
||||
- **Desktop icons** - grouped into pages, terminal scripts, apps (tcg, movies, shows, books), games and socials (GitHub, LinkedIn, Devpost, Discord).
|
||||
- **Desktop icons** - grouped into pages, terminal scripts, apps (files, tcg, movies, shows, books, games), games and socials (GitHub, LinkedIn, Devpost, Discord).
|
||||
- **13 themes** - Cerberus, Flats, Tokyo Night, Night Cat, Catppuccin, Arch Linux, Gruvbox, Nord, Kanagawa, Wintry, Rose, Catppuccin Latte and Rose Pine Dawn, each with its own wallpaper.
|
||||
- **Portfolio** - about, portfolio, projects (open source, packages, hackathons, research, organizations), blog with RSS and links with QR codes.
|
||||
- **Library apps** - movies, shows and books open as their own windows with status filters, search, sorting, details and a monthly watch and read history. Entries in the same series or collection are grouped together.
|
||||
- **Library apps** - movies, shows, books and games open as their own windows with status filters, search, sorting, details and a monthly watch and read history. Entries in the same series or collection are grouped together. Games can also be marked as a favorite or liked, with tags and a note, and the about page shows those starred games.
|
||||
- **Live data** - GitHub stars and forks, npm downloads, AniList anime stats and Last.fm listening stats collected into SQLite.
|
||||
- **Mobile friendly** - on small screens windows go fullscreen with tabs to switch between them.
|
||||
|
||||
@@ -70,7 +71,8 @@ Alt stands in for Super, since browsers can't use it.
|
||||
| `theme [name]` | list or switch themes |
|
||||
| `cowsay <text>` | moo |
|
||||
| `btop` | system monitor with my GitHub stats |
|
||||
| `movies` / `shows` / `books` | open the library apps |
|
||||
| `thunar` / `files` | browse `static/files` |
|
||||
| `movies` / `shows` / `books` / `games library` | open the library apps |
|
||||
| `pacman -S <pkg>` | install things (not really) |
|
||||
|
||||
## Running
|
||||
@@ -99,67 +101,74 @@ Copy `.env.example` to `.env` and fill in what you need. Every value is optional
|
||||
| --- | --- |
|
||||
| `DISCORD_TOKEN`, `DISCORD_USER_ID`, `DISCORD_GUILD_ID` | Live Discord status in the bar |
|
||||
| `OMDB_API_KEY` | Looking up shows and movies in the content editor |
|
||||
| `IGDB_CLIENT_ID`, `IGDB_CLIENT_SECRET` | Looking up games on IGDB in the content editor, from a Confidential app in the [Twitch developer console](https://dev.twitch.tv/console) |
|
||||
| `LASTFM_API_KEY` | Collecting Last.fm scrobbles for the listening stats |
|
||||
| `LIBRARY_API_KEY` | Secret the content editor sends to change shows, movies and books. Set the same value on the server and locally |
|
||||
| `LIBRARY_API_KEY` | Secret the content editor sends to change shows, movies, books and games. Set the same value on the server and locally |
|
||||
| `LIBRARY_API_URL` | Site the content editor talks to, `http://localhost:5000` by default |
|
||||
| `LIBRARY_DATA_DIR` | Folder for `library.db`, `data/library` by default |
|
||||
| `LASTFM_DATA_DIR` | Folder for `lastfm.db`, `data/lastfm` by default |
|
||||
|
||||
## Content
|
||||
|
||||
Personal content and config live in `content/`. Shows, movies and books are the exception: they live in a SQLite database at `data/library/library.db` (set `LIBRARY_DATA_DIR` to move it) that the server owns, so adding one never needs a commit. Last.fm scrobbles and album covers are collected at runtime into `data/lastfm/lastfm.db` (set `LASTFM_DATA_DIR` to move it). On first start an older `scrobbles.jsonl`, `covers.json`, `track-covers.json` and `images/` in that folder are moved into the database, and those files can be deleted afterwards. Both databases stay out of git.
|
||||
Personal content and config live in `content/`. Shows, movies, books and games are the exception: they live in a SQLite database at `data/library/library.db` (set `LIBRARY_DATA_DIR` to move it) that the server owns, so adding one never needs a commit. Last.fm scrobbles and album covers are collected at runtime into `data/lastfm/lastfm.db` (set `LASTFM_DATA_DIR` to move it). On first start an older `scrobbles.jsonl`, `covers.json`, `track-covers.json` and `images/` in that folder are moved into the database, and those files can be deleted afterwards. Both databases stay out of git.
|
||||
|
||||
### Library API
|
||||
|
||||
| Request | Does |
|
||||
| --- | --- |
|
||||
| `GET /api/library` | Every show, movie and book, public |
|
||||
| `GET /api/library` | Every show, movie, book and game, public |
|
||||
| `PUT /api/library/media/<imdbId>` | Add or change a show or movie |
|
||||
| `DELETE /api/library/media/<imdbId>` | Remove a show or movie |
|
||||
| `PUT /api/library/books/<goodreadsId>` | Add or change a book |
|
||||
| `DELETE /api/library/books/<goodreadsId>` | Remove a book |
|
||||
| `GET /api/library/images/<id>` | A saved poster or cover |
|
||||
| `PUT /api/library/games/<igdbId>` | Add or change a game |
|
||||
| `DELETE /api/library/games/<igdbId>` | Remove a game |
|
||||
| `GET /api/library/images/<id>` | A saved poster, cover or game image |
|
||||
|
||||
Changes need `Authorization: Bearer <LIBRARY_API_KEY>`. A `PUT` only changes the fields it sends, and `null` clears one. When a status changes to watching or reading the start date is set, and to watched or read the finish date, unless the request sends its own. Posters and covers are downloaded by the server and kept in the database.
|
||||
Changes need `Authorization: Bearer <LIBRARY_API_KEY>`. A `PUT` only changes the fields it sends, and `null` clears one. When a status changes to watching, reading or playing the start date is set, and to watched, read or played the finish date, unless the request sends its own. Posters, covers and game images are downloaded by the server and kept in the database. A site path such as `/img/minecraft.png` is used as it is.
|
||||
|
||||
### Content editor
|
||||
|
||||
A terminal app built with [Textual](https://textual.textualize.io/) edits the playlist, shows, movies, books, portfolio, projects and themes without touching the JSON by hand. It uses the site's own themes.
|
||||
A terminal app built with [Textual](https://textual.textualize.io/) edits the playlist, shows, movies, books, games, portfolio, projects and themes without touching the JSON by hand. It uses the site's own themes.
|
||||
|
||||
```bash
|
||||
bun run content:setup
|
||||
bun run content
|
||||
```
|
||||
|
||||
`content:setup` creates a virtual environment in `tools/content/.venv` and installs Textual and Pillow. Run it once.
|
||||
`content:setup` creates a virtual environment in `tools/content/.venv` and installs Textual, Pillow and pillow-heif. Run it once, and again when `requirements.txt` changes.
|
||||
|
||||
| Key | Action |
|
||||
| --- | --- |
|
||||
| `1` to `9` | Switch between Music, Shows, Movies, Books, Profile, Experience, Leadership, Projects and Themes |
|
||||
| `a` | Add (YouTube link, IMDb link or Goodreads link) |
|
||||
| `1` to `9`, `0` | Switch between Music, Shows, Movies, Books, Games, Profile, Experience, Leadership, Projects and Themes |
|
||||
| `a` | Add (YouTube link, IMDb link, Goodreads link, or a store link, IGDB link or name for a game) |
|
||||
| `S` | Add books from a Goodreads series |
|
||||
| `e` / `Enter` | Edit the selected entry (or change the rating for shows, movies and books) |
|
||||
| `g` | Put a show or movie in a group, which the library apps and about page show together |
|
||||
| `h` | Set the started and finished dates for a show, movie or book |
|
||||
| `f` | Toggle featured on a project |
|
||||
| `e` / `Enter` | Edit the selected entry (or change the rating for shows, movies, books and games) |
|
||||
| `g` | Put a show or movie in a group, which the library apps and about page show together, or set a game's tags and note |
|
||||
| `h` | Set the started and finished dates for a show, movie, book or game |
|
||||
| `l` | Change a game's store link or image |
|
||||
| `f` | Toggle featured on a project, or make a game your favorite |
|
||||
| `k` | Add a game to the games you like (up to 20) |
|
||||
| `p` | Preview a theme in the editor |
|
||||
| `t` | Switch the editor to the next theme |
|
||||
| `s` | Move a book to another shelf, set a show or movie to watched, watching or planning, or make a theme the site default |
|
||||
| `s` | Move a book to another shelf, set a show, movie or game status (a game can also be replayable), or make a theme the site default |
|
||||
| `d` | Delete |
|
||||
| `K` / `J` | Move a song or entry up or down |
|
||||
| `u` / `U` | Refresh the selected book, or every book, from Goodreads; `u` also refreshes a show or movie from OMDb |
|
||||
| `u` / `U` | Refresh the selected book, or every book, from Goodreads; `u` also refreshes a show or movie from OMDb, or a game from IGDB |
|
||||
| `C` | Save every missing book cover, or every missing show and movie poster and details, into the library |
|
||||
| `r` | Reload from disk or the library |
|
||||
| `q` | Quit |
|
||||
|
||||
The Shows, Movies and Books tabs read and write the library through the API at `LIBRARY_API_URL` using `LIBRARY_API_KEY`, so point it at the live site to update it from anywhere. Show and movie titles are looked up on OMDb with `OMDB_API_KEY` from `.env` when added; fill in the name field to skip the lookup. Books are scraped from Goodreads when added. To check a Goodreads link on its own, run `python3 tools/content/goodreads.py <url>`.
|
||||
The Shows, Movies, Books and Games tabs read and write the library through the API at `LIBRARY_API_URL` using `LIBRARY_API_KEY`, so point it at the live site to update it from anywhere. Show and movie titles are looked up on OMDb with `OMDB_API_KEY` from `.env` when added; fill in the name field to skip the lookup. Books are scraped from Goodreads when added. To check a Goodreads link on its own, run `python3 tools/content/goodreads.py <url>`.
|
||||
|
||||
A game in `about.json` can have a `mobygames` link. Run `python3 tools/content/mobygames.py <url> --save` to scrape its release date, platforms, developers, genres, scores, description and images into `data/gameDetails.json`, which the game card shows. Leave out `--save` to only print the result, or use `--debug` if MobyGames blocks the request.
|
||||
Games are looked up on IGDB with `IGDB_CLIENT_ID` and `IGDB_CLIENT_SECRET`. A Steam or Xbox link is matched to its IGDB entry directly; any other store link (Nintendo, Epic, GOG and so on) is searched by the name in the link, or by the name you enter. An IGDB link such as `https://www.igdb.com/games/hades-ii` always matches exactly. IGDB fills in the release date, platforms, developers, publishers, genres, summary, rating and a 16:9 artwork image; enter your own image to use it instead. To check a lookup on its own, run `python3 tools/content/igdb.py <link or name>`.
|
||||
|
||||
To move the games that used to be listed in `about.json` into the library once, run `bun run games:import`. It removes them from `about.json` only when every game was imported.
|
||||
|
||||
| File | Holds |
|
||||
| --- | --- |
|
||||
| `profile.json` | Name, bio, socials, skills and photos |
|
||||
| `about.json` | Hobbies, games and the AniList username |
|
||||
| `about.json` | Hobbies, setup and the AniList and Last.fm usernames |
|
||||
| `experience.json` / `leadership.json` | Work experience and leadership roles |
|
||||
| `projects/*.json` | Open source, packages, hackathons, research groups and organizations |
|
||||
| `music.json` | YouTube links for the music player |
|
||||
@@ -170,9 +179,20 @@ A game in `about.json` can have a `mobygames` link. Run `python3 tools/content/m
|
||||
|
||||
| File in `data/` | Holds |
|
||||
| --- | --- |
|
||||
| `library/library.db` | Shows, movies, books, their history dates and saved images |
|
||||
| `library/library.db` | Shows, movies, books, games, their history dates and saved images |
|
||||
| `lastfm/lastfm.db` | Last.fm scrobbles, album and track cover links and saved cover images |
|
||||
| `gameDetails.json` | Video game details scraped from MobyGames |
|
||||
|
||||
### Files
|
||||
|
||||
Files you drop into `static/files` (any folders inside it too) show up in the file explorer and are served at `/files/...`. Hidden files are skipped.
|
||||
|
||||
```sh
|
||||
bun run files
|
||||
```
|
||||
|
||||
Converts every HEIC or HEIF photo in `static/files` to a JPEG, turned the right way up and without metadata, and removes GPS location data from any other photo in there since the folder is public. Converted originals are moved to `tools/content/.cache/heic-originals`; pass `--delete-originals` to delete them instead, or `--keep-location` to leave location data alone. Run `bun run content:setup` again first to install `pillow-heif`.
|
||||
|
||||
A hobby in `about.json` can have a `folder`, such as `"folder": "robotics"`. Clicking that hobby on the about page opens the file explorer in `static/files/robotics`.
|
||||
|
||||
### Wallpapers
|
||||
|
||||
|
||||
Reference in new issue
Block a user