Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3144bd96c9 |
No files matched your search
@@ -1,109 +1,116 @@
|
|||||||
# Showy — Movies & Series Library Tracker
|
# Showy - Movies & Series Library Tracker
|
||||||
|
|
||||||
**Showy** is a personal, single-user app for tracking the movies and TV series you watch. It pulls metadata from **TMDB**, keeps your library, watch history and ratings in **MySQL**, and runs as a web app or a **desktop app** (Electron, with a Tauri version in progress).
|
**Showy** is a comprehensive application designed to help you manage your movies and series library. Built with **Angular 17**, **Node.js**, **Express**, and **MySQL**, and optionally packaged with **Electron**, Showy allows you to track your watch progress, manage your watchlist, view upcoming releases on a calendar, and organize official and custom collections. The app also features a dashboard for quick insights into your library. The entire application is **dockerized** for easy setup and deployment.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Library** — add movies and shows from TMDB; favorites, hidden entries, watchlist; filter by type, genre, rating and year
|
- **Library Management**:
|
||||||
- **Entry pages** — full-bleed hero, trailer player, cast and crew, seasons (list or card view), where to watch, keywords, recommendations, budget/box office, certification and external links. Titles **not in your library** open on the same page from TMDB data, with *Add to Library*
|
- Add movies and series to your library.
|
||||||
- **Artwork** — every TMDB poster, backdrop and logo for a title, merged with your local media, with one-click *Add*
|
- Track watch progress for movies and episodes.
|
||||||
- **Watch tracking** — movies and episodes with exact/estimated/unknown dates, watch buddies, rewatches, season "mark all watched" (single date or spread over a range)
|
- Add movies and series to your watchlist.
|
||||||
- **Season & episode pages** — progress, *Continue* to the next unwatched episode, directors/writers, guest stars
|
- **Calendar**:
|
||||||
- **History** — everything you watched by year, as a list, a timeline, or a Spotify-style **Year in Review**
|
- View upcoming movies and episodes in a calendar view.
|
||||||
- **Calendar** — upcoming episodes
|
- Never miss a release date for your favorite shows or movies.
|
||||||
- **Collections** — TMDB collections and your own
|
- **Collections**:
|
||||||
- **People** — cast and crew pages with filmography split into "in your library" and "not in library"
|
- Browse official collections (e.g., Marvel Cinematic Universe, Harry Potter series).
|
||||||
- **Dashboard** — watch time, activity, genres, ratings and growth charts
|
- Create and manage custom collections (e.g., "90s Classics", "Christmas Movies").
|
||||||
- **Discovery Videos** — a personal video vault linked to library entries
|
- **Dashboard**:
|
||||||
- **In-app streaming** and a **command palette** (search, recently viewed, quick navigation)
|
- Get an overview of your library stats.
|
||||||
- **Maintenance** — background **TMDB refresh** of stale entries (rate limited), orphan media/people cleanup, duplicate credits, watch-status fixes
|
- View recently added movies/series, upcoming releases, and watch progress.
|
||||||
|
- **Optional Desktop App**:
|
||||||
|
- Use Showy as a desktop application with Electron for a seamless experience.
|
||||||
|
- **Dockerized**:
|
||||||
|
- Easy setup and deployment using Docker and Docker Compose.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Tech Stack
|
## Technologies Used
|
||||||
|
|
||||||
| Layer | Technologies |
|
- **Frontend**: Angular 17
|
||||||
|---|---|
|
- **Backend**: Node.js, Express
|
||||||
| Frontend | React 19, TypeScript, Vite 8, Tailwind CSS 4, Base UI (shadcn-style components), TanStack Query 5, Zustand 5, React Router 7, Recharts |
|
- **Database**: MySQL
|
||||||
| Backend | Node.js, Express 4, Sequelize 6, MySQL 8, Axios, Sharp, JWT auth |
|
- **Optional Desktop Integration**: Electron
|
||||||
| Data | [TMDB API v3](https://developer.themoviedb.org/) (rate limited, proxied by the backend) |
|
- **Containerization**: Docker, Docker Compose
|
||||||
| Desktop | Electron 45 (`electron/`); Tauri v2 in progress on the `feat/tauri-app` branch |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
Showy/
|
showy/
|
||||||
├── backend/ # Express + Sequelize API (models, routes, controllers, services, mappers)
|
├── frontend/ # Angular 17 frontend
|
||||||
│ ├── config/ # DB connection, relations, startup migrations, data seeding
|
│ ├── src/
|
||||||
│ └── settings.json # Runtime settings (TMDB key, ports, auth) — copy from settings.json.example
|
│ │ ├── app/ # Angular components, services, modules
|
||||||
├── react_frontend/ # React + Vite frontend (the current UI)
|
│ │ ├── assets/ # Static assets (images, styles)
|
||||||
├── electron/ # Electron desktop shell
|
│ │ └── environments/ # Environment configurations
|
||||||
├── docs-vault/ # Project documentation (Obsidian vault) — start at Index.md
|
│ ├── Dockerfile # Dockerfile for the frontend
|
||||||
├── frontend/ # Legacy Angular frontend (still used by docker-compose)
|
│ └── ...
|
||||||
└── docker-compose.yml
|
├── backend/ # Node.js + Express backend
|
||||||
|
│ ├── config/ # Database and app configurations
|
||||||
|
│ ├── controllers/ # API controllers
|
||||||
|
│ ├── models/ # Database models
|
||||||
|
│ ├── routes/ # API routes
|
||||||
|
│ ├── Dockerfile # Dockerfile for the backend
|
||||||
|
│ └── ...
|
||||||
|
├── electron/ # Electron configuration (optional)
|
||||||
|
├── docker-compose.yml # Docker Compose configuration
|
||||||
|
└── README.md # This file
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- Node.js 18+ and **pnpm**
|
- Docker
|
||||||
- MySQL 8 with a database named `Showzy` (connection settings in `backend/config/database.js`)
|
- Docker Compose
|
||||||
- A TMDB API key
|
|
||||||
|
|
||||||
### 1. Backend
|
### Installation
|
||||||
|
|
||||||
|
1. **Clone the repository**:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd backend
|
git clone https://github.com/X4Lo/showy.git
|
||||||
pnpm install
|
cd showy
|
||||||
cp settings.json.example settings.json # then set tmdbApiKey, userDataPath, authPassword, jwtSecret
|
|
||||||
pnpm dev # http://localhost:4000/api/v1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
On start the backend syncs the schema and runs `config/migrations.js`, which adds any new columns to an existing database (additive only).
|
2. **Set up environment variables**:
|
||||||
|
- Create a `.env` file in the `backend` directory with the following variables:
|
||||||
### 2. Frontend
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd react_frontend
|
PORT=3000
|
||||||
pnpm install
|
DB_HOST=mysql
|
||||||
pnpm dev # http://localhost:4200
|
DB_USER=root
|
||||||
|
DB_PASSWORD=yourpassword
|
||||||
|
DB_NAME=showy
|
||||||
```
|
```
|
||||||
|
|
||||||
The Vite dev server proxies `/api` to the backend; change the `proxy.target` in `vite.config.ts` to point at `http://localhost:4000` for local development.
|
1. **Build and run the application with Docker Compose**:
|
||||||
|
|
||||||
### 3. Desktop app (optional)
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd electron
|
docker-compose up --build
|
||||||
pnpm install
|
|
||||||
pnpm build-front # builds the frontend into electron/frontend_build
|
|
||||||
pnpm start
|
|
||||||
```
|
```
|
||||||
|
|
||||||
See [`docs-vault/Electron.md`](docs-vault/Electron.md) for packaging. The Tauri version lives in `tauri/` on the `feat/tauri-app` branch (see its `tauri/README.md`).
|
4. **Access the app**:
|
||||||
|
- Frontend: Open your browser and navigate to `http://localhost:4200`.
|
||||||
|
- Backend API: Access the API at `http://localhost:3000`.
|
||||||
|
5. **(Optional) Run the app with Electron**:
|
||||||
|
- Follow the instructions in the `electron/README.md` to build and run the desktop app.
|
||||||
|
|
||||||
### Docker
|
## Acknowledgments
|
||||||
|
|
||||||
`docker-compose up --build` starts MySQL, the backend (port 4000) and the **legacy Angular** frontend (port 3000). The React frontend isn't in Docker yet.
|
- Thanks to the Angular, Node.js, and Express communities for their amazing tools and libraries.
|
||||||
|
- Special thanks to (mention any libraries or tools you used, e.g., TMDB API for movie data).
|
||||||
---
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
Detailed docs live in [`docs-vault/`](docs-vault/Index.md) — architecture, API reference, database models, TMDB integration, every page and feature, and known issues.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
|
||||||
- **Mohammed Abad**: [mohammedabad.me@gmail.com](mailto:mohammedabad.me@gmail.com)
|
For questions or feedback, feel free to reach out:
|
||||||
- **GitHub**: [X4Lo](https://github.com/X4Lo)
|
- **Mohammed Abad**: [mohammedabad.me@gmail.com](mailto:mohammedabad.me@gmail.com)
|
||||||
|
- **GitHub**: [X4Lo](https://github.com/X4Lo)
|
||||||
|
|
||||||
Data provided by [TMDB](https://www.themoviedb.org/). This product uses the TMDB API but is not endorsed or certified by TMDB.
|
---
|
||||||
|
|
||||||
|
Enjoy managing your movies and series with **Showy**! 🎬🍿
|
||||||
@@ -10,10 +10,6 @@ const {
|
|||||||
mapEntryRatings,
|
mapEntryRatings,
|
||||||
} = require("../mappers/entryMapper");
|
} = require("../mappers/entryMapper");
|
||||||
const asyncWrapper = require("../utils/asyncWrapper");
|
const asyncWrapper = require("../utils/asyncWrapper");
|
||||||
const maintenanceService = require("../services/maintenanceService");
|
|
||||||
|
|
||||||
// TV series are refreshed at most once per this many hours by the calendar sync
|
|
||||||
const SERIES_SYNC_HOURS = 24;
|
|
||||||
|
|
||||||
const _collectionManager = collectionManager;
|
const _collectionManager = collectionManager;
|
||||||
const _entryManager = entryManager;
|
const _entryManager = entryManager;
|
||||||
@@ -101,19 +97,11 @@ class EntryController {
|
|||||||
res.status(200).json({ message: `Entry with ID ${id} deleted.` });
|
res.status(200).json({ message: `Entry with ID ${id} deleted.` });
|
||||||
});
|
});
|
||||||
|
|
||||||
// * POST - SYNC TV SERIES (calendar)
|
// * GET - SYNC ALL ENTIRES DATA
|
||||||
// Starts a background refresh of airing TV series not refreshed in the last
|
syncSeries = asyncWrapper(async (req, res, next) => {
|
||||||
// 24h (manual refreshes reset that clock). Returns the job status at once.
|
const entries = await _entryManager.SyncSeriesData();
|
||||||
syncSeries = asyncWrapper(async (req, res) => {
|
|
||||||
const job = await maintenanceService.startStaleRefresh(SERIES_SYNC_HOURS, {
|
|
||||||
seriesOnly: true,
|
|
||||||
});
|
|
||||||
res.status(job.alreadyRunning ? 200 : 202).json(job);
|
|
||||||
});
|
|
||||||
|
|
||||||
// * GET - SYNC TV SERIES STATUS
|
res.status(201).json(entries);
|
||||||
syncSeriesStatus = asyncWrapper(async (req, res) => {
|
|
||||||
res.status(200).json(maintenanceService.getStaleRefreshStatus());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// * GET - Get seasons of an entry
|
// * GET - Get seasons of an entry
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ entryRouter.get(
|
|||||||
);
|
);
|
||||||
entryRouter.get("/tmdb/artwork/:type/:tmdbId", entryController.getTmdbArtwork);
|
entryRouter.get("/tmdb/artwork/:type/:tmdbId", entryController.getTmdbArtwork);
|
||||||
|
|
||||||
// Calendar sync: refresh airing TV series older than 24h (GET kept as an alias)
|
|
||||||
entryRouter.post("/sync-series", entryController.syncSeries);
|
|
||||||
entryRouter.get("/sync-series", entryController.syncSeries);
|
entryRouter.get("/sync-series", entryController.syncSeries);
|
||||||
entryRouter.get("/sync-series/status", entryController.syncSeriesStatus);
|
|
||||||
|
|
||||||
entryRouter.get("/", entryController.getAllEntries);
|
entryRouter.get("/", entryController.getAllEntries);
|
||||||
entryRouter.get("/:id", entryController.getEntryById);
|
entryRouter.get("/:id", entryController.getEntryById);
|
||||||
|
|||||||
@@ -565,6 +565,210 @@ class EntryManager {
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** This function will refresh data of series that have the status not 'ended/canceled' and have not been refreshed today
|
||||||
|
*/
|
||||||
|
async SyncSeriesData() {
|
||||||
|
const today = moment().format("YYYY-MM-DD");
|
||||||
|
const entries = await Entry.findAll({
|
||||||
|
where: {
|
||||||
|
is_tvseries: true,
|
||||||
|
autoSync: true,
|
||||||
|
last_fetch: {
|
||||||
|
[Op.ne]: today,
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
[Op.notIn]: ["Ended", "Canceled"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
logToFile(`Started syncing ${entries.length} Tv-Series`);
|
||||||
|
|
||||||
|
const results = await Promise.all(
|
||||||
|
entries.map((entry) => this.SyncSerieData(entry.id)),
|
||||||
|
);
|
||||||
|
logToFile(`Syncing Tv-Series Finished`);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
async SyncSerieData(entryId) {
|
||||||
|
const oldEntry = await Entry.findByPk(entryId, {
|
||||||
|
include: [
|
||||||
|
{ model: EntryId, as: "entryId" },
|
||||||
|
{ model: EntryRating, as: "entryRating" },
|
||||||
|
{ model: EntrySeen, as: "entrySeen" },
|
||||||
|
{ model: Season, as: "seasons" },
|
||||||
|
{ model: Media, as: "medias" },
|
||||||
|
{
|
||||||
|
model: Genre,
|
||||||
|
as: "genres",
|
||||||
|
attributes: ["id"],
|
||||||
|
through: {
|
||||||
|
attributes: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
logToFile(
|
||||||
|
`Sync Started For: ${oldEntry.entryId.tmdb_id}/${oldEntry.title}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!oldEntry) throw NotFoundError("Entry Not Found");
|
||||||
|
|
||||||
|
const entryData = await fetchEntryData(
|
||||||
|
oldEntry.entryId.tmdb_id,
|
||||||
|
oldEntry.is_tvseries,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!entryData) throw new ValidationError(`Couldn't Fetch Entry Data`);
|
||||||
|
|
||||||
|
// ! 1 - Normal Data
|
||||||
|
let newData = {
|
||||||
|
title: entryData.title || entryData.name,
|
||||||
|
original_title: entryData.original_title || entryData.original_name,
|
||||||
|
release_date: entryData.release_date || entryData.first_air_date,
|
||||||
|
runtime: entryData.runtime || null,
|
||||||
|
|
||||||
|
tagline: entryData.tagline || null,
|
||||||
|
storyline: entryData.overview,
|
||||||
|
country:
|
||||||
|
entryData.production_countries.length > 0
|
||||||
|
? entryData.production_countries[0].name
|
||||||
|
: null,
|
||||||
|
|
||||||
|
status: entryData.status,
|
||||||
|
|
||||||
|
poster_path: entryData.poster_path,
|
||||||
|
banner_path: entryData.backdrop_path,
|
||||||
|
|
||||||
|
last_fetch: new Date(),
|
||||||
|
};
|
||||||
|
|
||||||
|
await oldEntry.update(newData);
|
||||||
|
|
||||||
|
// ! 2 - Ids
|
||||||
|
// TODO: get more ids
|
||||||
|
await oldEntry.entryId.update({
|
||||||
|
imdb_id: entryData.imdb_id,
|
||||||
|
});
|
||||||
|
|
||||||
|
// ! 3 - Ratings
|
||||||
|
await oldEntry.entryRating.update({
|
||||||
|
tmdb_rating: entryData.vote_average,
|
||||||
|
});
|
||||||
|
|
||||||
|
// ! 4 - Genres
|
||||||
|
const currentGenresIds = oldEntry.genres.map((genre) => genre.id);
|
||||||
|
entryData.genres.forEach(async (genre) => {
|
||||||
|
// ? only assing the genre if its not already asigned
|
||||||
|
if (!currentGenresIds.includes(genre.id)) {
|
||||||
|
await EntryGenre.create({
|
||||||
|
genre_id: genre.id,
|
||||||
|
entry_id: oldEntry.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ! 5 - Seasons
|
||||||
|
// ? only update the last seasons available + season 0 (specials)
|
||||||
|
if (oldEntry.is_tvseries) {
|
||||||
|
const latestAvailableSeason = await Math.max(
|
||||||
|
...oldEntry.seasons.map((s) => s.season_number),
|
||||||
|
);
|
||||||
|
for (const season of entryData.seasons) {
|
||||||
|
if (
|
||||||
|
season.season_number != 0 &&
|
||||||
|
season.season_number != latestAvailableSeason
|
||||||
|
)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// ? fetch new season data from tmdb
|
||||||
|
let seasonData = await fetchSeasonData(
|
||||||
|
oldEntry.entryId.tmdb_id,
|
||||||
|
season.season_number,
|
||||||
|
);
|
||||||
|
|
||||||
|
// * find or create the season
|
||||||
|
const [oldSeason, createdSeason] = await Season.findOrCreate({
|
||||||
|
where: { tmdb_id: season.id },
|
||||||
|
defaults: {
|
||||||
|
tmdb_id: seasonData.id,
|
||||||
|
entry_id: oldEntry.id,
|
||||||
|
name: seasonData.name,
|
||||||
|
overview: seasonData.overview,
|
||||||
|
season_number: seasonData.season_number,
|
||||||
|
episode_count: seasonData.episodes.length,
|
||||||
|
air_date: seasonData.air_date,
|
||||||
|
user_rating: 0,
|
||||||
|
tmdb_rating: seasonData.vote_average,
|
||||||
|
poster_path: seasonData.poster_path,
|
||||||
|
banner_path: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// ? if the season already exist then just update it with new data
|
||||||
|
if (!createdSeason) {
|
||||||
|
await oldSeason.update({
|
||||||
|
tmdb_id: seasonData.id,
|
||||||
|
entry_id: oldEntry.id,
|
||||||
|
name: seasonData.name,
|
||||||
|
overview: seasonData.overview,
|
||||||
|
season_number: seasonData.season_number,
|
||||||
|
episode_count: seasonData.episodes.length,
|
||||||
|
air_date: seasonData.air_date,
|
||||||
|
user_rating: 0,
|
||||||
|
tmdb_rating: seasonData.vote_average,
|
||||||
|
poster_path: seasonData.poster_path,
|
||||||
|
banner_path: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// * forging updated/created season into a variable
|
||||||
|
let existingSeason = oldSeason || createdSeason;
|
||||||
|
|
||||||
|
// ! 6 - Episodes
|
||||||
|
for (const episode of seasonData.episodes) {
|
||||||
|
// * find or create the episode
|
||||||
|
const [oldEpisode, createdEpisode] = await Episode.findOrCreate({
|
||||||
|
where: { tmdb_id: episode.id },
|
||||||
|
defaults: {
|
||||||
|
season_id: existingSeason.id,
|
||||||
|
name: episode.name,
|
||||||
|
overview: episode.overview,
|
||||||
|
episode_number: episode.episode_number,
|
||||||
|
episode_type: episode.episode_type,
|
||||||
|
runtime: episode.runtime,
|
||||||
|
air_date: episode.air_date,
|
||||||
|
tmdb_rating: episode.vote_average,
|
||||||
|
still_path: episode.still_path,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// ? if the episode already exist then just update it with new data
|
||||||
|
if (!createdEpisode) {
|
||||||
|
await oldEpisode.update({
|
||||||
|
tmdb_id: episode.id,
|
||||||
|
season_id: existingSeason.id,
|
||||||
|
name: episode.name,
|
||||||
|
overview: episode.overview,
|
||||||
|
episode_number: episode.episode_number,
|
||||||
|
episode_type: episode.episode_type,
|
||||||
|
runtime: episode.runtime,
|
||||||
|
air_date: episode.air_date,
|
||||||
|
tmdb_rating: episode.vote_average,
|
||||||
|
still_path: episode.still_path,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await oldEntry.reload();
|
||||||
|
|
||||||
|
return oldEntry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new EntryManager();
|
module.exports = new EntryManager();
|
||||||
@@ -575,20 +575,14 @@ class MaintenanceService {
|
|||||||
* Entries due for a TMDB refresh: never fetched, or last fetched more than
|
* Entries due for a TMDB refresh: never fetched, or last fetched more than
|
||||||
* `hours` ago. Entries with auto sync turned off are skipped.
|
* `hours` ago. Entries with auto sync turned off are skipped.
|
||||||
* @param {number} [hours=24]
|
* @param {number} [hours=24]
|
||||||
* @param {{ seriesOnly?: boolean }} [options] - seriesOnly: only TV series
|
|
||||||
* that are still airing (not Ended/Canceled), for the calendar sync
|
|
||||||
*/
|
*/
|
||||||
async getStaleEntries(hours = 24, { seriesOnly = false } = {}) {
|
async getStaleEntries(hours = 24) {
|
||||||
const cutoff = new Date(Date.now() - hours * 60 * 60 * 1000);
|
const cutoff = new Date(Date.now() - hours * 60 * 60 * 1000);
|
||||||
return Entry.findAll({
|
return Entry.findAll({
|
||||||
attributes: ["id", "title", "last_fetch"],
|
attributes: ["id", "title", "last_fetch"],
|
||||||
where: {
|
where: {
|
||||||
autoSync: { [Op.not]: false },
|
autoSync: { [Op.not]: false },
|
||||||
[Op.or]: [{ last_fetch: null }, { last_fetch: { [Op.lt]: cutoff } }],
|
[Op.or]: [{ last_fetch: null }, { last_fetch: { [Op.lt]: cutoff } }],
|
||||||
...(seriesOnly && {
|
|
||||||
is_tvseries: true,
|
|
||||||
status: { [Op.or]: [null, { [Op.notIn]: ["Ended", "Canceled"] }] },
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
order: [["last_fetch", "ASC"]],
|
order: [["last_fetch", "ASC"]],
|
||||||
});
|
});
|
||||||
@@ -606,20 +600,18 @@ class MaintenanceService {
|
|||||||
* TMDB requests go through tmdbService's rate limiter, so a large library
|
* TMDB requests go through tmdbService's rate limiter, so a large library
|
||||||
* is spread out instead of hammering the API.
|
* is spread out instead of hammering the API.
|
||||||
* @param {number} [hours=24]
|
* @param {number} [hours=24]
|
||||||
* @param {{ seriesOnly?: boolean }} [options] - see getStaleEntries
|
|
||||||
* @returns {Object} the job status, or `{ alreadyRunning: true, ... }`
|
* @returns {Object} the job status, or `{ alreadyRunning: true, ... }`
|
||||||
*/
|
*/
|
||||||
async startStaleRefresh(hours = 24, options = {}) {
|
async startStaleRefresh(hours = 24) {
|
||||||
if (this.staleRefreshJob?.running) {
|
if (this.staleRefreshJob?.running) {
|
||||||
return { alreadyRunning: true, ...this.getStaleRefreshStatus() };
|
return { alreadyRunning: true, ...this.getStaleRefreshStatus() };
|
||||||
}
|
}
|
||||||
|
|
||||||
const entries = await this.getStaleEntries(hours, options);
|
const entries = await this.getStaleEntries(hours);
|
||||||
const job = {
|
const job = {
|
||||||
running: true,
|
running: true,
|
||||||
cancelRequested: false,
|
cancelRequested: false,
|
||||||
hours,
|
hours,
|
||||||
scope: options.seriesOnly ? "series" : "all",
|
|
||||||
total: entries.length,
|
total: entries.length,
|
||||||
done: 0,
|
done: 0,
|
||||||
succeeded: 0,
|
succeeded: 0,
|
||||||
|
|||||||
@@ -199,15 +199,3 @@ Response types:
|
|||||||
- **Duplicate credits:** `{ groups: number, duplicates: number, deleted: number }`
|
- **Duplicate credits:** `{ groups: number, duplicates: number, deleted: number }`
|
||||||
- **Auto-fix watch statuses:** `{ completed: number, watching: number, planToWatch: number }`
|
- **Auto-fix watch statuses:** `{ completed: number, watching: number, planToWatch: number }`
|
||||||
- **Impossible seen dates:** Scan → `{ count: number }`, Fix → `{ count: number, added: number }`
|
- **Impossible seen dates:** Scan → `{ count: number }`, Fix → `{ count: number, added: number }`
|
||||||
|
|
||||||
## entries.ts — additions
|
|
||||||
|
|
||||||
`getRecommendations(id)`, `getTmdbRecommendations(type, tmdbId)`, `getArtwork(id)`, `getTmdbArtwork(type, tmdbId)`, `addArtwork(id, { type, file_path })`
|
|
||||||
|
|
||||||
## maintenance.ts — additions
|
|
||||||
|
|
||||||
`getStaleEntries(hours)`, `startStaleRefresh(hours)` (202 or 409), `cancelStaleRefresh()`
|
|
||||||
|
|
||||||
## history.ts
|
|
||||||
|
|
||||||
`historyApi.getYears()`, `historyApi.getYear(year)` — types `HistoryYear`, `HistoryEntry`, `HistoryEpisode`, `HistoryEvent`, `HistoryYearData`
|
|
||||||
@@ -57,10 +57,7 @@ All endpoints are prefixed with `/api/v1`. See [[Backend]] for server setup.
|
|||||||
| `DELETE` | `/entries/:id` | Delete entry and all related data |
|
| `DELETE` | `/entries/:id` | Delete entry and all related data |
|
||||||
| `GET` | `/entries/:id/seasons` | Get all seasons for a TV entry |
|
| `GET` | `/entries/:id/seasons` | Get all seasons for a TV entry |
|
||||||
| `GET` | `/entries/:id/credits` | Get ALL credits (cast + crew) for an entry, with associated `person` populated. Used by [[Pages#EntryCastsPage\|EntryCastsPage]] |
|
| `GET` | `/entries/:id/credits` | Get ALL credits (cast + crew) for an entry, with associated `person` populated. Used by [[Pages#EntryCastsPage\|EntryCastsPage]] |
|
||||||
| `GET` | `/entries/:id/recommendations` | Live TMDB recommendations for a library entry (not stored) |
|
| `PUT` | `/entries/:id/refresh` | Force refresh from TMDB |
|
||||||
| `GET` | `/entries/:id/artwork` | TMDB posters/backdrops/logos merged with the entry's media — see [[Artwork]] |
|
|
||||||
| `POST` | `/entries/:id/artwork` | Download a TMDB image into the media table: `{ type, file_path }` |
|
|
||||||
| `PUT` | `/entries/:id/refresh` | Force refresh from TMDB (details, ids, ratings, genres, networks, seasons, episodes, credits) |
|
|
||||||
| `PUT` | `/entries/:id/fetch-collection` | Fetch/create TMDB collection for entry |
|
| `PUT` | `/entries/:id/fetch-collection` | Fetch/create TMDB collection for entry |
|
||||||
| `GET` | `/entries/sync-series` | Batch refresh all non-ended TV series |
|
| `GET` | `/entries/sync-series` | Batch refresh all non-ended TV series |
|
||||||
| `POST` | `/entries/:id/media` | Upload media (multipart — poster/backdrop/logo) |
|
| `POST` | `/entries/:id/media` | Upload media (multipart — poster/backdrop/logo) |
|
||||||
@@ -76,9 +73,7 @@ All endpoints are prefixed with `/api/v1`. See [[Backend]] for server setup.
|
|||||||
| `GET` | `/entries/tmdb/top-rated/:type` | Top-rated movies/tv |
|
| `GET` | `/entries/tmdb/top-rated/:type` | Top-rated movies/tv |
|
||||||
| `GET` | `/entries/tmdb/upcoming/movie` | Upcoming movies |
|
| `GET` | `/entries/tmdb/upcoming/movie` | Upcoming movies |
|
||||||
| `GET` | `/entries/tmdb/search?query=&page=` | Multi-search |
|
| `GET` | `/entries/tmdb/search?query=&page=` | Multi-search |
|
||||||
| `GET` | `/entries/tmdb/preview/:type/:tmdbId` | Preview a TMDB entry before adding. Includes `entry` (same shape as a library entry), `seasons` and `credits` (cast + directors) |
|
| `GET` | `/entries/tmdb/preview/:type/:tmdbId` | Preview TMDB entry (movie/tv) before adding — returns local + TMDB data |
|
||||||
| `GET` | `/entries/tmdb/recommendations/:type/:tmdbId` | Recommendations by TMDB id (entries not in the library) |
|
|
||||||
| `GET` | `/entries/tmdb/artwork/:type/:tmdbId` | TMDB artwork by TMDB id (read-only) |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -233,19 +228,6 @@ See [[Statistics]] for chart details.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## History
|
|
||||||
|
|
||||||
> [!info] File: `routes/history.routes.js` → `services/historyService.js`
|
|
||||||
|
|
||||||
See [[History]].
|
|
||||||
|
|
||||||
| Method | Path | Description |
|
|
||||||
|---|---|---|
|
|
||||||
| `GET` | `/history/years` | Years with watches, newest first: `[{ year, movies, episodes }]` |
|
|
||||||
| `GET` | `/history/:year` | Every movie/episode watch in a year, newest first: `{ year, entries: { [id]: entry }, events: [...] }` |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
|
|
||||||
> [!info] File: `routes/settings.routes.js` → `controllers/settingsController.js`
|
> [!info] File: `routes/settings.routes.js` → `controllers/settingsController.js`
|
||||||
@@ -320,18 +302,6 @@ See [[Settings Page#Cleanup]] for the UI.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Stale Entries Refresh
|
|
||||||
|
|
||||||
| Method | Path | Description |
|
|
||||||
|---|---|---|
|
|
||||||
| `GET` | `/maintenance/stale-entries?hours=24` | Count of entries not refreshed in the last `hours` + current job status |
|
|
||||||
| `POST` | `/maintenance/stale-entries/refresh?hours=24` | Start refreshing them in the background (`202`; `409` if already running) |
|
|
||||||
| `DELETE` | `/maintenance/stale-entries/refresh` | Cancel the running job |
|
|
||||||
|
|
||||||
Entries with auto sync off are skipped. TMDB requests go through the [[TMDB Integration#Rate Limiting|rate limiter]].
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Import
|
## Import
|
||||||
|
|
||||||
> [!info] File: `routes/import.routes.js` → `controllers/importController.js`
|
> [!info] File: `routes/import.routes.js` → `controllers/importController.js`
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
---
|
|
||||||
title: Artwork
|
|
||||||
tags:
|
|
||||||
- feature
|
|
||||||
- media
|
|
||||||
- tmdb
|
|
||||||
---
|
|
||||||
|
|
||||||
# Artwork
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
The **Artwork** section at the bottom of [[Pages#EntryDetailsPage|EntryDetailsPage]] lists every TMDB poster, backdrop and logo for the title, merged with the entry's [[Media System|media table]].
|
|
||||||
|
|
||||||
## UI
|
|
||||||
|
|
||||||
- Tabs: **Posters / Backdrops / Logos** with counts
|
|
||||||
- **Two rows** shown per tab (columns follow the breakpoint); **Show more** adds two rows
|
|
||||||
- Language filter (no-text images first, then English, then the original language); **In library** toggle
|
|
||||||
- Badges: **In library** / **Selected**; language tag; TMDB vote average on hover
|
|
||||||
- Click an image to open it full size
|
|
||||||
- Library entries: **Add** downloads the original into the media table; titles not in the library are read-only
|
|
||||||
|
|
||||||
## Matching
|
|
||||||
|
|
||||||
Media rows record the TMDB `file_path` they were downloaded from in `media.tmdb_path` (`tmdbPath`). A TMDB image is **in library** when a media row of the same type has that path. Media without a path (custom uploads, images downloaded before the column existed) appear as local-only items first.
|
|
||||||
|
|
||||||
> [!warning] Older downloads
|
|
||||||
> Images downloaded before `tmdb_path` existed can't be matched, so the same TMDB image can be added again. See [[Known Issues]].
|
|
||||||
|
|
||||||
## Adding
|
|
||||||
|
|
||||||
`POST /entries/:id/artwork { type, file_path }`:
|
|
||||||
|
|
||||||
1. Validates the type (`poster` / `backdrop` / `logo`) and path
|
|
||||||
2. Returns the existing row if that image is already in the library
|
|
||||||
3. Downloads `https://image.tmdb.org/t/p/original{file_path}` into `images/entries/{type}s/`
|
|
||||||
4. Creates the media row — **selected** only if no image of that type is selected yet
|
|
||||||
5. Generates the preview file
|
|
||||||
|
|
||||||
## Implementation
|
|
||||||
|
|
||||||
| Layer | File |
|
|
||||||
|---|---|
|
|
||||||
| Service | `backend/services/artworkService.js` |
|
|
||||||
| Endpoints | `GET /entries/:id/artwork`, `POST /entries/:id/artwork`, `GET /entries/tmdb/artwork/:type/:tmdbId` |
|
|
||||||
| Hooks | `useArtwork`, `useAddArtwork` in `react_frontend/src/hooks/useEntries.ts` |
|
|
||||||
| Component | `react_frontend/src/components/entries/ArtworkSection.tsx` |
|
|
||||||
@@ -82,26 +82,6 @@ See [[Discovery Videos]].
|
|||||||
| `VideoDropzone` | `discovery-videos/VideoDropzone.tsx` | Native HTML5 drag & drop zone (no dependency) |
|
| `VideoDropzone` | `discovery-videos/VideoDropzone.tsx` | Native HTML5 drag & drop zone (no dependency) |
|
||||||
| `EntryMultiSelect` | `discovery-videos/EntryMultiSelect.tsx` | Search-first library entry picker (debounced 250 ms) reading from [[Stores\|library store]] |
|
| `EntryMultiSelect` | `discovery-videos/EntryMultiSelect.tsx` | Search-first library entry picker (debounced 250 ms) reading from [[Stores\|library store]] |
|
||||||
|
|
||||||
## Entry Detail Components
|
|
||||||
|
|
||||||
| Component | File | Purpose |
|
|
||||||
|---|---|---|
|
|
||||||
| `ArtworkSection` | `components/entries/ArtworkSection.tsx` | [[Artwork]] tabs, language filter, add to library |
|
|
||||||
| `WatchProvidersCard` | `components/entries/WatchProvidersCard.tsx` | Where to watch, per country |
|
|
||||||
| `TrailerDialog` | `components/entries/TrailerDialog.tsx` | In-app YouTube player for stored TMDB videos |
|
|
||||||
| `RecommendationsSection` | `components/entries/RecommendationsSection.tsx` | "More like this" by entry id or TMDB id |
|
|
||||||
| `SeasonsContainer` | `components/entries/SeasonsContainer.tsx` | Seasons with list/cards toggle; cards show a circular progress ring around the mark-watched button |
|
|
||||||
| `SeasonEpisodes`, `EpisodeViewToggle` | `components/entries/SeasonEpisodes.tsx` | Season page episodes in list or card view |
|
|
||||||
| `DetailHero` (+ `MetaItem`, `HeroChip`, `IconAction`, `IconLink`, `DetailSection`, `DetailCard`, `DetailRow`) | `components/entries/DetailHero.tsx` | Shared hero and building blocks for the season and episode pages |
|
|
||||||
|
|
||||||
## History Components
|
|
||||||
|
|
||||||
| Component | File | Purpose |
|
|
||||||
|---|---|---|
|
|
||||||
| `HistoryList` | `components/history/HistoryList.tsx` | Months → days → rows |
|
|
||||||
| `HistoryTimeline` | `components/history/HistoryTimeline.tsx` | Vertical timeline with month dividers |
|
|
||||||
| `YearInReview` | `components/history/YearInReview.tsx` | Wrapped-style stats |
|
|
||||||
|
|
||||||
## Skeletons
|
## Skeletons
|
||||||
|
|
||||||
> [!info] File: `components/skeletons/PageSkeletons.tsx`
|
> [!info] File: `components/skeletons/PageSkeletons.tsx`
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ MySQL database named **Showzy**, managed by Sequelize 6 ORM.
|
|||||||
|
|
||||||
- Connection: `localhost`, user `root`, password `password`
|
- Connection: `localhost`, user `root`, password `password`
|
||||||
- Sync mode: `sequelize.sync({ alter: false })` — no auto-alter in production
|
- Sync mode: `sequelize.sync({ alter: false })` — no auto-alter in production
|
||||||
- Migrations: `config/migrations.js` runs after sync on every start. It adds any column a model defines that the table lacks (additive only, nothing is dropped) and widens a few changed types (`certification`, `last_fetch`, `network_studio`, `networks.name`). New model attributes reach existing databases automatically on the next start.
|
|
||||||
- Logging: writes SQL to `sequelize.log`
|
- Logging: writes SQL to `sequelize.log`
|
||||||
- Genre seeding: 27 TMDB genres auto-seeded on startup
|
- Genre seeding: 27 TMDB genres auto-seeded on startup
|
||||||
|
|
||||||
@@ -110,7 +109,6 @@ See [[Models]] for detailed field definitions of every model.
|
|||||||
## Important Files
|
## Important Files
|
||||||
|
|
||||||
- `backend/config/database.js` — Sequelize connection
|
- `backend/config/database.js` — Sequelize connection
|
||||||
- `backend/config/migrations.js` — Startup column migrations
|
|
||||||
- `backend/config/relations.js` — All associations
|
- `backend/config/relations.js` — All associations
|
||||||
- `backend/config/dataInitializer.js` — Genre seeding
|
- `backend/config/dataInitializer.js` — Genre seeding
|
||||||
- `backend/config/sequelizeHooks.js` — Collection order hooks
|
- `backend/config/sequelizeHooks.js` — Collection order hooks
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ tags:
|
|||||||
|
|
||||||
# Electron
|
# Electron
|
||||||
|
|
||||||
> [!note] Tauri in progress
|
|
||||||
> A Tauri v2 version of the desktop app is being built in `tauri/` on the `feat/tauri-app` branch (not merged yet). Electron stays as is until it's ready. Dev mode works on Windows; the release build is blocked by the packaged backend resolving `settings.json` from inside pkg's read-only bundle. See `tauri/README.md` on that branch.
|
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Electron 34 wraps the Showy backend + React frontend into a standalone desktop application for Windows. The backend runs **in-process** (no child process spawn), and the app uses a custom frameless title bar with IPC-driven window controls.
|
Electron 34 wraps the Showy backend + React frontend into a standalone desktop application for Windows. The backend runs **in-process** (no child process spawn), and the app uses a custom frameless title bar with IPC-driven window controls.
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
---
|
|
||||||
title: History
|
|
||||||
tags:
|
|
||||||
- feature
|
|
||||||
- history
|
|
||||||
- watch-tracking
|
|
||||||
---
|
|
||||||
|
|
||||||
# History
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
Everything you watched, by year, at `/history` (sidebar → History, or the command palette). Built from [[Watch Tracking|EntrySeen and EpisodeSeen]] records.
|
|
||||||
|
|
||||||
## Controls
|
|
||||||
|
|
||||||
- **Year picker** — only years with watches; previous / next arrows
|
|
||||||
- **Type filter** — All / Movies / TV
|
|
||||||
- Tab, year and filter are kept in the URL: `/history?tab=timeline&year=2024&type=tv`
|
|
||||||
|
|
||||||
## Tabs
|
|
||||||
|
|
||||||
### History
|
|
||||||
|
|
||||||
Months newest first, each with a sticky header (movies, episodes, watch time). Inside each month, watches are grouped by day. Each row shows the poster, title, episode, runtime and who you watched with.
|
|
||||||
|
|
||||||
### Timeline
|
|
||||||
|
|
||||||
A vertical line from the latest watch at the top down to January, with a divider per month. Poster cards alternate sides on wide screens; the dot colour marks movies (amber) or TV (blue).
|
|
||||||
|
|
||||||
### Year in Review
|
|
||||||
|
|
||||||
Wrapped-style stats: total hours (and full days), movies, episodes, shows, days watching, longest streak, busiest day, biggest binge, favourite weekday and month, top 5 shows, top genres by time, month-by-month and weekday charts, top-rated movies, rewatches, top networks, watch buddies, new shows started (first episode watched was S1E1), and the first and last watch of the year.
|
|
||||||
|
|
||||||
## Sessions
|
|
||||||
|
|
||||||
Episodes of the same show watched back to back on the same day are grouped into one **session** (e.g. "S1 E1–E5 · 5 episodes"). Lists and the timeline show sessions; the review counts individual watches.
|
|
||||||
|
|
||||||
## Unknown Dates
|
|
||||||
|
|
||||||
Watches with `accuracy = UNKNOWN` (bulk imports) are badged "Date unknown". The Year in Review leaves them out by default because they distort streaks, busiest days and monthly charts; a checkbox includes them.
|
|
||||||
|
|
||||||
## Implementation
|
|
||||||
|
|
||||||
| Layer | File |
|
|
||||||
|---|---|
|
|
||||||
| Endpoints | `backend/routes/history.routes.js` — `GET /history/years`, `GET /history/:year` |
|
|
||||||
| Service | `backend/services/historyService.js` |
|
|
||||||
| API client / hooks | `react_frontend/src/api/history.ts`, `react_frontend/src/hooks/useHistory.ts` |
|
|
||||||
| Grouping & stats | `react_frontend/src/lib/history.ts` — `buildSessions`, `groupByMonth`, `computeReview` |
|
|
||||||
| Page | `react_frontend/src/pages/HistoryPage.tsx` |
|
|
||||||
| Tabs | `react_frontend/src/components/history/` — `HistoryList`, `HistoryTimeline`, `YearInReview` |
|
|
||||||
|
|
||||||
`GET /history/:year` returns each title once in `entries` (poster, runtime, genres, networks, rating) and references it from every watch in `events`. A busy year (~1,650 watches) is about 530 KB.
|
|
||||||
|
|
||||||
## See Also
|
|
||||||
|
|
||||||
- [[Watch Tracking]]
|
|
||||||
- [[Statistics]] — all-time charts on the dashboard
|
|
||||||
@@ -140,19 +140,6 @@ See [[Discovery Videos]].
|
|||||||
| `useUpdateVideo()` | Mutation | `PUT /discovery-videos/:id` |
|
| `useUpdateVideo()` | Mutation | `PUT /discovery-videos/:id` |
|
||||||
| `useDeleteVideo()` | Mutation | `DELETE /discovery-videos/:id` |
|
| `useDeleteVideo()` | Mutation | `DELETE /discovery-videos/:id` |
|
||||||
|
|
||||||
## useEntries — TMDB data additions
|
|
||||||
|
|
||||||
- `useEntryRecommendations(id)` / `useTmdbRecommendations(tmdbId, type)` — "More like this"
|
|
||||||
- `useArtwork({ entryId } | { tmdbId, type })` / `useAddArtwork(entryId)` — [[Artwork]]
|
|
||||||
- `useTmdbPreview(tmdbId, type)` — also returns the entry-shaped `entry` used by the unified details page
|
|
||||||
|
|
||||||
## useHistory
|
|
||||||
|
|
||||||
> [!info] File: `hooks/useHistory.ts`
|
|
||||||
|
|
||||||
- `useHistoryYears()` — `GET /history/years`
|
|
||||||
- `useHistoryYear(year)` — `GET /history/:year`
|
|
||||||
|
|
||||||
## useDebounce
|
## useDebounce
|
||||||
|
|
||||||
> [!info] File: `hooks/useDebounce.ts`
|
> [!info] File: `hooks/useDebounce.ts`
|
||||||
|
|||||||
+2
-4
@@ -23,7 +23,7 @@ aliases:
|
|||||||
- [[Tech Stack]] — All technologies and versions
|
- [[Tech Stack]] — All technologies and versions
|
||||||
- [[Deployment]] — Docker Compose setup
|
- [[Deployment]] — Docker Compose setup
|
||||||
- [[Env]] — Environment variables and configuration
|
- [[Env]] — Environment variables and configuration
|
||||||
- [[Electron]] — Desktop wrapper details (a Tauri version is in progress)
|
- [[Electron]] — Desktop wrapper details
|
||||||
|
|
||||||
## Backend
|
## Backend
|
||||||
|
|
||||||
@@ -35,13 +35,12 @@ aliases:
|
|||||||
- [[Error Handling]] — Custom error classes and middleware
|
- [[Error Handling]] — Custom error classes and middleware
|
||||||
- [[TMDB Integration]] — External API proxy and data fetching
|
- [[TMDB Integration]] — External API proxy and data fetching
|
||||||
- [[Media System]] — Image storage, download, optimization, previews
|
- [[Media System]] — Image storage, download, optimization, previews
|
||||||
- [[Artwork]] — TMDB posters/backdrops/logos merged with the media table
|
|
||||||
- [[Import System]] — Bulk import flows
|
- [[Import System]] — Bulk import flows
|
||||||
|
|
||||||
## Frontend
|
## Frontend
|
||||||
|
|
||||||
- [[Frontend]] — React app structure, patterns, conventions
|
- [[Frontend]] — React app structure, patterns, conventions
|
||||||
- [[Routing]] — All routes with lazy loading
|
- [[Routing]] — All 17 routes with lazy loading
|
||||||
- [[Pages]] — Every page component
|
- [[Pages]] — Every page component
|
||||||
- [[Components]] — All UI components by category
|
- [[Components]] — All UI components by category
|
||||||
- [[Hooks]] — Custom hooks (queries, mutations, utilities)
|
- [[Hooks]] — Custom hooks (queries, mutations, utilities)
|
||||||
@@ -56,7 +55,6 @@ aliases:
|
|||||||
- [[Library]] — Entry management, watchlist, favorites
|
- [[Library]] — Entry management, watchlist, favorites
|
||||||
- [[Collections]] — TMDB and user collections
|
- [[Collections]] — TMDB and user collections
|
||||||
- [[Watch Tracking]] — EntrySeen, EpisodeSeen, accuracy system
|
- [[Watch Tracking]] — EntrySeen, EpisodeSeen, accuracy system
|
||||||
- [[History]] — History list, timeline and year in review
|
|
||||||
- [[Streaming]] — In-app streaming system with 4 providers (8 servers)
|
- [[Streaming]] — In-app streaming system with 4 providers (8 servers)
|
||||||
- [[Calendar]] — Upcoming episodes view
|
- [[Calendar]] — Upcoming episodes view
|
||||||
- [[Discovery Videos]] — Personal video vault (upload + link to library entries)
|
- [[Discovery Videos]] — Personal video vault (upload + link to library entries)
|
||||||
|
|||||||
@@ -49,12 +49,6 @@ Tracked bugs and technical debt items.
|
|||||||
- **Impact:** DoS risk if backend is exposed
|
- **Impact:** DoS risk if backend is exposed
|
||||||
- **Fix:** Gate behind dev-mode check
|
- **Fix:** Gate behind dev-mode check
|
||||||
|
|
||||||
### Packaged Backend Can't Find settings.json
|
|
||||||
|
|
||||||
- **Issue:** `configService` resolves `settings.json` from `__dirname`, which points inside pkg's read-only snapshot in `backend.exe`
|
|
||||||
- **Impact:** Blocks the Tauri release build (sidecar backend); see [[Electron]]
|
|
||||||
- **Fix:** Resolve settings next to the executable (`process.execPath`) or a user data folder when running under pkg
|
|
||||||
|
|
||||||
## Frontend
|
## Frontend
|
||||||
|
|
||||||
### Implicit `any` Types in SeasonPage
|
### Implicit `any` Types in SeasonPage
|
||||||
@@ -77,23 +71,6 @@ Tracked bugs and technical debt items.
|
|||||||
- **Impact:** [[Normalizers]] layer exists to handle this, but it's fragile
|
- **Impact:** [[Normalizers]] layer exists to handle this, but it's fragile
|
||||||
- **Fix:** Standardize backend response format (ideally all snake_case)
|
- **Fix:** Standardize backend response format (ideally all snake_case)
|
||||||
|
|
||||||
### Web Build Fails Type Checking
|
|
||||||
|
|
||||||
- **Issue:** `tsc -b` (and so `pnpm build`) reports ~41 existing errors, mostly `asChild` on Base UI components and `string | null` select values (LibraryPage, WatchlistPage, several dialogs)
|
|
||||||
- **Impact:** The plain web build fails; Vite dev, Electron and Tauri dev still run
|
|
||||||
- **Fix:** Replace `asChild` with `render` props and narrow select values
|
|
||||||
|
|
||||||
### Old Media Not Matched in Artwork
|
|
||||||
|
|
||||||
- **Issue:** Images downloaded before `media.tmdb_path` existed have no TMDB path
|
|
||||||
- **Impact:** They show as local-only in [[Artwork]], and the same TMDB image can be added again as a duplicate
|
|
||||||
- **Fix:** Backfill by re-downloading, or compare image hashes
|
|
||||||
|
|
||||||
### Unknown-Date Watches
|
|
||||||
|
|
||||||
- **Issue:** ~311 imported movie watches have `accuracy = UNKNOWN`
|
|
||||||
- **Impact:** Badged in [[History]] and excluded from the Year in Review by default (toggle to include)
|
|
||||||
|
|
||||||
## Database
|
## Database
|
||||||
|
|
||||||
### Franchise Model Unused
|
### Franchise Model Unused
|
||||||
@@ -105,9 +82,9 @@ Tracked bugs and technical debt items.
|
|||||||
|
|
||||||
### No Database Migrations
|
### No Database Migrations
|
||||||
|
|
||||||
- **Issue:** `sequelize.sync({ alter })` is disabled; `config/migrations.js` only adds missing columns and widens a fixed list of types
|
- **Issue:** Schema changes rely on `sequelize.sync({ alter })` which is disabled (`doUpdate = false`)
|
||||||
- **Impact:** Renames, drops and index changes still need manual SQL
|
- **Impact:** Manual schema management required for changes
|
||||||
- **Fix:** Adopt versioned Sequelize migrations if the schema starts changing in non-additive ways
|
- **Fix:** Implement proper Sequelize migrations
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
|
|||||||
@@ -51,10 +51,9 @@ All entries are held in [[Stores|useLibraryStore]] as a `Map<number, Entry>` for
|
|||||||
|
|
||||||
## Pages
|
## Pages
|
||||||
|
|
||||||
- [[Pages#LibraryPage|LibraryPage]] — Grid of all library entries (All / Movies / TV tabs + Favorites and Hidden toggles)
|
- [[Pages#LibraryPage|LibraryPage]] — Grid of all library entries
|
||||||
- [[Pages#WatchlistPage|WatchlistPage]] — Grid of watchlist entries
|
- [[Pages#WatchlistPage|WatchlistPage]] — Grid of watchlist entries
|
||||||
- [[Pages#EntryDetailsPage|EntryDetailsPage]] — Entry detail view (also used for titles not in the library)
|
- [[Pages#EntryDetailsPage|EntryDetailsPage]] — Entry detail view
|
||||||
- [[History]] — Everything watched, by year
|
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ Key fields:
|
|||||||
- `path` — UUID filename on disk
|
- `path` — UUID filename on disk
|
||||||
- `isSelected` — the "active" image displayed in UI
|
- `isSelected` — the "active" image displayed in UI
|
||||||
- `isCustom` — user-uploaded (vs TMDB-downloaded)
|
- `isCustom` — user-uploaded (vs TMDB-downloaded)
|
||||||
- `tmdbPath` — TMDB `file_path` the image came from; recorded on every TMDB download so [[Artwork]] can mark images already in the library
|
|
||||||
|
|
||||||
## Serving URLs
|
## Serving URLs
|
||||||
|
|
||||||
@@ -97,10 +96,6 @@ See [[Media Utilities]] for how the frontend resolves which image to display:
|
|||||||
|
|
||||||
1. Local selected media → 2. TMDB fallback → 3. Default placeholder
|
1. Local selected media → 2. TMDB fallback → 3. Default placeholder
|
||||||
|
|
||||||
## Artwork
|
|
||||||
|
|
||||||
Entry pages list every TMDB poster, backdrop and logo merged with the media table, and can download any of them into it. See [[Artwork]].
|
|
||||||
|
|
||||||
## Maintenance
|
## Maintenance
|
||||||
|
|
||||||
See [[Settings Page#Cleanup]] for orphan file/record detection and removal.
|
See [[Settings Page#Cleanup]] for orphan file/record detection and removal.
|
||||||
|
|||||||
+5
-41
@@ -34,8 +34,8 @@ The core model — represents a movie or TV series.
|
|||||||
| `tagline` | STRING(200) | |
|
| `tagline` | STRING(200) | |
|
||||||
| `storyline` | STRING(3000) | |
|
| `storyline` | STRING(3000) | |
|
||||||
| `country` | STRING(30) | |
|
| `country` | STRING(30) | |
|
||||||
| `certification` | STRING(20) | e.g. `R`, `TV-14` (US first, then origin country) |
|
| `certification` | INTEGER | |
|
||||||
| `network_studio` | STRING(100) | First network, else first production company |
|
| `network_studio` | STRING(40) | |
|
||||||
| `collection_id` | INTEGER | TMDB collection ID |
|
| `collection_id` | INTEGER | TMDB collection ID |
|
||||||
| `max_cast` | INTEGER | Default `10` |
|
| `max_cast` | INTEGER | Default `10` |
|
||||||
| `credit_fetched` | BOOLEAN | Default `false` |
|
| `credit_fetched` | BOOLEAN | Default `false` |
|
||||||
@@ -51,28 +51,8 @@ The core model — represents a movie or TV series.
|
|||||||
| `banner_path` | STRING(200) | TMDB backdrop path |
|
| `banner_path` | STRING(200) | TMDB backdrop path |
|
||||||
| `date_first_seen` | DATEONLY | |
|
| `date_first_seen` | DATEONLY | |
|
||||||
| `date_last_seen` | DATEONLY | |
|
| `date_last_seen` | DATEONLY | |
|
||||||
| `last_fetch` | DATE | Last TMDB refresh (date + time); used by the [[API Reference#Stale Entries Refresh\|stale refresh]] |
|
| `last_fetch` | DATEONLY | Used by [[Services#Lazy Refresh\|lazy refresh]] |
|
||||||
| `entry_sync_status` | STRING(50) | Nullable. e.g. `"RequireCreditsSync"` |
|
| `entry_sync_status` | STRING(50) | Nullable. e.g. `"RequireCreditsSync"` |
|
||||||
| `adult` | BOOLEAN | |
|
|
||||||
| `tmdb_popularity` | FLOAT | |
|
|
||||||
| `original_language` | STRING(10) | |
|
|
||||||
| `origin_country` | JSON | `string[]` |
|
|
||||||
| `homepage` | STRING(500) | |
|
|
||||||
| `budget` / `revenue` | BIGINT | Movies only |
|
|
||||||
| `tv_type` | STRING(30) | TV only, e.g. `Scripted` |
|
|
||||||
| `number_of_seasons` / `number_of_episodes` | INTEGER | TV only |
|
|
||||||
| `last_air_date` | DATEONLY | TV only |
|
|
||||||
| `in_production` | BOOLEAN | TV only |
|
|
||||||
| `spoken_languages`, `production_countries`, `production_companies` | JSON | Detail page only* |
|
|
||||||
| `keywords` | JSON | `string[]`, up to 30* |
|
|
||||||
| `tmdb_videos` | JSON | YouTube trailers/teasers, up to 12* (not `videos`: that name is the Discovery Videos association) |
|
|
||||||
| `watch_providers` | JSON | Per-country stream/rent/buy providers* |
|
|
||||||
| `alternative_titles` | JSON | * |
|
|
||||||
| `created_by`, `next_episode_to_air`, `last_episode_to_air` | JSON | TV only* |
|
|
||||||
|
|
||||||
\* Listed in `Entry.DETAIL_ONLY_ATTRIBUTES` and excluded from the library list query (`GET /entries`) to keep it small.
|
|
||||||
|
|
||||||
All TMDB fields are filled by `mappers/entryMapper.js` — see [[TMDB Integration#Entry Mapper]].
|
|
||||||
|
|
||||||
**Has:** [[#EntryId]] (1:1), [[#EntryRating]] (1:1), [[#EntrySeen]] (1:N), [[#Season]] (1:N), [[#Credit]] (1:N), Genres (M:N), Networks (M:N), Collections (M:N), Media (polymorphic)
|
**Has:** [[#EntryId]] (1:1), [[#EntryRating]] (1:1), [[#EntrySeen]] (1:N), [[#Season]] (1:N), [[#Credit]] (1:N), Genres (M:N), Networks (M:N), Collections (M:N), Media (polymorphic)
|
||||||
|
|
||||||
@@ -87,7 +67,6 @@ All TMDB fields are filled by `mappers/entryMapper.js` — see [[TMDB Integratio
|
|||||||
| `id` | INTEGER PK AUTO | |
|
| `id` | INTEGER PK AUTO | |
|
||||||
| `tmdb_id` | STRING(30) | |
|
| `tmdb_id` | STRING(30) | |
|
||||||
| `imdb_id` | STRING(30) | |
|
| `imdb_id` | STRING(30) | |
|
||||||
| `tvdb_id` | STRING(30) | From the season's `external_ids` |
|
|
||||||
| `entry_id` | INTEGER FK | → Entry |
|
| `entry_id` | INTEGER FK | → Entry |
|
||||||
| `name` | STRING(500) | |
|
| `name` | STRING(500) | |
|
||||||
| `overview` | STRING(3000) | |
|
| `overview` | STRING(3000) | |
|
||||||
@@ -126,10 +105,6 @@ All TMDB fields are filled by `mappers/entryMapper.js` — see [[TMDB Integratio
|
|||||||
| `air_date` | DATE | |
|
| `air_date` | DATE | |
|
||||||
| `user_rating` | FLOAT | |
|
| `user_rating` | FLOAT | |
|
||||||
| `tmdb_rating` | FLOAT | |
|
| `tmdb_rating` | FLOAT | |
|
||||||
| `tmdb_vote_count` | INTEGER | |
|
|
||||||
| `production_code` | STRING(50) | |
|
|
||||||
| `crew` | JSON | Directors + writers (`{ id, name, job, department, profile_path }`) |
|
|
||||||
| `guest_stars` | JSON | Up to 25 (`{ id, name, character, profile_path, order }`) |
|
|
||||||
| `still_path` | STRING(200) | |
|
| `still_path` | STRING(200) | |
|
||||||
| `date_first_seen` | DATEONLY | |
|
| `date_first_seen` | DATEONLY | |
|
||||||
| `date_last_seen` | DATEONLY | |
|
| `date_last_seen` | DATEONLY | |
|
||||||
@@ -188,7 +163,6 @@ Polymorphic image record. See [[Media System]].
|
|||||||
| `mediaableId` | INTEGER | Polymorphic FK |
|
| `mediaableId` | INTEGER | Polymorphic FK |
|
||||||
| `type` | STRING(50) | `'poster'`, `'backdrop'`, `'logo'`, `'still'`, `'profile'` |
|
| `type` | STRING(50) | `'poster'`, `'backdrop'`, `'logo'`, `'still'`, `'profile'` |
|
||||||
| `path` | STRING(200) | UUID filename on disk |
|
| `path` | STRING(200) | UUID filename on disk |
|
||||||
| `tmdbPath` | STRING(200) | `tmdb_path` — TMDB `file_path` the image was downloaded from; null for custom uploads and images downloaded before it existed. Used by [[Artwork]] |
|
|
||||||
| `isLocal` | BOOLEAN | |
|
| `isLocal` | BOOLEAN | |
|
||||||
| `isSelected` | BOOLEAN | Default `false` — the "active" media |
|
| `isSelected` | BOOLEAN | Default `false` — the "active" media |
|
||||||
| `isCustom` | BOOLEAN | Default `false` — user-uploaded |
|
| `isCustom` | BOOLEAN | Default `false` — user-uploaded |
|
||||||
@@ -271,7 +245,6 @@ See [[People]].
|
|||||||
| `id` | INTEGER PK AUTO | |
|
| `id` | INTEGER PK AUTO | |
|
||||||
| `tmdb_id` | STRING(100) | |
|
| `tmdb_id` | STRING(100) | |
|
||||||
| `name` | STRING(100) | |
|
| `name` | STRING(100) | |
|
||||||
| `original_name` | STRING(200) | |
|
|
||||||
| `birthday` | DATEONLY | |
|
| `birthday` | DATEONLY | |
|
||||||
| `deathday` | DATEONLY | Nullable |
|
| `deathday` | DATEONLY | Nullable |
|
||||||
| `gender` | INTEGER | TMDB gender codes |
|
| `gender` | INTEGER | TMDB gender codes |
|
||||||
@@ -304,12 +277,6 @@ External ID storage (1:1 with Entry).
|
|||||||
| `tmdb_id` | STRING(30) |
|
| `tmdb_id` | STRING(30) |
|
||||||
| `imdb_id` | STRING(30) |
|
| `imdb_id` | STRING(30) |
|
||||||
| `tvdb_id` | STRING(30) |
|
| `tvdb_id` | STRING(30) |
|
||||||
| `wikidata_id` | STRING(30) |
|
|
||||||
| `facebook_id` | STRING(100) |
|
|
||||||
| `instagram_id` | STRING(100) |
|
|
||||||
| `twitter_id` | STRING(100) |
|
|
||||||
|
|
||||||
All filled from TMDB `external_ids` (TV series only have their IMDb id there).
|
|
||||||
|
|
||||||
**No timestamps.**
|
**No timestamps.**
|
||||||
|
|
||||||
@@ -327,7 +294,6 @@ Multi-source ratings (1:1 with Entry).
|
|||||||
| `entry_id` | INTEGER FK → Entry |
|
| `entry_id` | INTEGER FK → Entry |
|
||||||
| `user_rating` | FLOAT |
|
| `user_rating` | FLOAT |
|
||||||
| `tmdb_rating` | FLOAT |
|
| `tmdb_rating` | FLOAT |
|
||||||
| `tmdb_vote_count` | INTEGER |
|
|
||||||
| `imdb_rating` | FLOAT |
|
| `imdb_rating` | FLOAT |
|
||||||
| `rotten_tomatoes_rating` | FLOAT |
|
| `rotten_tomatoes_rating` | FLOAT |
|
||||||
|
|
||||||
@@ -358,7 +324,7 @@ Join table: Entry ↔ Network. Composite PK: `(network_id, entry_id)`. Has `orde
|
|||||||
| Field | Type | Notes |
|
| Field | Type | Notes |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `id` | INTEGER PK | TMDB genre ID (not auto-increment) |
|
| `id` | INTEGER PK | TMDB genre ID (not auto-increment) |
|
||||||
| `name` | STRING(100) | |
|
| `name` | STRING(30) | |
|
||||||
|
|
||||||
**No timestamps.** Seeded with 27 TMDB genres on startup.
|
**No timestamps.** Seeded with 27 TMDB genres on startup.
|
||||||
|
|
||||||
@@ -371,15 +337,13 @@ Join table: Entry ↔ Network. Composite PK: `(network_id, entry_id)`. Has `orde
|
|||||||
| Field | Type |
|
| Field | Type |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `id` | INTEGER PK (TMDB ID) |
|
| `id` | INTEGER PK (TMDB ID) |
|
||||||
| `name` | STRING(100) |
|
| `name` | STRING(30) |
|
||||||
| `originCountry` | STRING(100) |
|
| `originCountry` | STRING(100) |
|
||||||
| `homepage` | STRING(100) |
|
| `homepage` | STRING(100) |
|
||||||
| `logoPath` | STRING(200) |
|
| `logoPath` | STRING(200) |
|
||||||
| `posterPath` | STRING(200) |
|
| `posterPath` | STRING(200) |
|
||||||
| `backdropPath` | STRING(200) |
|
| `backdropPath` | STRING(200) |
|
||||||
|
|
||||||
`originCountry` and `logoPath` are filled from TMDB's `origin_country` / `logo_path` and refreshed with the entry.
|
|
||||||
|
|
||||||
**No timestamps.**
|
**No timestamps.**
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
+27
-36
@@ -30,10 +30,6 @@ Charts: `WatchActivityChart`, `WatchTimeChart`, `CouchDayChart`, `LibraryGrowthC
|
|||||||
|
|
||||||
Entry grid showing all non-watchlist, non-hidden entries from [[Stores|library store]]. See [[Library]].
|
Entry grid showing all non-watchlist, non-hidden entries from [[Stores|library store]]. See [[Library]].
|
||||||
|
|
||||||
- Type tabs: **All / Movies / TV**
|
|
||||||
- **Favorites** and **Hidden** are independent toggle buttons that combine with the type tab (e.g. TV + Favorites = favorite shows). Hidden mode shows only hidden entries (watchlist included).
|
|
||||||
- Filter state lives in `useLibraryFiltersStore` (`favoritesOnly`, `hiddenOnly`)
|
|
||||||
|
|
||||||
## DiscoverPage
|
## DiscoverPage
|
||||||
|
|
||||||
TMDB browse by category: popular, trending, top-rated, upcoming. Uses `useTmdb` infinite queries.
|
TMDB browse by category: popular, trending, top-rated, upcoming. Uses `useTmdb` infinite queries.
|
||||||
@@ -73,17 +69,16 @@ Monthly [[Calendar]] view showing upcoming episode air dates. Uses `episodesApi.
|
|||||||
|
|
||||||
## EntryDetailsPage
|
## EntryDetailsPage
|
||||||
|
|
||||||
One page for both cases (`pages/EntryDetailsPage.tsx`):
|
The main entry detail view. Width constrained to `max-w-4xl`.
|
||||||
|
|
||||||
- `/entry/:id` — a library entry, loaded from the local DB
|
Sections:
|
||||||
- `/entry/tmdb/:type/:tmdbId` — not in the library; renders the TMDB preview (`GET /entries/tmdb/preview/:type/:tmdbId` returns an `entry` object in the same shape as a library entry). Library-only actions are hidden and **Add to Library** replaces them. If the title is already in the library, the page redirects to `/entry/:id`.
|
|
||||||
|
|
||||||
Layout (`max-w-6xl`):
|
- Backdrop + poster + title + metadata
|
||||||
|
- Actions: watchlist, favorite, refresh, settings, rating
|
||||||
- **Hero** — full-bleed backdrop fading into the page, large poster (click → full-size popup), type/certification/status chips, title (selectable), tagline, year · runtime/seasons · "Created by" (TV) · "Directed by"
|
- Watch history (movies) → [[Watch Tracking]]
|
||||||
- **Action bar** — Watch (streaming), Trailer (in-app player from stored TMDB videos, YouTube search fallback), mark watched, rate, favorite, add to collection, ⋯ menu (watch history / status, hide, refresh, manage media, settings, delete)
|
- Seasons list (TV) → links to SeasonPage
|
||||||
- **Main column** — Overview, Keywords, Cast ([[Components#Entry Components|CastList]]), Seasons ([[Components#Entry Components|SeasonsContainer]] with list/cards toggle), In Collections, More like this (live TMDB recommendations), [[Artwork]]
|
- Cast list → links to PersonDetailsPage; shows episode count for TV; "All Cast & Crew" link → EntryCastsPage
|
||||||
- **Sidebar** — IMDb / TMDB (+ vote count) / your rating tiles, Details card (release, runtime, episodes, last aired, next episode, network logos, type, language, budget, box office, studio, country, watched), external links (TMDB, IMDb, website, Wikidata, Instagram, X, Facebook), **Where to watch** card (per-country providers, defaults to the browser's region)
|
- Media gallery → [[Media System]]
|
||||||
|
|
||||||
## EntryCastsPage
|
## EntryCastsPage
|
||||||
|
|
||||||
@@ -100,22 +95,26 @@ Full cast & crew grid for an entry. Route: `/entry/:id/cast`. Width: `max-w-4xl`
|
|||||||
|
|
||||||
## SeasonPage
|
## SeasonPage
|
||||||
|
|
||||||
Season detail (`max-w-6xl`), same visual language as the entry page.
|
Season detail with episode list. Width: `max-w-4xl`.
|
||||||
|
|
||||||
- **Hero** — show backdrop, season poster, "← Back to {show}" button, show and season chips, "Completed" badge, year · episodes · total runtime · air-date range
|
- Breadcrumb: `Title / Season x` (see [[Navigation]])
|
||||||
- Rating chip (opens SeasonRatingDialog), TMDB rating, progress bar
|
- Episode progress bar
|
||||||
- **Start / Continue: E#** — plays the first aired, unwatched episode
|
- **Mark Season Watched** button (always visible) → opens [[Components#Dialogs|MarkSeasonWatchedDialog]]
|
||||||
- Mark season watched → [[Components#Dialogs|MarkSeasonWatchedDialog]] (single date or scatter mode), rate, ⋯ (refresh season)
|
- **Single Date mode**: marks all unwatched episodes on one date
|
||||||
- **Episodes** with a **List / Cards** toggle (remembered per browser): stills (click to play), air date, runtime, TMDB rating, seen dates, finale / mid-season / upcoming badges, mark-watched button
|
- **Scatter Mode**: distributes episodes evenly across a date range (start → end)
|
||||||
|
- Episode list with watch status
|
||||||
|
- Links to EpisodePage
|
||||||
|
|
||||||
## EpisodePage
|
## EpisodePage
|
||||||
|
|
||||||
Episode detail (`max-w-6xl`).
|
Episode detail with watch history. Width: `max-w-4xl`.
|
||||||
|
|
||||||
- **Hero** — episode still as backdrop, show / season chips, `S##E##`, finale / upcoming / watched badges, title, air date · runtime · TMDB rating + votes
|
- Breadcrumb: `Title / Season x / Episode x` (see [[Navigation]])
|
||||||
- Actions: **Watch episode**, **Mark as watched / Watch again**, previous / next episode
|
- Episode thumbnail (TMDB still)
|
||||||
- Main column: overview with "Directed by" / "Written by" (stored episode crew), Guest Stars (stored, linked by TMDB id), watch history (edit / delete), previous / next cards
|
- `S##E##` display using `season.season_number` (not DB id)
|
||||||
- Sidebar: details card (aired, runtime, TMDB, production code, watched) and the season's episode list with the current one highlighted
|
- Prev/next episode navigation
|
||||||
|
- Watch history management
|
||||||
|
- Cast list
|
||||||
|
|
||||||
## PeoplePage
|
## PeoplePage
|
||||||
|
|
||||||
@@ -123,23 +122,15 @@ Browse and search people (actors, directors). Both local DB and TMDB search.
|
|||||||
|
|
||||||
## PersonDetailsPage
|
## PersonDetailsPage
|
||||||
|
|
||||||
One page for both cases (`pages/PersonDetailsPage.tsx`):
|
Person profile with biography, filmography. Uses lazy-fetch via [[Services#PeopleManager]].
|
||||||
|
|
||||||
- `/people/:id` — person in the local DB (favorite toggle; filmography from TMDB via the local id)
|
## PersonTmdbRedirectPage
|
||||||
- `/people/tmdb/:tmdbId` — not in the DB; everything from the TMDB preview, with **Add to Library**. If TMDB reports a local id, redirects to `/people/:id`.
|
|
||||||
|
|
||||||
Both render one header (photo, name, department, born / died with age tooltip, place of birth, TMDB link, biography) and one filmography split into **In your library** and **Not in library**.
|
Takes a TMDB person ID, fetches/creates the local person record, redirects to `PersonDetailsPage`.
|
||||||
|
|
||||||
## HistoryPage
|
|
||||||
|
|
||||||
Watch history at `/history`. See [[History]].
|
|
||||||
|
|
||||||
- Year picker (only years with watches) and All / Movies / TV filter; tab, year and filter live in the URL (`?tab=&year=&type=`)
|
|
||||||
- Tabs: **History** (by month and day), **Timeline** (latest → January, month dividers, stacked binge sessions), **Year in Review** (wrapped-style stats)
|
|
||||||
|
|
||||||
## SettingsPage
|
## SettingsPage
|
||||||
|
|
||||||
App configuration + maintenance. See [[Settings Page]].
|
App configuration + maintenance. See [[Settings Page]].
|
||||||
|
|
||||||
- General settings (TMDB API key, backend port)
|
- General settings (TMDB API key, backend port)
|
||||||
- Maintenance: **TMDB Refresh** (stale entries job), media cleanup, watch statuses, duplicate credits, missing directors, impossible seen dates
|
- Cleanup section (orphan files, orphan media records)
|
||||||
@@ -24,23 +24,17 @@ Every page uses `React.lazy()` with a custom `<Suspense>` skeleton fallback.
|
|||||||
| `/library` | `LibraryPage` | `LibrarySkeleton` | [[Library]] grid/list |
|
| `/library` | `LibraryPage` | `LibrarySkeleton` | [[Library]] grid/list |
|
||||||
| `/discover/:category` | `DiscoverPage` | `HomeSkeleton` | TMDB browse (popular, trending, top-rated, upcoming) |
|
| `/discover/:category` | `DiscoverPage` | `HomeSkeleton` | TMDB browse (popular, trending, top-rated, upcoming) |
|
||||||
| `/watchlist` | `WatchlistPage` | `WatchlistSkeleton` | Watchlist entries |
|
| `/watchlist` | `WatchlistPage` | `WatchlistSkeleton` | Watchlist entries |
|
||||||
| `/history` | `HistoryPage` | `WatchlistSkeleton` | [[History]] — list, timeline, year in review |
|
|
||||||
| `/collections` | `CollectionsPage` | `CollectionsSkeleton` | [[Collections]] overview |
|
| `/collections` | `CollectionsPage` | `CollectionsSkeleton` | [[Collections]] overview |
|
||||||
| `/collections/:id` | `CollectionDetailsPage` | `CollectionDetailsSkeleton` | Collection with entries |
|
| `/collections/:id` | `CollectionDetailsPage` | `CollectionDetailsSkeleton` | Collection with entries |
|
||||||
| `/media` | `MediaPage` | `MediaSkeleton` | Media management |
|
| `/media` | `MediaPage` | `MediaSkeleton` | Media management |
|
||||||
| `/discovery-videos` | `DiscoveryVideosPage` | `DiscoveryVideosSkeleton` | Personal video vault — see [[Discovery Videos]] |
|
| `/discovery-videos` | `DiscoveryVideosPage` | `DiscoveryVideosSkeleton` | Personal video vault — see [[Discovery Videos]] |
|
||||||
| `/calendar` | `CalendarPage` | `CalendarSkeleton` | [[Calendar]] upcoming episodes |
|
| `/calendar` | `CalendarPage` | `CalendarSkeleton` | [[Calendar]] upcoming episodes |
|
||||||
| `/entry/tmdb/:type/:tmdbId` | `EntryDetailsPage` | `EntryDetailsSkeleton` | Entry not in the library (TMDB preview, same page) |
|
|
||||||
| `/entry/tmdb/:type/:tmdbId/cast` | `TmdbCastsPage` | `PeopleSkeleton` | Full cast of a TMDB-only entry |
|
|
||||||
| `/entry/:id` | `EntryDetailsPage` | `EntryDetailsSkeleton` | Entry details, seasons, cast |
|
| `/entry/:id` | `EntryDetailsPage` | `EntryDetailsSkeleton` | Entry details, seasons, cast |
|
||||||
| `/entry/:id/cast` | `EntryCastsPage` | `EntryDetailsSkeleton` | Full cast & crew |
|
|
||||||
| `/entry/:entryId/season/:seasonId` | `SeasonPage` | `SeasonSkeleton` | Season episodes |
|
| `/entry/:entryId/season/:seasonId` | `SeasonPage` | `SeasonSkeleton` | Season episodes |
|
||||||
| `/entry/:entryId/season/:seasonId/episode/:episodeId` | `EpisodePage` | `EpisodeSkeleton` | Episode details |
|
| `/entry/:entryId/season/:seasonId/episode/:episodeId` | `EpisodePage` | `EpisodeSkeleton` | Episode details |
|
||||||
| `/people` | `PeoplePage` | `PeopleSkeleton` | [[People]] browse |
|
| `/people` | `PeoplePage` | `PeopleSkeleton` | [[People]] browse |
|
||||||
| `/people/:id` | `PersonDetailsPage` | `PersonDetailsSkeleton` | Person profile + filmography |
|
| `/people/:id` | `PersonDetailsPage` | `PersonDetailsSkeleton` | Person profile + filmography |
|
||||||
| `/people/tmdb/:tmdbId` | `PersonDetailsPage` | `PersonDetailsSkeleton` | Person not in the DB (TMDB data, same page) |
|
| `/people/tmdb/:tmdbId` | `PersonTmdbRedirectPage` | `PersonDetailsSkeleton` | TMDB person → local redirect |
|
||||||
| `/watch-buddies` | `WatchBuddiesPage` | `PeopleSkeleton` | Watch buddies |
|
|
||||||
| `/watch-buddies/:id` | `WatchBuddyProfilePage` | `PeopleSkeleton` | Buddy profile |
|
|
||||||
| `/settings` | `SettingsPage` | `SettingsSkeleton` | [[Settings Page]] |
|
| `/settings` | `SettingsPage` | `SettingsSkeleton` | [[Settings Page]] |
|
||||||
|
|
||||||
## Layout
|
## Layout
|
||||||
|
|||||||
+6
-26
@@ -172,9 +172,9 @@ CRUD for [[Collections]]. Handles `UserCollectionEntry` join records.
|
|||||||
|
|
||||||
See [[TMDB Integration]].
|
See [[TMDB Integration]].
|
||||||
|
|
||||||
Every request goes through `tmdbGet(path, params)` — a rate-limited queue (20 req/s, 8 concurrent) with retries on 429 / 5xx / network errors. The API key is never logged.
|
14 methods wrapping TMDB API v3 calls:
|
||||||
|
|
||||||
Methods: `fetchEntryData` (details + appended blocks), `fetchSeasonData`, `fetchEntryMedia`, `fetchEntryRecommendations`, `fetchCollectionData`, `fetchEntryCredits`, `fetchPersonDetails`, `fetchPersonCombinedCredits`, `fetchTrending`, `fetchPopular`, `fetchTopRated`, `fetchUpcoming`, `searchMulti`, `searchPeople`, `fetchPopularPeople`
|
`fetchEntryData`, `fetchSeasonData`, `fetchEntryMedia`, `fetchCollectionData`, `fetchEntryCredits`, `fetchPersonDetails`, `fetchPersonCombinedCredits`, `fetchTrending`, `fetchPopular`, `fetchTopRated`, `fetchUpcoming`, `searchMulti`, `searchPeople`, `fetchPopularPeople`
|
||||||
|
|
||||||
### configService
|
### configService
|
||||||
|
|
||||||
@@ -218,31 +218,11 @@ See [[Import System]].
|
|||||||
|
|
||||||
> [!info] File: `backend/services/maintenanceService.js`
|
> [!info] File: `backend/services/maintenanceService.js`
|
||||||
|
|
||||||
See [[Settings Page]].
|
See [[Settings Page#Cleanup]].
|
||||||
|
|
||||||
- `deleteOrphanFiles(dry)` / `deleteOrphanMediaRecords(dry)` — return `{ posters, logos, backdrops, stills }` counts
|
- `deleteOrphanFiles(dry)` — Files on disk without DB records
|
||||||
- `deleteOrphanPeople`, `fixMissingDirectors`, `cleanDuplicateCredits`, `autoFixWatchStatuses`, `fixImpossibleSeenDates`
|
- `deleteOrphanMediaRecords(dry)` — DB records without files on disk
|
||||||
- `getStaleEntries(hours)` — entries never fetched or fetched more than `hours` ago (auto sync on)
|
- Both return `{ posters, logos, backdrops, stills }` counts
|
||||||
- `startStaleRefresh(hours)` / `getStaleRefreshStatus()` / `cancelStaleRefresh()` — background job that refreshes stale entries one at a time via `entryManager.refrechEntryById`
|
|
||||||
|
|
||||||
### artworkService
|
|
||||||
|
|
||||||
> [!info] File: `backend/services/artworkService.js`
|
|
||||||
|
|
||||||
See [[Artwork]].
|
|
||||||
|
|
||||||
- `getEntryArtwork(entryId)` — TMDB images merged with the entry's media rows (`in_library`, `media_id`, `is_selected`)
|
|
||||||
- `getTmdbArtwork(type, tmdbId)` — TMDB images only
|
|
||||||
- `addEntryArtwork(entryId, { type, file_path })` — downloads the original into the media table (deduplicated by `tmdbPath`; selected if none of that type is)
|
|
||||||
|
|
||||||
### historyService
|
|
||||||
|
|
||||||
> [!info] File: `backend/services/historyService.js`
|
|
||||||
|
|
||||||
See [[History]].
|
|
||||||
|
|
||||||
- `getYears()` — years with watches and their movie/episode counts
|
|
||||||
- `getYear(year)` — every watch in a year with entries listed once
|
|
||||||
|
|
||||||
### logService
|
### logService
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ tags:
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
App configuration and maintenance tools at `/settings`, in two tabs: **General** and **Maintenance**.
|
App configuration and maintenance tools at `/settings`. Contains two card sections.
|
||||||
|
|
||||||
## General Settings
|
## General Settings
|
||||||
|
|
||||||
@@ -23,15 +23,6 @@ Form using react-hook-form + zod validation.
|
|||||||
|
|
||||||
Saved via `PUT /api/v1/settings`.
|
Saved via `PUT /api/v1/settings`.
|
||||||
|
|
||||||
## TMDB Refresh
|
|
||||||
|
|
||||||
First card on the Maintenance tab. Refreshes entries whose `last_fetch` is older than N hours (default 24) — details, ids, ratings, genres, networks, seasons, episodes and credits.
|
|
||||||
|
|
||||||
- Shows how many entries are due; **Refresh stale entries** starts a background job, **Cancel** stops it
|
|
||||||
- Live progress (polled every 2s while running): done/total, ok, failed, current title; failures listed when finished
|
|
||||||
- Rate limited, so a large library takes a while; entries with auto sync off are skipped
|
|
||||||
- Endpoints: [[API Reference#Stale Entries Refresh]]
|
|
||||||
|
|
||||||
## Cleanup
|
## Cleanup
|
||||||
|
|
||||||
Maintenance tools for cleaning up orphaned data. Uses backend maintenance endpoints.
|
Maintenance tools for cleaning up orphaned data. Uses backend maintenance endpoints.
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ useStreamingStore (Zustand)
|
|||||||
|
|
||||||
## Data Flow
|
## Data Flow
|
||||||
|
|
||||||
1. User clicks "Watch Now" / "Continue Watching" on [[Pages#EntryDetailsPage|EntryDetailsPage]]
|
1. User clicks "Watch Now" / "Continue Watching" on [[Entry Details Page|EntryDetailsPage]]
|
||||||
2. `StreamingSection` determines the request (movie or TV + season/episode)
|
2. `StreamingSection` determines the request (movie or TV + season/episode)
|
||||||
3. `useStreamingStore.play()` builds a URL via the active server's provider adapter
|
3. `useStreamingStore.play()` builds a URL via the active server's provider adapter
|
||||||
4. `StreamingPlayer` renders an iframe with the embed URL
|
4. `StreamingPlayer` renders an iframe with the embed URL
|
||||||
|
|||||||
@@ -10,47 +10,33 @@ tags:
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Showy uses **TMDB API v3** as its source for movie, TV and people metadata. All TMDB calls go through the backend — the frontend never talks to TMDB directly, so the API key stays server-side.
|
Showy uses **TMDB API v3** as its primary source for movie and TV metadata. All TMDB calls are proxied through the backend — the frontend never contacts TMDB directly.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
- API base URL: `settings.json` → `tmdbApiUrl` (e.g. `https://api.themoviedb.org/3/`)
|
- API base URL: `https://api.themoviedb.org/3`
|
||||||
- API key: `settings.json` → `tmdbApiKey`
|
- API key stored in `settings.json` → `tmdbApiKey`
|
||||||
- Read by `configService`
|
- Managed by `configService`
|
||||||
|
|
||||||
## Rate Limiting
|
|
||||||
|
|
||||||
> [!info] File: `backend/services/tmdbService.js` → `tmdbGet(path, params)`
|
|
||||||
|
|
||||||
Every TMDB request goes through one queue so bulk jobs (like the [[API Reference#Stale Entries Refresh|stale entries refresh]]) never get the IP blocked:
|
|
||||||
|
|
||||||
- **20 requests per second**, **8 in flight** at once (TMDB allows ~50/s)
|
|
||||||
- **429** → waits for `Retry-After`, then retries; **5xx / network errors** → exponential backoff
|
|
||||||
- Up to 4 attempts per request
|
|
||||||
- Requests are logged as `TMDB GET <path>?<params>` **without** the API key
|
|
||||||
|
|
||||||
Measured: 45 requests went out at 20 / 20 / 5 per second, all succeeded.
|
|
||||||
|
|
||||||
The legacy [[Import System]] keeps its own extra throttle (35 requests per 10 s) on top.
|
|
||||||
|
|
||||||
## tmdbService
|
## tmdbService
|
||||||
|
|
||||||
|
> [!info] File: `backend/services/tmdbService.js`
|
||||||
|
|
||||||
### Entry Data
|
### Entry Data
|
||||||
|
|
||||||
| Method | TMDB Endpoint | Notes |
|
| Method | TMDB Endpoint | Returns |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `fetchEntryData(tmdbId, isTV)` | `/movie/{id}` or `/tv/{id}` | Appends `external_ids`, `release_dates` (movie) / `content_ratings` (TV), `keywords`, `videos`, `watch/providers`, `alternative_titles` in the same request |
|
| `fetchEntryData(tmdbId, isTV)` | `/movie/{id}` or `/tv/{id}` | Full entry metadata |
|
||||||
| `fetchSeasonData(tmdbId, seasonNum)` | `/tv/{id}/season/{num}` | Appends `external_ids`; episodes include `crew` and `guest_stars` |
|
| `fetchSeasonData(tmdbId, seasonNum)` | `/tv/{id}/season/{num}` | Season with episodes |
|
||||||
| `fetchEntryMedia(tmdbId, isTV)` | `/{type}/{id}/images` | All languages (no `language` param) |
|
| `fetchEntryMedia(tmdbId, isTV)` | `/movie/{id}/images` or `/tv/{id}/images` | Posters, backdrops, logos |
|
||||||
| `fetchEntryCredits(tmdbId, isTV)` | `/movie/{id}/credits` or `/tv/{id}/aggregate_credits` | |
|
| `fetchEntryCredits(tmdbId, isTV)` | `/movie/{id}/credits` or `/tv/{id}/credits` | Cast and crew |
|
||||||
| `fetchEntryRecommendations(tmdbId, isTV, page)` | `/{type}/{id}/recommendations` | Live, never stored |
|
| `fetchCollectionData(collectionId)` | `/collection/{id}` | Collection with parts |
|
||||||
| `fetchCollectionData(collectionId)` | `/collection/{id}` | |
|
|
||||||
|
|
||||||
### Person Data
|
### Person Data
|
||||||
|
|
||||||
| Method | TMDB Endpoint |
|
| Method | TMDB Endpoint |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `fetchPersonDetails(tmdbId)` | `/person/{id}` (+ `external_ids`) |
|
| `fetchPersonDetails(tmdbId)` | `/person/{id}` |
|
||||||
| `fetchPersonCombinedCredits(tmdbId)` | `/person/{id}/combined_credits` |
|
| `fetchPersonCombinedCredits(tmdbId)` | `/person/{id}/combined_credits` |
|
||||||
|
|
||||||
### Browse & Search
|
### Browse & Search
|
||||||
@@ -65,53 +51,41 @@ The legacy [[Import System]] keeps its own extra throttle (35 requests per 10 s)
|
|||||||
| `searchPeople(query)` | `/search/person` |
|
| `searchPeople(query)` | `/search/person` |
|
||||||
| `fetchPopularPeople()` | `/person/popular` |
|
| `fetchPopularPeople()` | `/person/popular` |
|
||||||
|
|
||||||
All methods return `null` on failure (after retries) and log the error.
|
|
||||||
|
|
||||||
## Entry Mapper
|
|
||||||
|
|
||||||
> [!info] File: `backend/mappers/entryMapper.js`
|
|
||||||
|
|
||||||
One place that turns TMDB responses into column values. Used by entry creation (`entryService.createEntry`), the refresh (`entryManager.refrechEntryById`), the season refresh (`seasonController.refreshSeason`), the legacy importer (`models-services/entryService.saveEntry`) and the TMDB preview endpoint.
|
|
||||||
|
|
||||||
| Function | Fills |
|
|
||||||
|---|---|
|
|
||||||
| `mapEntryFields(data)` | Entry columns — title, dates, runtime (TV falls back to `episode_run_time` then the last episode's runtime), certification (US → GB → origin country; theatrical first for movies), network/studio, budget/revenue, languages, countries, companies, homepage, keywords, trimmed videos and watch providers, alternative titles, TV type/creators/season & episode counts/last air date/next & last episode |
|
|
||||||
| `mapEntryIds(data)` | IMDb (from `external_ids` for TV), TVDB, Wikidata, Facebook, Instagram, X |
|
|
||||||
| `mapEntryRatings(data)` | `tmdb_rating`, `tmdb_vote_count` |
|
|
||||||
| `mapSeasonFields(seasonData)` | Season columns incl. `tvdb_id` |
|
|
||||||
| `mapEpisodeFields(episode)` | Episode columns incl. vote count, production code, directors/writers, guest stars |
|
|
||||||
|
|
||||||
See [[Models#Entry]] for every stored field.
|
|
||||||
|
|
||||||
## Refresh
|
|
||||||
|
|
||||||
`PUT /entries/:id/refresh` (and the stale job) re-fetches and updates:
|
|
||||||
|
|
||||||
- Entry, ids and ratings via the mapper
|
|
||||||
- Genres and networks — **synced both ways** (added and removed); network name, country and logo refreshed
|
|
||||||
- Seasons and episodes (matched by TMDB id)
|
|
||||||
- Credits and people
|
|
||||||
|
|
||||||
### Stale Entries Refresh
|
|
||||||
|
|
||||||
`POST /maintenance/stale-entries/refresh?hours=24` refreshes, one at a time, every entry whose `last_fetch` is older than `hours` (or never set), skipping entries with auto sync off. Progress is available from `GET /maintenance/stale-entries`; the UI is the TMDB Refresh card in [[Settings Page#TMDB Refresh]].
|
|
||||||
|
|
||||||
## Frontend TMDB Proxy
|
## Frontend TMDB Proxy
|
||||||
|
|
||||||
|
The frontend accesses TMDB data through backend proxy endpoints (see [[API Reference#TMDB Proxy]]):
|
||||||
|
|
||||||
```
|
```
|
||||||
Frontend → /api/v1/entries/tmdb/trending/movie → Backend → TMDB API → Response
|
Frontend → /api/v1/entries/tmdb/trending/movie → Backend → TMDB API → Response
|
||||||
```
|
```
|
||||||
|
|
||||||
See [[API Reference#TMDB Proxy]]. The preview endpoint (`/entries/tmdb/preview/:type/:tmdbId`) returns an `entry` object in the same shape as a library entry, so [[Pages#EntryDetailsPage|EntryDetailsPage]] renders titles that aren't in the library.
|
This keeps the API key server-side.
|
||||||
|
|
||||||
## Image URLs
|
## Image URLs
|
||||||
|
|
||||||
TMDB image base URL: `https://image.tmdb.org/t/p/`
|
TMDB image base URL: `https://image.tmdb.org/t/p/`
|
||||||
|
|
||||||
- Posters: `w185`, `w342`, `w500`
|
Common sizes used:
|
||||||
- Backdrops: `w780`, `w1280`, `original`
|
|
||||||
- Stills: `w300`, `w780`, `original`
|
|
||||||
- Profiles: `w185`, `w300`
|
|
||||||
- Logos / providers: `w92`, `w500`
|
|
||||||
|
|
||||||
See [[Media Utilities]] for frontend URL resolution, [[Media System]] for local caching and [[Artwork]] for browsing and adding TMDB images.
|
- Posters: `w342`, `w500`, `w780`
|
||||||
|
- Backdrops: `w780`, `w1280`
|
||||||
|
- Stills: `w300`, `w1280`
|
||||||
|
- Profiles: `w185`
|
||||||
|
|
||||||
|
See [[Media Utilities]] for frontend URL resolution and [[Media System]] for local image caching.
|
||||||
|
|
||||||
|
## Lazy Refresh Pattern
|
||||||
|
|
||||||
|
Used by [[Services#EntryManager]] and [[Services#PeopleManager]]:
|
||||||
|
|
||||||
|
1. Check `last_fetch` or `fully_fetched` field
|
||||||
|
2. If stale (>24h) or never fetched → call TMDB
|
||||||
|
3. Update local data + set `last_fetch` to today
|
||||||
|
4. TV series with `status = "Ended"` skip refresh
|
||||||
|
|
||||||
|
## Rate Limiting
|
||||||
|
|
||||||
|
The [[Import System]] self-throttles to stay under TMDB limits:
|
||||||
|
|
||||||
|
- Max 35 requests per 10 seconds
|
||||||
|
- 500ms delay between individual requests
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
|
"dev:tauri": "cross-env VITE_TAURI=true vite",
|
||||||
|
"build:tauri": "cross-env VITE_TAURI=true vite build --outDir ../tauri/frontend_build --emptyOutDir",
|
||||||
"build:electron": "cross-env VITE_ELECTRON=true vite build --outDir ../electron/frontend_build",
|
"build:electron": "cross-env VITE_ELECTRON=true vite build --outDir ../electron/frontend_build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
@@ -15,6 +17,7 @@
|
|||||||
"@fontsource-variable/geist": "^5.2.8",
|
"@fontsource-variable/geist": "^5.2.8",
|
||||||
"@hookform/resolvers": "^5.2.2",
|
"@hookform/resolvers": "^5.2.2",
|
||||||
"@tanstack/react-query": "^5.95.2",
|
"@tanstack/react-query": "^5.95.2",
|
||||||
|
"@tauri-apps/api": "^2.12.4",
|
||||||
"axios": "^1.14.0",
|
"axios": "^1.14.0",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
|||||||
Generated
+8
@@ -51,6 +51,9 @@ importers:
|
|||||||
'@tanstack/react-query':
|
'@tanstack/react-query':
|
||||||
specifier: ^5.95.2
|
specifier: ^5.95.2
|
||||||
version: 5.100.8(react@19.2.5)
|
version: 5.100.8(react@19.2.5)
|
||||||
|
'@tauri-apps/api':
|
||||||
|
specifier: ^2.12.4
|
||||||
|
version: 2.12.4
|
||||||
axios:
|
axios:
|
||||||
specifier: ^1.20.0
|
specifier: ^1.20.0
|
||||||
version: 1.21.0(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0)
|
version: 1.21.0(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0)
|
||||||
@@ -798,6 +801,9 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ^18 || ^19
|
react: ^18 || ^19
|
||||||
|
|
||||||
|
'@tauri-apps/api@2.12.4':
|
||||||
|
resolution: {integrity: sha512-pVmfis+4zT8H0Qhp3xPZx9Ju7kpzvA6rr/PSJPyuwfvucTQ8sVt61NYU9KMkK703UFlYadFmjKA4HhybOtN0gg==}
|
||||||
|
|
||||||
'@ts-morph/common@0.27.0':
|
'@ts-morph/common@0.27.0':
|
||||||
resolution: {integrity: sha512-Wf29UqxWDpc+i61k3oIOzcUfQt79PIT9y/MWfAGlrkjg6lBC1hwDECLXPVJAhWjiGbfBCxZd65F/LIZF3+jeJQ==}
|
resolution: {integrity: sha512-Wf29UqxWDpc+i61k3oIOzcUfQt79PIT9y/MWfAGlrkjg6lBC1hwDECLXPVJAhWjiGbfBCxZd65F/LIZF3+jeJQ==}
|
||||||
|
|
||||||
@@ -3435,6 +3441,8 @@ snapshots:
|
|||||||
'@tanstack/query-core': 5.100.8
|
'@tanstack/query-core': 5.100.8
|
||||||
react: 19.2.5
|
react: 19.2.5
|
||||||
|
|
||||||
|
'@tauri-apps/api@2.12.4': {}
|
||||||
|
|
||||||
'@ts-morph/common@0.27.0':
|
'@ts-morph/common@0.27.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
fast-glob: 3.3.3
|
fast-glob: 3.3.3
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { api } from "@/lib/api";
|
import { api } from "@/lib/api";
|
||||||
import { normalizeEntry, normalizeCredit } from "@/lib/normalizers";
|
import { normalizeEntry, normalizeCredit } from "@/lib/normalizers";
|
||||||
import type { StaleRefreshJob } from "@/api/maintenance";
|
|
||||||
import type {
|
import type {
|
||||||
Entry,
|
Entry,
|
||||||
Credit,
|
Credit,
|
||||||
@@ -91,14 +90,7 @@ export const entriesApi = {
|
|||||||
addArtwork: (id: number, data: { type: ArtworkType; file_path: string }) =>
|
addArtwork: (id: number, data: { type: ArtworkType; file_path: string }) =>
|
||||||
api.post<Media>(`/entries/${id}/artwork`, data).then((r) => r.data),
|
api.post<Media>(`/entries/${id}/artwork`, data).then((r) => r.data),
|
||||||
|
|
||||||
/** Starts the background refresh of airing TV series older than 24h. */
|
syncSeries: () => api.get("/entries/sync-series").then((r) => r.data),
|
||||||
syncSeries: () =>
|
|
||||||
api.post<StaleRefreshJob>("/entries/sync-series").then((r) => r.data),
|
|
||||||
|
|
||||||
syncSeriesStatus: () =>
|
|
||||||
api
|
|
||||||
.get<StaleRefreshJob>("/entries/sync-series/status")
|
|
||||||
.then((r) => r.data),
|
|
||||||
|
|
||||||
previewTmdb: (tmdbId: number, type: "movie" | "tv") =>
|
previewTmdb: (tmdbId: number, type: "movie" | "tv") =>
|
||||||
api
|
api
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ export interface OrphanPeopleResult {
|
|||||||
|
|
||||||
export interface StaleRefreshJob {
|
export interface StaleRefreshJob {
|
||||||
running: boolean;
|
running: boolean;
|
||||||
/** "series" = calendar sync of airing TV series, "all" = maintenance refresh */
|
|
||||||
scope?: "series" | "all";
|
|
||||||
hours?: number;
|
hours?: number;
|
||||||
total?: number;
|
total?: number;
|
||||||
done?: number;
|
done?: number;
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import { Sidebar, MobileSidebarContent } from "./Sidebar";
|
|||||||
import { TitleBar } from "./TitleBar";
|
import { TitleBar } from "./TitleBar";
|
||||||
import { CommandPalette } from "@/components/CommandPalette";
|
import { CommandPalette } from "@/components/CommandPalette";
|
||||||
import { useCommandPaletteStore } from "@/stores/useCommandPaletteStore";
|
import { useCommandPaletteStore } from "@/stores/useCommandPaletteStore";
|
||||||
|
import { isDesktop } from "@/lib/platform";
|
||||||
const isElectron =
|
|
||||||
import.meta.env.VITE_ELECTRON === "true" || !!window.electron?.isElectron;
|
|
||||||
|
|
||||||
export function AppLayout() {
|
export function AppLayout() {
|
||||||
const [mobileOpen, setMobileOpen] = useState(false);
|
const [mobileOpen, setMobileOpen] = useState(false);
|
||||||
@@ -62,7 +60,7 @@ export function AppLayout() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen flex-col overflow-hidden">
|
<div className="flex h-screen flex-col overflow-hidden">
|
||||||
{isElectron && <TitleBar />}
|
{isDesktop && <TitleBar />}
|
||||||
<CommandPalette />
|
<CommandPalette />
|
||||||
|
|
||||||
<div className="flex flex-1 overflow-hidden">
|
<div className="flex flex-1 overflow-hidden">
|
||||||
|
|||||||
@@ -1,17 +1,36 @@
|
|||||||
import { Minus, Square, X } from "lucide-react";
|
import { Minus, Square, X } from "lucide-react";
|
||||||
|
import { isTauri } from "@/lib/platform";
|
||||||
|
|
||||||
|
// Loaded only inside the Tauri shell so web and Electron bundles don't pull it in eagerly.
|
||||||
|
const tauriWindow = async () => {
|
||||||
|
const { getCurrentWindow } = await import("@tauri-apps/api/window");
|
||||||
|
return getCurrentWindow();
|
||||||
|
};
|
||||||
|
|
||||||
|
const minimize = () =>
|
||||||
|
isTauri
|
||||||
|
? void tauriWindow().then((w) => w.minimize())
|
||||||
|
: window.electron?.windowControls.minimize();
|
||||||
|
const maximize = () =>
|
||||||
|
isTauri
|
||||||
|
? void tauriWindow().then((w) => w.toggleMaximize())
|
||||||
|
: window.electron?.windowControls.maximize();
|
||||||
|
const close = () =>
|
||||||
|
isTauri
|
||||||
|
? void tauriWindow().then((w) => w.close())
|
||||||
|
: window.electron?.windowControls.close();
|
||||||
|
|
||||||
export function TitleBar() {
|
export function TitleBar() {
|
||||||
const minimize = () => window.electron?.windowControls.minimize();
|
|
||||||
const maximize = () => window.electron?.windowControls.maximize();
|
|
||||||
const close = () => window.electron?.windowControls.close();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
// Electron drags via -webkit-app-region; Tauri via data-tauri-drag-region,
|
||||||
|
// which only applies to the element that carries it (not its children).
|
||||||
<div
|
<div
|
||||||
|
data-tauri-drag-region
|
||||||
className="flex h-14 select-none items-center justify-between border-b border-border bg-background"
|
className="flex h-14 select-none items-center justify-between border-b border-border bg-background"
|
||||||
style={{ WebkitAppRegion: "drag" } as React.CSSProperties}
|
style={{ WebkitAppRegion: "drag" } as React.CSSProperties}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2 pl-3">
|
<div data-tauri-drag-region className="flex h-full flex-1 items-center gap-2 pl-3">
|
||||||
<span className="text-xs font-semibold tracking-wide text-foreground/80">
|
<span className="pointer-events-none text-xs font-semibold tracking-wide text-foreground/80">
|
||||||
SHOWY
|
SHOWY
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
import { useEffect, useRef } from "react";
|
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { entriesApi } from "@/api/entries";
|
|
||||||
import { entryKeys } from "@/hooks/useEntries";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Refreshes airing TV series when the calendar is opened. The backend only
|
|
||||||
* picks series not refreshed in the last 24h (a manual refresh resets that),
|
|
||||||
* so most visits start nothing. While a sync runs its status is polled, and
|
|
||||||
* calendar episodes + the library are reloaded when it finishes.
|
|
||||||
*/
|
|
||||||
export function useSeriesSync() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const start = useMutation({ mutationFn: entriesApi.syncSeries });
|
|
||||||
const startedRef = useRef(false);
|
|
||||||
|
|
||||||
// Kick off once per visit (StrictMode's second call just sees it running)
|
|
||||||
useEffect(() => {
|
|
||||||
if (startedRef.current) return;
|
|
||||||
startedRef.current = true;
|
|
||||||
start.mutate();
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const startedJob = start.data;
|
|
||||||
const status = useQuery({
|
|
||||||
queryKey: ["entries", "sync-series", "status"],
|
|
||||||
queryFn: entriesApi.syncSeriesStatus,
|
|
||||||
enabled: !!startedJob?.running,
|
|
||||||
refetchInterval: (query) =>
|
|
||||||
query.state.data?.running === false ? false : 2500,
|
|
||||||
});
|
|
||||||
|
|
||||||
const job = status.data ?? startedJob;
|
|
||||||
const running = !!job?.running;
|
|
||||||
|
|
||||||
// Reload calendar data once the sync that was running finishes
|
|
||||||
const wasRunning = useRef(false);
|
|
||||||
useEffect(() => {
|
|
||||||
if (wasRunning.current && !running) {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["episodes"] });
|
|
||||||
queryClient.invalidateQueries({ queryKey: entryKeys.all, exact: true });
|
|
||||||
}
|
|
||||||
wasRunning.current = running;
|
|
||||||
}, [running, queryClient]);
|
|
||||||
|
|
||||||
return { job, running };
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useAuthStore } from '@/stores/useAuthStore';
|
import { useAuthStore } from '@/stores/useAuthStore';
|
||||||
|
import { isDesktopBuild } from '@/lib/platform';
|
||||||
|
|
||||||
const API_BASE_URL =
|
const API_BASE_URL =
|
||||||
import.meta.env.VITE_ELECTRON === 'true'
|
isDesktopBuild
|
||||||
? 'http://localhost:4000/api/v1'
|
? 'http://localhost:4000/api/v1'
|
||||||
: import.meta.env.VITE_API_URL || '/api/v1';
|
: import.meta.env.VITE_API_URL || '/api/v1';
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// Which shell the frontend runs in. The build-time flags come from the
|
||||||
|
// build:electron / build:tauri / dev:tauri scripts; the runtime checks cover
|
||||||
|
// dev mode, where the shell loads the plain Vite dev server.
|
||||||
|
|
||||||
|
export const isTauri =
|
||||||
|
import.meta.env.VITE_TAURI === "true" ||
|
||||||
|
(typeof window !== "undefined" && "__TAURI_INTERNALS__" in window);
|
||||||
|
|
||||||
|
export const isElectron =
|
||||||
|
import.meta.env.VITE_ELECTRON === "true" ||
|
||||||
|
(typeof window !== "undefined" && !!window.electron?.isElectron);
|
||||||
|
|
||||||
|
/** Built for a desktop shell: local backend on :4000, hash routing, custom title bar. */
|
||||||
|
export const isDesktopBuild =
|
||||||
|
import.meta.env.VITE_ELECTRON === "true" || import.meta.env.VITE_TAURI === "true";
|
||||||
|
|
||||||
|
/** Running inside a desktop shell (Electron or Tauri). */
|
||||||
|
export const isDesktop = isElectron || isTauri;
|
||||||
@@ -10,13 +10,7 @@ import {
|
|||||||
subMonths,
|
subMonths,
|
||||||
isSameDay,
|
isSameDay,
|
||||||
} from "date-fns";
|
} from "date-fns";
|
||||||
import {
|
import { ChevronLeft, ChevronRight, LayoutGrid, List } from "lucide-react";
|
||||||
ChevronLeft,
|
|
||||||
ChevronRight,
|
|
||||||
LayoutGrid,
|
|
||||||
List,
|
|
||||||
Loader2,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -25,7 +19,6 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { useEpisodesByMonth } from "@/hooks/useEpisodes";
|
import { useEpisodesByMonth } from "@/hooks/useEpisodes";
|
||||||
import { useSeriesSync } from "@/hooks/useSeriesSync";
|
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
@@ -53,8 +46,6 @@ export function CalendarPage() {
|
|||||||
const endDateStr = format(monthEnd, "yyyy-MM-dd");
|
const endDateStr = format(monthEnd, "yyyy-MM-dd");
|
||||||
|
|
||||||
const { data: episodes = [] } = useEpisodesByMonth(startDateStr, endDateStr);
|
const { data: episodes = [] } = useEpisodesByMonth(startDateStr, endDateStr);
|
||||||
// Refresh airing TV series (at most every 24h each) so air dates are current
|
|
||||||
const { job: syncJob, running: syncRunning } = useSeriesSync();
|
|
||||||
|
|
||||||
const days = useMemo(
|
const days = useMemo(
|
||||||
() => eachDayOfInterval({ start: monthStart, end: monthEnd }),
|
() => eachDayOfInterval({ start: monthStart, end: monthEnd }),
|
||||||
@@ -78,26 +69,7 @@ export function CalendarPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-[calc(100vh-3rem)]">
|
<div className="flex flex-col h-[calc(100vh-3rem)]">
|
||||||
<div className="flex items-center justify-between mb-4 shrink-0">
|
<div className="flex items-center justify-between mb-4 shrink-0">
|
||||||
<div className="flex min-w-0 items-center gap-3">
|
|
||||||
<h1 className="text-2xl font-bold">Calendar</h1>
|
<h1 className="text-2xl font-bold">Calendar</h1>
|
||||||
{syncRunning && syncJob?.total ? (
|
|
||||||
<span
|
|
||||||
className="inline-flex min-w-0 items-center gap-1.5 rounded-full border border-border/60 bg-muted/40 px-2.5 py-0.5 text-xs text-muted-foreground"
|
|
||||||
title="Refreshing TV series not updated in the last 24 hours"
|
|
||||||
>
|
|
||||||
<Loader2 className="h-3 w-3 shrink-0 animate-spin" />
|
|
||||||
<span className="tabular-nums">
|
|
||||||
{syncJob.scope === "all" ? "Refreshing library" : "Updating series"}{" "}
|
|
||||||
{syncJob.done ?? 0}/{syncJob.total}
|
|
||||||
</span>
|
|
||||||
{syncJob.current?.title && (
|
|
||||||
<span className="hidden max-w-40 truncate sm:inline">
|
|
||||||
· {syncJob.current.title}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { createBrowserRouter, createHashRouter } from "react-router-dom";
|
import { createBrowserRouter, createHashRouter } from "react-router-dom";
|
||||||
import { lazy, Suspense, type ReactNode } from "react";
|
import { lazy, Suspense, type ReactNode } from "react";
|
||||||
import { AppLayout } from "@/components/layout/AppLayout";
|
import { AppLayout } from "@/components/layout/AppLayout";
|
||||||
|
import { isDesktopBuild } from "@/lib/platform";
|
||||||
import {
|
import {
|
||||||
DashboardSkeleton,
|
DashboardSkeleton,
|
||||||
HomeSkeleton,
|
HomeSkeleton,
|
||||||
@@ -117,8 +118,7 @@ function SuspensePage({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const isElectron = import.meta.env.VITE_ELECTRON === "true";
|
const createRouter = isDesktopBuild ? createHashRouter : createBrowserRouter;
|
||||||
const createRouter = isElectron ? createHashRouter : createBrowserRouter;
|
|
||||||
|
|
||||||
export const router = createRouter([
|
export const router = createRouter([
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,10 +4,13 @@ import tailwindcss from '@tailwindcss/vite'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
const isElectron = process.env.VITE_ELECTRON === 'true';
|
const isElectron = process.env.VITE_ELECTRON === 'true';
|
||||||
|
const isTauri = process.env.VITE_TAURI === 'true';
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: isElectron ? './' : '/',
|
base: isElectron || isTauri ? './' : '/',
|
||||||
|
// Keep Rust/Tauri output visible in the terminal during `tauri dev`.
|
||||||
|
clearScreen: !isTauri,
|
||||||
plugins: [react(), tailwindcss()],
|
plugins: [react(), tailwindcss()],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
@@ -16,6 +19,8 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 4200,
|
port: 4200,
|
||||||
|
// Tauri loads devUrl http://localhost:4200, so never fall back to another port.
|
||||||
|
strictPort: isTauri,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://showyback.coolguy.space',
|
target: 'http://showyback.coolguy.space',
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
frontend_build
|
||||||
|
src-tauri/target
|
||||||
|
src-tauri/gen
|
||||||
|
src-tauri/binaries/*
|
||||||
|
!src-tauri/binaries/.gitkeep
|
||||||
+128
@@ -0,0 +1,128 @@
|
|||||||
|
# Showy — Tauri desktop app
|
||||||
|
|
||||||
|
A Tauri v2 shell for Showy, built side by side with the Electron app in `../electron`
|
||||||
|
(which stays untouched). It loads the React frontend from `../react_frontend` and
|
||||||
|
starts the Node backend from `../backend` alongside the window.
|
||||||
|
|
||||||
|
```
|
||||||
|
tauri/
|
||||||
|
├─ package.json # Tauri CLI + scripts
|
||||||
|
├─ scripts/prepare-sidecar.mjs # copies dist/backend/backend.exe into src-tauri/binaries
|
||||||
|
├─ frontend_build/ # output of `pnpm build:tauri` (git-ignored)
|
||||||
|
└─ src-tauri/
|
||||||
|
├─ tauri.conf.json # window, dev URL, frontend dist, bundle
|
||||||
|
├─ tauri.bundle.conf.json # adds the backend sidecar; merged in only for `pnpm build`
|
||||||
|
├─ capabilities/default.json # window permissions for the custom title bar
|
||||||
|
├─ icons/ # generated from electron/assets/icon.ico
|
||||||
|
└─ src/
|
||||||
|
├─ lib.rs # app setup, stops the backend on exit
|
||||||
|
└─ backend.rs # starts/stops the backend process
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prerequisites (Windows)
|
||||||
|
|
||||||
|
- **Rust** (stable, MSVC toolchain): install with [rustup](https://rustup.rs/), target
|
||||||
|
`x86_64-pc-windows-msvc`.
|
||||||
|
- **Microsoft C++ Build Tools**: "Desktop development with C++" workload from Visual Studio
|
||||||
|
Build Tools (needed by the MSVC Rust toolchain).
|
||||||
|
- **WebView2 runtime**: preinstalled on Windows 11. On Windows 10 install the Evergreen
|
||||||
|
runtime from Microsoft.
|
||||||
|
- **Node.js** (22.x is used here) and **pnpm**.
|
||||||
|
- **Tauri CLI**: installed per project as `@tauri-apps/cli` (`pnpm install` in this folder).
|
||||||
|
`cargo install tauri-cli --version "^2"` also works if you prefer `cargo tauri ...`.
|
||||||
|
- For the backend: a running **MySQL** and `backend/settings.json` (see
|
||||||
|
`backend/settings.json.example`), with dependencies installed in `backend/`.
|
||||||
|
|
||||||
|
## Run in dev
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd react_frontend && pnpm install
|
||||||
|
cd ../backend && pnpm install
|
||||||
|
cd ../tauri && pnpm install
|
||||||
|
pnpm dev
|
||||||
|
```
|
||||||
|
|
||||||
|
`pnpm dev` (= `tauri dev`) does the following:
|
||||||
|
|
||||||
|
1. Runs `pnpm --dir ../react_frontend dev:tauri`: Vite on `http://localhost:4200` with
|
||||||
|
`VITE_TAURI=true` (API base `http://localhost:4000/api/v1`, hash router, custom title bar).
|
||||||
|
2. Builds and starts the Rust app, which opens the window on the dev server (with hot reload)
|
||||||
|
and opens DevTools, like Electron's dev mode (set `SHOWY_NO_DEVTOOLS=1` to skip).
|
||||||
|
3. Starts the backend with `node server.js` in `../backend`. Its output shows in the same
|
||||||
|
terminal. When the window closes the backend is stopped, and so is anything it spawned (a
|
||||||
|
Windows job object kills the process tree, even if the app crashes).
|
||||||
|
|
||||||
|
If something already listens on port 4000 (e.g. you run `pnpm dev` in `backend/` yourself), the
|
||||||
|
app does **not** start a second backend and uses the one that is running.
|
||||||
|
|
||||||
|
Environment overrides:
|
||||||
|
|
||||||
|
| Variable | Effect |
|
||||||
|
| --- | --- |
|
||||||
|
| `SHOWY_SKIP_BACKEND=1` | never start a backend |
|
||||||
|
| `SHOWY_BACKEND_DIR=<path>` | backend folder for dev builds (default `../backend`) |
|
||||||
|
| `SHOWY_BACKEND_EXE=<path>` | run this executable as the backend (dev or release) |
|
||||||
|
| `SHOWY_NO_DEVTOOLS=1` | don't open DevTools in dev builds |
|
||||||
|
|
||||||
|
The first `tauri dev` compiles all Rust dependencies, which takes several minutes. Later runs
|
||||||
|
take seconds.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd backend && npm run package # pkg -> dist/backend/backend.exe
|
||||||
|
cd ../tauri && pnpm build-backend # copies it to src-tauri/binaries/backend-x86_64-pc-windows-msvc.exe
|
||||||
|
pnpm build # tauri build (runs `pnpm build:tauri` in react_frontend first)
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
- `src-tauri/target/release/showy.exe`: the app (the sidecar must sit next to it as `backend.exe`).
|
||||||
|
- `src-tauri/target/release/bundle/nsis/Showy_2.0.0_x64-setup.exe`: an installer that puts
|
||||||
|
`showy.exe` and `backend.exe` side by side.
|
||||||
|
|
||||||
|
In release builds the backend runs without a console, and its output goes to
|
||||||
|
`%LOCALAPPDATA%\x4lo.showy\logs\backend.log`.
|
||||||
|
|
||||||
|
The frontend build for Tauri goes to `tauri/frontend_build`. The web build (`pnpm build`) and
|
||||||
|
the Electron build (`pnpm build:electron`) are unchanged.
|
||||||
|
|
||||||
|
## Frontend changes
|
||||||
|
|
||||||
|
- `react_frontend/src/lib/platform.ts`: `isTauri`, `isElectron`, `isDesktop`, `isDesktopBuild`.
|
||||||
|
- `api.ts` and `router.tsx` use `isDesktopBuild` (Electron **or** Tauri build), so both desktop
|
||||||
|
builds talk to `localhost:4000` and use the hash router.
|
||||||
|
- `TitleBar.tsx`: on Tauri the buttons call `@tauri-apps/api/window` (`minimize`,
|
||||||
|
`toggleMaximize`, `close`), which is loaded lazily. Dragging uses `data-tauri-drag-region`.
|
||||||
|
Electron keeps using `window.electron.windowControls` and `-webkit-app-region`.
|
||||||
|
- `vite.config.ts`: `base: './'`, `strictPort` and no screen clearing when `VITE_TAURI=true`.
|
||||||
|
- New scripts: `dev:tauri`, `build:tauri`.
|
||||||
|
|
||||||
|
## Status / missing compared with Electron
|
||||||
|
|
||||||
|
Tested on Windows 11 in dev mode: the window opens on the Vite dev server, the backend starts
|
||||||
|
and answers the webview on port 4000, the title-bar window commands (minimize, maximize/restore,
|
||||||
|
close) work, and closing the window stops the backend.
|
||||||
|
|
||||||
|
Not done yet / differences:
|
||||||
|
|
||||||
|
- **The release build has not been tested yet.** It needs `dist/backend/backend.exe`, and there
|
||||||
|
is a known problem with the pkg backend: `configService.getUserDataPath()` uses `__dirname`,
|
||||||
|
which points inside pkg's read-only snapshot. So the packaged backend cannot find or create
|
||||||
|
`settings.json`. The backend needs to read its settings next to the executable
|
||||||
|
(`path.dirname(process.execPath)` when `process.pkg` is set) or from a folder the shell passes
|
||||||
|
in, e.g. via `PARENT_PROCESS.tauri_path` (the app data dir, already sent). `sharp` and
|
||||||
|
`ffmpeg-static` native files also need checking in the pkg build.
|
||||||
|
- **Backend model**: Electron `require`s `server.js` in its own process. Tauri runs it as a
|
||||||
|
separate process (`node` in dev, the pkg `backend.exe` in release).
|
||||||
|
- **`PARENT_PROCESS`**: Electron sends `{ electron_path: userData }`. Tauri sends
|
||||||
|
`{ tauri_path: <app data dir> }`. The backend doesn't read either today.
|
||||||
|
- **Generic IPC**: Electron's preload also exposes `window.electron.ipcRenderer`. The frontend
|
||||||
|
doesn't use it, so Tauri has no equivalent (only window controls).
|
||||||
|
- **Title bar on the login page**: the window has no native frame, and the login page renders
|
||||||
|
outside `AppLayout`, so there is no title bar to drag or close the window until you log in.
|
||||||
|
Electron behaves the same way.
|
||||||
|
- **Dev API target**: Electron's `npm run dev` loads the plain `vite` dev server, which proxies
|
||||||
|
`/api` to the remote backend. Tauri dev uses the local backend on port 4000.
|
||||||
|
- No auto-update, tray icon, single-instance lock or code signing (Electron has none of these
|
||||||
|
either). The bundle target is NSIS. Electron produces an unpacked `dir` build instead.
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "showy_tauri",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"private": true,
|
||||||
|
"description": "Showy Desktop App (Tauri)",
|
||||||
|
"scripts": {
|
||||||
|
"tauri": "tauri",
|
||||||
|
"dev": "tauri dev",
|
||||||
|
"build-front": "pnpm --dir ../react_frontend build:tauri",
|
||||||
|
"build-backend": "node scripts/prepare-sidecar.mjs",
|
||||||
|
"build": "tauri build --config src-tauri/tauri.bundle.conf.json",
|
||||||
|
"icons": "tauri icon ../electron/assets/icon.ico"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tauri-apps/cli": "^2.9.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+140
@@ -0,0 +1,140 @@
|
|||||||
|
lockfileVersion: '9.0'
|
||||||
|
|
||||||
|
settings:
|
||||||
|
autoInstallPeers: true
|
||||||
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
|
importers:
|
||||||
|
|
||||||
|
.:
|
||||||
|
devDependencies:
|
||||||
|
'@tauri-apps/cli':
|
||||||
|
specifier: ^2.9.0
|
||||||
|
version: 2.12.4
|
||||||
|
|
||||||
|
packages:
|
||||||
|
|
||||||
|
'@tauri-apps/cli-darwin-arm64@2.12.4':
|
||||||
|
resolution: {integrity: sha512-OxqKSckIkoJ6vX2AjifIJpTasFC0Hbdoo7gEiCmAjauABO3U8m2MRsLWe+QTiBwDx1mIrvgA+rvI7tvDnbnHVg==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-darwin-x64@2.12.4':
|
||||||
|
resolution: {integrity: sha512-fz76/77wMMJOaaUN6n3CybRG0P/MTEjjqYk81mGPyhi9m6Ue5T+LWBnJP/AkPooNatBPI2vtulGqomyMJ44lCQ==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-arm-gnueabihf@2.12.4':
|
||||||
|
resolution: {integrity: sha512-K0w8Bof6Lt8QKLAYhRy0yy36ZH5iA/35VuSOvnxyjvCUZ+A3JKsUTlALviH/sVgAlisaPzzmeJSH8XOn4Q2HBA==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [arm]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-arm64-gnu@2.12.4':
|
||||||
|
resolution: {integrity: sha512-j5rOnjmRUwWrm1oosf0zBYl4D+fqydgUROFCk0hvKZxvbTT8SOERes0QB7rBV/XWNy+kM6pCKzb3oSm2sRglzg==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-arm64-musl@2.12.4':
|
||||||
|
resolution: {integrity: sha512-aOue3Fy6Jb7+oWcfAVUsVHfeTybSCt2CZoU06aO4jv4d2Ks/KnaTPwMAK3CLEduGOvBLY1lbBBrIyomqLLH5Sg==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [musl]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-riscv64-gnu@2.12.4':
|
||||||
|
resolution: {integrity: sha512-Fx6GShY/RvST+t6LMlTHAwd66+1tEaAAGrnU7cysVfaiRP1BKng5Vl6rVmO6rSLOA1Sp1dRzNYM4f0OWQGb7qA==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [riscv64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-x64-gnu@2.12.4':
|
||||||
|
resolution: {integrity: sha512-tNzZSa79Z1nRpHxEpQ38lsAFpKlFlYvoXzjTV+lRRn/zSf3wrdUC3wnLcq2XEadchPu4ttK0zivhYzr+XGD19Q==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-x64-musl@2.12.4':
|
||||||
|
resolution: {integrity: sha512-jmZ1pr0xEqUhuEusWtt9Yt+GF6lCnGHUmIL+KIknpbjK/XQ2qkhDBhaxK/JMHM2A8dAacVXCxXJk2EXpwhQUfA==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [musl]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-win32-arm64-msvc@2.12.4':
|
||||||
|
resolution: {integrity: sha512-fGo8pgEHZxdSYgZ/J98m1usJ7NHKmKbq7k6uT0x1rpOq6Bg2YVzzpaAblWk710f5LHYBJIL5QIFS5IrD+4gmTg==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-win32-ia32-msvc@2.12.4':
|
||||||
|
resolution: {integrity: sha512-ezl8sQIcjYsye3TUnTH5VcWmWzccZASlQm7hlZt0dYyj1XD0qpVW47u2xYVrIKui0F8uQv/7QGZixdWiClBsbg==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [ia32]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
|
'@tauri-apps/cli-win32-x64-msvc@2.12.4':
|
||||||
|
resolution: {integrity: sha512-DJhDeCqjLDNMWYFy7ZS8cfeAHX2RK0RbQMLiA3bMVVkXRDJ4NBYiHriGqsUhsr9iG41aTb+dJGkFPmPw1gWwVw==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
|
'@tauri-apps/cli@2.12.4':
|
||||||
|
resolution: {integrity: sha512-JI9bHfudSRJikGOrjbXEm6RjzzvmKuLc+JixB1NE8hNzQkNlCCIC3pTES3uypkR9lxHrsbxzcnSwhI2IxBQphw==}
|
||||||
|
engines: {node: '>= 10'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
|
snapshots:
|
||||||
|
|
||||||
|
'@tauri-apps/cli-darwin-arm64@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-darwin-x64@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-arm-gnueabihf@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-arm64-gnu@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-arm64-musl@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-riscv64-gnu@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-x64-gnu@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-linux-x64-musl@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-win32-arm64-msvc@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-win32-ia32-msvc@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli-win32-x64-msvc@2.12.4':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@tauri-apps/cli@2.12.4':
|
||||||
|
optionalDependencies:
|
||||||
|
'@tauri-apps/cli-darwin-arm64': 2.12.4
|
||||||
|
'@tauri-apps/cli-darwin-x64': 2.12.4
|
||||||
|
'@tauri-apps/cli-linux-arm-gnueabihf': 2.12.4
|
||||||
|
'@tauri-apps/cli-linux-arm64-gnu': 2.12.4
|
||||||
|
'@tauri-apps/cli-linux-arm64-musl': 2.12.4
|
||||||
|
'@tauri-apps/cli-linux-riscv64-gnu': 2.12.4
|
||||||
|
'@tauri-apps/cli-linux-x64-gnu': 2.12.4
|
||||||
|
'@tauri-apps/cli-linux-x64-musl': 2.12.4
|
||||||
|
'@tauri-apps/cli-win32-arm64-msvc': 2.12.4
|
||||||
|
'@tauri-apps/cli-win32-ia32-msvc': 2.12.4
|
||||||
|
'@tauri-apps/cli-win32-x64-msvc': 2.12.4
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// Copies the pkg-packaged backend (dist/backend/backend.exe) into
|
||||||
|
// src-tauri/binaries/ under the name Tauri expects for an external binary:
|
||||||
|
// backend-<rust target triple>[.exe].
|
||||||
|
//
|
||||||
|
// Build the backend first: cd backend && npm run package
|
||||||
|
import { execSync } from "node:child_process";
|
||||||
|
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
|
||||||
|
import { dirname, join, resolve } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const here = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const repoRoot = resolve(here, "..", "..");
|
||||||
|
const ext = process.platform === "win32" ? ".exe" : "";
|
||||||
|
const source = join(repoRoot, "dist", "backend", `backend${ext}`);
|
||||||
|
|
||||||
|
const triple = execSync("rustc -vV", { encoding: "utf8" })
|
||||||
|
.split("\n")
|
||||||
|
.find((line) => line.startsWith("host:"))
|
||||||
|
?.slice("host:".length)
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
if (!triple) {
|
||||||
|
console.error("Could not read the Rust host triple from `rustc -vV`.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (!existsSync(source)) {
|
||||||
|
console.error(`Backend executable not found: ${source}`);
|
||||||
|
console.error("Build it first: cd backend && npm run package");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetDir = resolve(here, "..", "src-tauri", "binaries");
|
||||||
|
mkdirSync(targetDir, { recursive: true });
|
||||||
|
const target = join(targetDir, `backend-${triple}${ext}`);
|
||||||
|
copyFileSync(source, target);
|
||||||
|
console.log(`Copied ${source} -> ${target}`);
|
||||||
Generated
+4376
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,31 @@
|
|||||||
|
[package]
|
||||||
|
name = "showy"
|
||||||
|
version = "2.0.0"
|
||||||
|
description = "Showy Desktop App"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "showy_lib"
|
||||||
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tauri-build = { version = "2", features = [] }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
tauri = { version = "2", features = [] }
|
||||||
|
serde_json = "1"
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
windows-sys = { version = "0.59", features = [
|
||||||
|
"Win32_Foundation",
|
||||||
|
"Win32_Security",
|
||||||
|
"Win32_System_JobObjects",
|
||||||
|
"Win32_System_Threading",
|
||||||
|
] }
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
codegen-units = 1
|
||||||
|
lto = true
|
||||||
|
opt-level = "s"
|
||||||
|
panic = "abort"
|
||||||
|
strip = true
|
||||||
Whitespace-only changes.
@@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
tauri_build::build()
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
|
"identifier": "default",
|
||||||
|
"description": "Permissions for the main Showy window (custom title bar controls).",
|
||||||
|
"windows": ["main"],
|
||||||
|
"permissions": [
|
||||||
|
"core:default",
|
||||||
|
"core:window:allow-minimize",
|
||||||
|
"core:window:allow-toggle-maximize",
|
||||||
|
"core:window:allow-internal-toggle-maximize",
|
||||||
|
"core:window:allow-close",
|
||||||
|
"core:window:allow-start-dragging"
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 83 KiB |
@@ -0,0 +1,222 @@
|
|||||||
|
//! Starts the Showy Node backend next to the Tauri window and stops it on exit.
|
||||||
|
//!
|
||||||
|
//! - Debug builds (`tauri dev`) run `node server.js` from the repo's `backend/` folder.
|
||||||
|
//! - Release builds run the `pkg`-packaged `backend.exe` sidecar that the bundler
|
||||||
|
//! places next to the app executable.
|
||||||
|
//! - If something already listens on the backend port, nothing is spawned and the
|
||||||
|
//! app talks to that process (handy when the backend runs in its own terminal).
|
||||||
|
//!
|
||||||
|
//! Environment overrides:
|
||||||
|
//! - `SHOWY_SKIP_BACKEND=1` never spawn a backend
|
||||||
|
//! - `SHOWY_BACKEND_DIR=<path>` backend folder used in debug builds
|
||||||
|
//! - `SHOWY_BACKEND_EXE=<path>` run this executable instead (any build)
|
||||||
|
|
||||||
|
use std::fs::{self, File};
|
||||||
|
use std::net::{SocketAddr, TcpStream};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::process::{Child, Command, Stdio};
|
||||||
|
use std::sync::Mutex;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use tauri::{AppHandle, Manager};
|
||||||
|
|
||||||
|
/// The frontend calls `http://localhost:4000/api/v1` in desktop builds.
|
||||||
|
pub const BACKEND_PORT: u16 = 4000;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct BackendState {
|
||||||
|
child: Mutex<Option<Child>>,
|
||||||
|
#[cfg(windows)]
|
||||||
|
job: Mutex<Option<job::Job>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BackendState {
|
||||||
|
pub fn stop(&self) {
|
||||||
|
if let Some(mut child) = self.child.lock().unwrap().take() {
|
||||||
|
log(&format!("stopping backend (pid {})", child.id()));
|
||||||
|
let _ = child.kill();
|
||||||
|
let _ = child.wait();
|
||||||
|
}
|
||||||
|
// Closing the job handle kills anything the backend spawned (e.g. ffmpeg).
|
||||||
|
#[cfg(windows)]
|
||||||
|
drop(self.job.lock().unwrap().take());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start(app: &AppHandle) -> BackendState {
|
||||||
|
let state = BackendState::default();
|
||||||
|
|
||||||
|
if std::env::var_os("SHOWY_SKIP_BACKEND").is_some() {
|
||||||
|
log("SHOWY_SKIP_BACKEND is set, not starting the backend");
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
if port_in_use(BACKEND_PORT) {
|
||||||
|
log(&format!(
|
||||||
|
"port {BACKEND_PORT} is already in use, using the backend that is already running"
|
||||||
|
));
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut cmd = match backend_command() {
|
||||||
|
Ok(cmd) => cmd,
|
||||||
|
Err(err) => {
|
||||||
|
log(&format!("cannot start backend: {err}"));
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Same contract as the Electron shell: tell the backend where the desktop
|
||||||
|
// app keeps its own data.
|
||||||
|
let data_dir = app.path().app_data_dir().ok();
|
||||||
|
cmd.env(
|
||||||
|
"PARENT_PROCESS",
|
||||||
|
serde_json::json!({ "tauri_path": data_dir }).to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
|
if cfg!(debug_assertions) {
|
||||||
|
// Backend logs go to the same terminal as `tauri dev`.
|
||||||
|
cmd.stdout(Stdio::inherit()).stderr(Stdio::inherit());
|
||||||
|
} else {
|
||||||
|
// No console in release builds: write the backend output to a log file.
|
||||||
|
let log_file = app.path().app_log_dir().ok().and_then(|dir| {
|
||||||
|
fs::create_dir_all(&dir).ok()?;
|
||||||
|
File::create(dir.join("backend.log")).ok()
|
||||||
|
});
|
||||||
|
match log_file.and_then(|f| f.try_clone().ok().map(|f2| (f, f2))) {
|
||||||
|
Some((out, err)) => {
|
||||||
|
cmd.stdout(out).stderr(err);
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
cmd.stdout(Stdio::null()).stderr(Stdio::null());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||||
|
cmd.creation_flags(CREATE_NO_WINDOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmd.stdin(Stdio::null());
|
||||||
|
|
||||||
|
match cmd.spawn() {
|
||||||
|
Ok(child) => {
|
||||||
|
log(&format!("backend started (pid {})", child.id()));
|
||||||
|
#[cfg(windows)]
|
||||||
|
if let Some(job) = job::Job::kill_on_close() {
|
||||||
|
if job.assign(&child) {
|
||||||
|
*state.job.lock().unwrap() = Some(job);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*state.child.lock().unwrap() = Some(child);
|
||||||
|
}
|
||||||
|
Err(err) => log(&format!("failed to spawn backend: {err}")),
|
||||||
|
}
|
||||||
|
state
|
||||||
|
}
|
||||||
|
|
||||||
|
fn backend_command() -> Result<Command, String> {
|
||||||
|
if let Some(exe) = std::env::var_os("SHOWY_BACKEND_EXE") {
|
||||||
|
let exe = PathBuf::from(exe);
|
||||||
|
return exe_command(exe);
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg!(debug_assertions) {
|
||||||
|
let dir = std::env::var_os("SHOWY_BACKEND_DIR")
|
||||||
|
.map(PathBuf::from)
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../backend")
|
||||||
|
});
|
||||||
|
let dir = dir.canonicalize().map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||||
|
if !dir.join("server.js").is_file() {
|
||||||
|
return Err(format!("no server.js in {}", dir.display()));
|
||||||
|
}
|
||||||
|
let mut cmd = Command::new("node");
|
||||||
|
cmd.arg("server.js").current_dir(dir);
|
||||||
|
Ok(cmd)
|
||||||
|
} else {
|
||||||
|
let exe_dir = std::env::current_exe()
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
|
.parent()
|
||||||
|
.map(PathBuf::from)
|
||||||
|
.ok_or("cannot resolve the app folder")?;
|
||||||
|
let name = if cfg!(windows) { "backend.exe" } else { "backend" };
|
||||||
|
exe_command(exe_dir.join(name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn exe_command(exe: PathBuf) -> Result<Command, String> {
|
||||||
|
if !exe.is_file() {
|
||||||
|
return Err(format!("backend executable not found: {}", exe.display()));
|
||||||
|
}
|
||||||
|
let mut cmd = Command::new(&exe);
|
||||||
|
if let Some(dir) = exe.parent() {
|
||||||
|
cmd.current_dir(dir);
|
||||||
|
}
|
||||||
|
Ok(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn port_in_use(port: u16) -> bool {
|
||||||
|
let addr = SocketAddr::from(([127, 0, 0, 1], port));
|
||||||
|
TcpStream::connect_timeout(&addr, Duration::from_millis(300)).is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn log(msg: &str) {
|
||||||
|
eprintln!("[showy] {msg}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A Windows job object that kills every process in it when its handle closes,
|
||||||
|
/// including when the app crashes, so the backend never outlives the window.
|
||||||
|
#[cfg(windows)]
|
||||||
|
mod job {
|
||||||
|
use std::os::windows::io::AsRawHandle;
|
||||||
|
use std::process::Child;
|
||||||
|
|
||||||
|
use windows_sys::Win32::Foundation::{CloseHandle, HANDLE};
|
||||||
|
use windows_sys::Win32::System::JobObjects::{
|
||||||
|
AssignProcessToJobObject, CreateJobObjectW, JobObjectExtendedLimitInformation,
|
||||||
|
SetInformationJobObject, JOBOBJECT_EXTENDED_LIMIT_INFORMATION,
|
||||||
|
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct Job(HANDLE);
|
||||||
|
|
||||||
|
// The handle is only used behind a Mutex and closed once.
|
||||||
|
unsafe impl Send for Job {}
|
||||||
|
|
||||||
|
impl Job {
|
||||||
|
pub fn kill_on_close() -> Option<Job> {
|
||||||
|
unsafe {
|
||||||
|
let handle = CreateJobObjectW(std::ptr::null(), std::ptr::null());
|
||||||
|
if handle.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let mut info: JOBOBJECT_EXTENDED_LIMIT_INFORMATION = std::mem::zeroed();
|
||||||
|
info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
|
||||||
|
let ok = SetInformationJobObject(
|
||||||
|
handle,
|
||||||
|
JobObjectExtendedLimitInformation,
|
||||||
|
&info as *const _ as *const _,
|
||||||
|
std::mem::size_of_val(&info) as u32,
|
||||||
|
);
|
||||||
|
if ok == 0 {
|
||||||
|
CloseHandle(handle);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(Job(handle))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn assign(&self, child: &Child) -> bool {
|
||||||
|
unsafe { AssignProcessToJobObject(self.0, child.as_raw_handle() as HANDLE) != 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for Job {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
CloseHandle(self.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
mod backend;
|
||||||
|
|
||||||
|
use tauri::{Manager, RunEvent};
|
||||||
|
|
||||||
|
pub fn run() {
|
||||||
|
let app = tauri::Builder::default()
|
||||||
|
.setup(|app| {
|
||||||
|
let state = backend::start(app.handle());
|
||||||
|
app.manage(state);
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
if std::env::var("SHOWY_NO_DEVTOOLS").is_err() {
|
||||||
|
if let Some(window) = app.get_webview_window("main") {
|
||||||
|
window.open_devtools();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.build(tauri::generate_context!())
|
||||||
|
.expect("error while building the Showy Tauri app");
|
||||||
|
|
||||||
|
app.run(|handle, event| {
|
||||||
|
if let RunEvent::Exit = event {
|
||||||
|
if let Some(state) = handle.try_state::<backend::BackendState>() {
|
||||||
|
state.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Prevents an additional console window on Windows in release builds.
|
||||||
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
showy_lib::run()
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
|
"bundle": {
|
||||||
|
"externalBin": ["binaries/backend"]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
|
"productName": "Showy",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"identifier": "x4lo.showy",
|
||||||
|
"build": {
|
||||||
|
"beforeDevCommand": "pnpm --dir ../react_frontend dev:tauri",
|
||||||
|
"devUrl": "http://localhost:4200",
|
||||||
|
"beforeBuildCommand": "pnpm --dir ../react_frontend build:tauri",
|
||||||
|
"frontendDist": "../frontend_build"
|
||||||
|
},
|
||||||
|
"app": {
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"label": "main",
|
||||||
|
"title": "Showy",
|
||||||
|
"width": 1280,
|
||||||
|
"height": 800,
|
||||||
|
"minWidth": 900,
|
||||||
|
"minHeight": 600,
|
||||||
|
"decorations": false,
|
||||||
|
"backgroundColor": "#09090b",
|
||||||
|
"center": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"security": {
|
||||||
|
"csp": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"targets": ["nsis"],
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user