Skip to content

Instantly share code, notes, and snippets.

@mtimkovich
Created July 24, 2024 09:40
Show Gist options
  • Save mtimkovich/a9a350a859010698996dbc663d663e25 to your computer and use it in GitHub Desktop.
Save mtimkovich/a9a350a859010698996dbc663d663e25 to your computer and use it in GitHub Desktop.
Netflix watched history to Letterboxd
import csv
from datetime import datetime
import re
def is_tv(title: str) -> bool:
synonyms = '(Season|Part|Volume|Chapter|Series|Book|Collection)'
text_numbers = '(One|Two|Three|Four|Five|Six|Seven|Eight|Nine|Ten)'
return (re.search(f'{synonyms} (\\d+|{text_numbers})', title)
or 'Limited Series' in title)
if __name__ == '__main__':
input = open('NetflixViewingHistory.csv')
output = open('netflix_letterboxd.csv', 'w')
reader = csv.reader(input)
writer = csv.writer(output)
writer.writerow(['Title', 'WatchedDate'])
for i, row in enumerate(reader):
if i == 0:
continue
title = row[0]
# Attempt to cull TV shows.
if is_tv(title):
continue
watched_date = datetime.strptime(row[1], '%m/%d/%y')
watched_date = watched_date.strftime('%Y-%m-%d')
writer.writerow([title, watched_date])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment