Created
          February 16, 2017 19:37 
        
      - 
      
 - 
        
Save sharkdp/6eff902699170cc20776fb9c85557684 to your computer and use it in GitHub Desktop.  
    Randomly choose a movie from your IMDb watchlist
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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)) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
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.