Skip to content

Instantly share code, notes, and snippets.

@sharkdp
Created February 16, 2017 19:37
Show Gist options
  • Save sharkdp/6eff902699170cc20776fb9c85557684 to your computer and use it in GitHub Desktop.
Save sharkdp/6eff902699170cc20776fb9c85557684 to your computer and use it in GitHub Desktop.
Randomly choose a movie from your IMDb watchlist
import csv
import random
with open("WATCHLIST.csv") as f:
rows = csv.DictReader(f, delimiter=",", quotechar='"')
movies = [row for row in rows if row["Title type"] == "Feature Film"]
movie = random.choice(movies)
movie["Genres"] = movie["Genres"].replace("sci_fi", "sci-fi")
text = """There are {num} feature films in your watchlist.
I have chosen the following movie for you:
\x1b[1m{Title}\x1b[0m ({Year})
IMDB rating: {IMDb Rating}
Genres: {Genres}
Runtime: {Runtime (mins)}min
Link: {URL}
You have two options:
* watch the movie now!
* delete the movie from your watchlist."""
print(text.format(num=len(movies), **movie))
@frostblooded
Copy link

The headers of the CSV and the way some of the data in the CSV is written has apparently been changed. I have forked the script and made the necessary changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment