-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvidangel.py
More file actions
50 lines (36 loc) · 1.42 KB
/
Copy pathvidangel.py
File metadata and controls
50 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!python
# Read a CSV file of Letterboxd watched.csv or watchlist.csv and create URLs to VidAngel for them
import csv
import argparse
import os
import string
import unicodedata
def movie_title_to_slug(title: str) -> str:
# Normalize Unicode characters to remove accents (e.g., é → e)
normalized = unicodedata.normalize('NFKD', title)
ascii_only = normalized.encode('ascii', 'ignore').decode('utf-8')
# Remove punctuation
translator = str.maketrans('', '', string.punctuation)
cleaned = ascii_only.translate(translator)
# Convert to lowercase, split into words, and join with dashes
slug = "-".join(cleaned.lower().split())
return slug
def read_films(file_path):
with open(file_path, 'r') as csvfile:
csvreader = csv.DictReader(csvfile)
for row in csvreader:
if len(row) != 4:
print('Bad row:', row)
raise Exception('Improper row')
# print(row['Name'])
print('start https://www.vidangel.com/movie/', movie_title_to_slug(row['Name']), sep='')
def main():
parser = argparse.ArgumentParser(description='vidangel.py - Check a list of films on VidAngel')
parser.add_argument('fname',
nargs='+',
help='Files to convert')
args = parser.parse_args()
for fname in args.fname:
read_films(fname)
if __name__ == "__main__":
main()