This script uses the Playwright automation framework and only supports Chrome/Chromium browsers. Playwright automatically downloads and manages browsers, eliminating the need for manual driver installation.
pip install -r requirements.txt
playwright install chromiumpip install python-dateutilThis minimal installation supports most extractors that don't require browser automation.
Dependencies are loaded on-demand. The program will show helpful error messages when a feature requires a missing package:
-
Browser Automation (for sites like Youku, IQIYI that require JavaScript rendering)
pip install playwright playwright install chromium
-
Chinese Variant Conversion (Simplified ↔ Traditional)
pip install opencc-python-reimplemented
Enable in
config.iniby settingchinese_convert = zh-CN(orzh-TW,zh-HK) -
Image Processing (for backdrop/poster cropping and format conversion)
pip install Pillow bordercrop
pip install playwright
pip install python-dateutil
pip install Pillow
pip install bordercrop
pip install opencc-python-reimplemented
playwright install chromium-h, --help: Show help information-V, --version: Show version information-d, --debug: Enable debug logging (default is INFO level)--headless: Run browser in headless mode (default is GUI mode)
python -m tmdb_import [options] "URL"
- GUI Mode (default): Browser window is visible, suitable for debugging and scenarios requiring manual interaction
- Headless Mode (--headless): Browser runs in the background without displaying a window, suitable for automation scripts and server environments
- Headless mode can improve performance and reduce resource usage, especially suitable for batch processing tasks
python -m tmdb_import "http://www.***.com/video.html"
python -m tmdb_import -d "http://www.***.com/video.html" # Enable debug logging
python -m tmdb_import --headless "http://www.***.com/video.html" # Run in headless mode
python -m tmdb_import -d --headless "http://www.***.com/video.html" # Debug + headless mode
python -m tmdb_import "http://www.***.com/video.html" --debug # Options can also be placed after URL
- Extract episode data through web links, including title, plot description, duration, release time (mostly current platform time), and background image links.
- Output files:
metadata.json: Full structured metadata (show-level fields, season-level fields, episode list by season)import.csv: Flattened episode list for TMDB import
python -m tmdb_import "https://www.themoviedb.org/tv/{tv_id}/season/{season_number}?language={language}"
# Example: python -m tmdb_import "https://www.themoviedb.org/tv/203646/season/1?language=zh-CN"
# Enable debug: python -m tmdb_import -d "https://www.themoviedb.org/tv/203646/season/1?language=zh-CN"
# Headless mode: python -m tmdb_import --headless "https://www.themoviedb.org/tv/203646/season/1?language=zh-CN"
# Combined options: python -m tmdb_import -d --headless "https://www.themoviedb.org/tv/203646/season/1?language=zh-CN"
- Import data from import.csv in the directory to TMDB. When uploading backdrop images, automatically crop black borders and adapt to the aspect ratio required by TMDB. On first run, manual login is required (or set
tmdb_usernameandtmdb_passwordinconfig.inifor automatic login). See Configuration for more options.
python -m tmdb_import backdrop "https://www.***.com/image.jpg"
python -m tmdb_import --headless backdrop "https://www.***.com/image.jpg" # Process backdrop in headless mode
- Crop backdrop images to fit TMDB requirements
python -m tmdb_import poster "https://www.***.com/image.jpg"
python -m tmdb_import --headless poster "https://www.***.com/image.jpg" # Process poster in headless mode
- Crop poster images to fit TMDB requirements
python -m tmdb_import fitsize width*height "https://www.***.com/image.jpg"
python -m tmdb_import --headless fitsize 1920*1080 "https://www.***.com/image.jpg" # Crop in headless mode
- Crop images according to specified width and height
TMDB-Import can also be used as a library in your Python projects:
# Add to sys.path (if not installed via pip)
import sys
sys.path.insert(0, r'/path/to/TMDB-Import')
# Import directly (package uses underscore now)
from tmdb_import import extract_from_url, save_metadata_json, create_csv
# Extract metadata
metadata = extract_from_url("https://tver.jp/series/...")
# Access metadata
print(metadata.title) # Show title
print(metadata.overview) # Show overview
print(metadata.poster) # Poster URL
print(metadata.language) # Language code (e.g., 'ja-JP')
# Access episodes
for season in metadata.seasons:
for episode_num, episode in season.episodes.items():
print(f"E{episode_num}: {episode.name}")
# Optional: Save files manually
save_metadata_json("output.json", metadata)
for season in metadata.seasons:
if season.episodes:
create_csv("output.csv", season.episodes)
breakAvailable Functions:
extract_from_url(url, language="zh-CN"): Extract and process metadata from URLsave_metadata_json(filename, metadata): Save metadata to JSON filecreate_csv(filename, episodes_dict): Save episodes to CSV file
Metadata Structure:
Metadata: Show-level data (title, overview, poster, backdrop, logo, language, seasons)Season: Season-level data (season_number, name, overview, poster, episodes)Episode: Episode data (episode_number, name, air_date, runtime, overview, backdrop)
The config.ini file in the working directory controls the behaviour of the script. All settings are placed under the [DEFAULT] section.
| Key | Default | Description |
|---|---|---|
encoding |
utf-8-sig |
CSV file encoding (e.g. utf-8, utf-8-sig, gbk) |
save_user_profile |
true |
Persist the browser session under the Browser/ folder so you stay logged in between runs |
tmdb_username |
(empty) | TMDB account username for automatic login |
tmdb_password |
(empty) | TMDB account password for automatic login |
backdrop_forced_upload |
false |
When true, upload a backdrop image even if one already exists on TMDB |
backdrop_vote_after_upload |
false |
When true, automatically cast a thumbs-up vote on the newly uploaded backdrop |
filter_words |
(empty) | Comma-separated words; episodes whose titles contain any of these words are filtered out. Remaining episodes are automatically renumbered while preserving gaps (e.g., if episodes 1,2,3,4,5,6,10 exist and episodes 2,4 are filtered, result will be 1,2,3,8 to preserve the gap after episode 6) |
rename_csv_on_import |
false |
When true, rename import.csv to import_{tmdb_id}_s{season}_{language}.csv before importing |
delete_csv_after_import |
false |
When true, delete the CSV file after a successful import |
chinese_convert |
(empty) | Convert Chinese text variant after extraction. Leave empty to disable. Options: zh-CN (Simplified), zh-TW (Taiwan Traditional), zh-HK (Hong Kong Traditional). Only applied when the source language is Chinese (zh-*). |
Example config.ini:
[DEFAULT]
encoding = utf-8-sig
save_user_profile = true
tmdb_username = your_username
tmdb_password = your_password
backdrop_forced_upload = false
backdrop_vote_after_upload = false
filter_words = 番外,加更
rename_csv_on_import = false
delete_csv_after_import = false
chinese_convert = Windows 11, Chrome/Chromium, Python 3, and Visual Studio Code.
| Website | Title | Plot | Duration | Release Date | Backdrop | Default Language |
|---|---|---|---|---|---|---|
| anidb | ✔ | x | ✔ | ✔ | x | Follow site |
| apple | ✔ | ✔ | ✔ | ✔ | ✔ | zh-CN |
| asahi | ✔ | ✔ | ✔ | ✔ | ✔ | ja-JP |
| bilibili | ✔ | x | ✔ | ✔ | ✔ | zh-CN |
| biliintl | ✔ | x | x | ✔ | ✔ | Follow site |
| crunchyroll | ✔ | ✔ | ✔ | ✔ | ✔ | Follow site |
| cctv | ✔ | ✔ | ✔ | x | ✔ | zh-CN |
| fod | ✔ | ✔ | x | ✔ | ✔ | ja-JP |
| hbomax | ✔ | ✔ | x | ✔ | ✔ | Follow site |
| iqiyi | ✔ | x | x | x | ✔ | zh-CN |
| ixigua | ✔ | ✔ | ✔ | ✔ | ✔ | zh-CN |
| kktv | ✔ | x | ✔ | ✔ | ✔ | zh-TW |
| linetv | ✔ | x | ✔ | x | ✔ | zh-TW |
| litv | ✔ | x | x | x | ✔ | zh-TW |
| mgtv | ✔ | x | ✔ | ✔ | x | zh-CN |
| migu | ✔ | ✔ | ✔ | x | x | zh-CN |
| mytvsuper | ✔ | ✔ | ✔ | ✔ | ✔ | zh-HK |
| myvideo | ✔ | ✔ | x | x | ✔ | zh-TW |
| netflix | ✔ | ✔ | x | x | x | Follow site |
| nhk | ✔ | ✔ | ✔ | x | ✔ | ja-JP |
| paravi | ✔ | ✔ | x | ✔ | ✔ | ja-JP |
| primevideo | ✔ | ✔ | ✔ | ✔ | ✔ | Follow site |
| ptsplus | ✔ | ✔ | ✔ | x | ✔ | zh-TW |
| ✔ | x | ✔ | ✔ | ✔ | zh-CN | |
| sohu | ✔ | ✔ | ✔ | ✔ | ✔ | zh-CN |
| tvdb | ✔ | x | ✔ | ✔ | x | Follow site |
| tvbanywhere | ✔ | ✔ | ✔ | ✔ | ✔ | zh-HK |
| tver | ✔ | ✔ | ✔ | ✔ | ✔ | ja-JP |
| viki | x | ✔ | ✔ | x | ✔ | en-US |
| viu | ✔ | ✔ | ✔ | ✔ | ✔ | zh-CN |
| yahoo | ✔ | ✔ | ✔ | x | x | Follow site |
| wavve | ✔ | ✔ | ✔ | ✔ | ✔ | ko-KR |
| youku | ✔ | ✔ | ✔ | ✔ | ✔ | zh-CN |
| youtube | ✔ | ✔ | ✔ | ✔ | ✔ | Follow site |