54 lines
1.3 KiB
Markdown
54 lines
1.3 KiB
Markdown
---
|
|
title: Import System
|
|
tags:
|
|
- backend
|
|
- import
|
|
- bulk
|
|
---
|
|
|
|
# Import System
|
|
|
|
## Overview
|
|
|
|
Bulk import functionality for migrating data into Showy. Self-throttling to respect TMDB rate limits.
|
|
|
|
> [!info] File: `backend/services/importerService.js`
|
|
|
|
## Endpoints
|
|
|
|
See [[API Reference#Import]].
|
|
|
|
| Method | Path | Description |
|
|
|---|---|---|
|
|
| `POST` | `/api/v1/import/movies` | Bulk import movies |
|
|
| `POST` | `/api/v1/import/tmdb` | Import by TMDB IDs |
|
|
| `POST` | `/api/v1/import/episodes-watch-history` | Import episode watch history |
|
|
|
|
## Rate Limiting
|
|
|
|
The importer self-throttles to stay under TMDB API limits:
|
|
|
|
- **Max 35 requests per 10 seconds**
|
|
- **500ms delay** between each individual request
|
|
- Each import triggers the full [[Services#EntryManager]] pipeline (TMDB fetch → save → media download)
|
|
|
|
## Flows
|
|
|
|
### Movie Import
|
|
|
|
1. Receives array of movie data
|
|
2. For each: calls `EntryManager.fetchAndSaveNewEntry(tmdbId, false)`
|
|
3. Throttled execution with progress tracking
|
|
|
|
### TMDB ID Import
|
|
|
|
1. Receives array of TMDB IDs + type flags
|
|
2. For each: calls `EntryManager.fetchAndSaveNewEntry(tmdbId, isTvSeries)`
|
|
3. Same throttled execution
|
|
|
|
### Episode Watch History Import
|
|
|
|
1. Receives array of episode watch records
|
|
2. Creates `EpisodeSeen` records in bulk
|
|
3. Updates `date_first_seen`/`date_last_seen` on episodes and entries
|