hdtv shut down: export your list to Trakt
The hdtv app has shut down, and many of us are locked out of our watchlists and history. It is annoying to lose track of where you left off in a series.
- Time
- 4 min
- Steps
- 7
- Updated
- 19 Nov 2026
You will learn
- Steps
- Prepare your input file
- Get a free TMDB API key
- Install the required library
- The Python script
If you exported your data to a basic CSV file before the shutdown, you can move your collection to Trakt.tv, a good platform for tracking movies and TV shows.
Trakt allows you to import your history using a CSV file, but it requires a very specific format (including TMDB IDs and content types) to match your shows correctly. To save you the headache of manually editing hundreds of rows, I wrote a Python script that fetches the correct TMDB IDs, sets the type to ‘show’ and formats the file for the Trakt import.
Here is how to get your TV show history back.
Step 1 of 7: Steps
Step 2 of 7: Prepare your input file
Create a CSV file named series.csv in the same folder where you will run the script. Make sure it has a column named title with the names of the TV shows you want to import.
Example series.csv:
Codefragment
title
Breaking Bad
Stranger Things
Game of Thrones
Step 3 of 7: Get a free TMDB API key
The script needs to talk to The Movie Database (TMDB) to find the correct IDs for Trakt.
- Go to The Movie Database and create a free account.
- Navigate to your account settings, click on API in the left menu, and request an API key.
- Paste this key into the script below (replace the placeholder text).
Step 4 of 7: Install the required library
Open your Terminal (Mac) or Command Prompt (Windows) and install the requests library by running:
Bash
pip3 install requests
Step 5 of 7: The Python script
Save the following code as trakt_exporter.py in the same directory as your series.csv file.
Python
import csv
import requests
import time
from datetime import datetime
# Your personal TMDb API key
TMDB_API_KEY = "YOUR_TMDB_API_KEY_HERE"
# File configuration
input_file = "series.csv"
output_file = "series_watched_trakt.csv"
# We use today's date as the 'watched date' (Format: YYYY-MM-DD)
# Trakt uses this to mark the show as officially 'watched'.
today = datetime.now().strftime("%Y-%m-%d")
print("Starting the conversion of your watched TV shows...")
with open(input_file, mode='r', encoding='utf-8') as infile, \
open(output_file, mode='w', encoding='utf-8', newline='') as outfile:
reader = csv.DictReader(infile)
# Setting up correct headers for Trakt.tv CSV import
fieldnames = ['tmdb', 'imdb', 'type', 'title', 'watched_at']
writer = csv.DictWriter(outfile, fieldnames=fieldnames)
writer.writeheader()
for row in reader:
title = row.get('title', '').strip()
if not title:
continue
print(f"Searching for: '{title}'...")
search_url = "https://api.themoviedb.org/3/search/tv"
params = {
"api_key": TMDB_API_KEY,
"query": title
}
tmdb_tv_id = ""
imdb_id = ""
try:
response = requests.get(search_url, params=params).json()
results = response.get('results', [])
if results:
tmdb_tv_id = results[0]['id']
actual_name = results[0]['name']
# Fetching external IDs to get the IMDb backup reference
id_url = f"https://api.themoviedb.org/3/tv/{tmdb_tv_id}/external_ids"
id_response = requests.get(id_url, params={"api_key": TMDB_API_KEY}).json()
imdb_id = id_response.get('imdb_id', '')
if imdb_id:
print(f" -> Found! {actual_name} (TMDB: {tmdb_tv_id} | IMDb: {imdb_id})")
else:
print(f" -> Found! {actual_name} (TMDB: {tmdb_tv_id}), but no IMDb ID available.")
else:
print(f" -> No match found for '{title}'.")
except Exception as e:
print(f" -> Error during search: {e}")
# Write row with optimized Trakt format
writer.writerow({
'tmdb': tmdb_tv_id,
'imdb': imdb_id,
'type': 'show', # Hardcoded as 'show' for Trakt categorisation
'title': title,
'watched_at': today # This flags the show as 'watched' in Trakt
})
# Short pause to respect TMDB API limits
time.sleep(0.2)
print("\nSuccess! Your new file 'series_watched_trakt.csv' is ready for import.")
Step 6 of 7: Run the script
Run the script in your terminal:
Bash
python3 trakt_exporter.py
Step 7 of 7: Import to Trakt.tv
Once the script finishes, you will see a new file called series_watched_trakt.csv.
- Head over to Trakt.tv and log into your account.
- Use their built-in CSV importer.
- Upload your newly generated
series_watched_trakt.csvfile, and Trakt fills your profile with your shows, marked as watched with today’s date.
Note: if the script does not find a show, its row stays in the CSV with an empty ID, so you can fill it in by hand before uploading.
