Exemple #1
0
    def handle(self, *args, **options):
        if args:
            assert len(args) == 1
            (imdb_path, ) = args
        elif hasattr(settings, 'IMDB_PATH'):
            imdb_path = settings.IMDB_PATH
        else:
            raise CommandError("Unable to find path to video files.  Either "
                               "set IMDB_PATH in settings.py or pass it on "
                               "the command line.")

        # The number of ContentNodes should be much smaller than all the movies
        # in IMDB, so we throw these in a dict and stream over IMDB instead of
        # the other way around.
        videos = models.ContentNode.objects.all()
        self.title_to_video = dict((v.title, v) for v in videos)
        self.title_to_imdb = {}
        self.parser = imdb.ImdbParser(imdb_path)

        self.create_imdbmetadata()
        self.add_plots()
        self.add_times()
        self.add_ratings()
        self.add_genres()
        self.add_directors()
        self.add_actors()
        self.save_imdbmetadata()
Exemple #2
0
 def test_gen_plots(self, mock_open):
     parser = imdb.ImdbParser("")
     plots = [
         ('Movie A (1991)', [('foo', 'asdf asdf')]),
         ('Movie B (1992)', [('bar', 'jkl; jkl;'), ('baz', 'quux quux')]),
     ]
     self.assertEqual(plots, list(parser.generate_plots()))
Exemple #3
0
 def test_gen_running_times(self, mock_open):
     parser = imdb.ImdbParser("")
     times = [
         ('The Insurance Man (1986) (TV)', 77),
         ('The Insurgents (2006)', 82),
         ('The Intern (2007) (V)', 117),
         ('The International (2009)', 118),
     ]
     self.assertEqual(times, list(parser.generate_running_times()))
Exemple #4
0
 def test_gen_movies(self, mock_open):
     parser = imdb.ImdbParser("")
     titles = [
         'D (2005)',
         'D 14 (1993)',
         'D 4 Delivery (2007)',
         'D III 38 (1939)',
         'D Minus (1998)',
     ]
     self.assertEqual(titles, list(parser.generate_movie_titles()))
Exemple #5
0
 def test_gen_ratings(self, mock_open):
     parser = imdb.ImdbParser("")
     ratings = [
         ('Austin Golden Hour (2008) (TV)', 66),
         ('Austin Powers in Goldmember (2002)', 62),
         ('Austin Powers: International Man of Mystery (1997)', 71),
         ('Economix - International Trade (1996)', 18),
         ('The International (2009)', 68),
         ('The Interruption (2004)', 40),
     ]
     self.assertEqual(ratings, list(parser.generate_ratings()))
Exemple #6
0
 def test_gen_genres(self, mock_open):
     parser = imdb.ImdbParser("")
     genres = [
         ('B-17: A Mini-Epic (2007)', 'Short'),
         ('B (1996)', 'Short'),
         ('B (1996)', 'Thriller'),
         ('B-1 Nuclear Bomber (1980) (VG)', 'Action'),
         ('B 224 (1999)', 'Short'),
         ('B-29 Flight Procedure and Combat Crew Functioning (1944)',
          'Short'),
         ('B-29 Flight Procedure and Combat Crew Functioning (1944)',
          'Documentary'),
     ]
     self.assertEqual(genres, list(parser.generate_genres()))
Exemple #7
0
 def test_gen_directors(self, mock_open):
     parser = imdb.ImdbParser("")
     directors = [
         ('Action Man (1998)', '13, Phoenix'),
         ('Action Man 2 (1998)', '13, Phoenix'),
         ('Anal Graveyard (1997)', '13, Phoenix'),
         ('Absolute Punishment: The Ultimate Death Experience Part 2 (1998)',
          '1312'),
         ('Before I Self Destruct (2009)', '50 Cent'),
         ('Crazy Jones (2002)', 'Aaron, Joe (II)'),
         ('Grease Monkeys (1979)', 'Aaron, Mark (I)'),
         ('The Rivermen (1980)', 'Aaron, Mark (I)'),
     ]
     self.assertEqual(directors, list(parser.generate_directors()))
Exemple #8
0
 def test_gen_actors(self, mock_open):
     parser = imdb.ImdbParser("")
     actors = [
         ('Shenasayi (1987)', 'Aalami, Ali Reza', 'M', None, None),
         ('Ansoo-ye ayene (1997)', 'Aalami, Arash', 'M', None, 7),
         ('13 (2010)', '50 Cent', 'M', 'Jimmy', None),
         ('2003 Radio Music Awards (2003)', '50 Cent', 'M', 'Himself',
          None),
         ('Ambush (2001)', 'Owen, Clive', 'M', 'The Driver', 1),
         ('Bad Boy Blues (1995)', 'Owen, Clive', 'M', 'Paul', 1),
         ('Beat the Devil (2002)', 'Owen, Clive', 'M', 'Driver', 1),
         ('Shoot \'Em Up (2007)', 'Owen, Clive', 'M', 'Smith', 1),
         ('Sin City (2005)', 'Owen, Clive', 'M', 'Dwight', 36),
         ('16 Blocks (2006)', 'Willis, Bruce', 'M', 'Det. Jack Mosley', 1),
         ('Apocalypse (1998)', 'Willis, Bruce', 'M', 'Trey Kincaid', 1),
         ('Armageddon (1998/I)', 'Willis, Bruce', 'M', 'Harry S. Stamper',
          1),
         ('Die Hard (1988)', 'Willis, Bruce', 'M', 'Officer John McClane',
          1),
     ]
     with mock_open(None) as f:
         self.assertEqual(actors, list(parser._generate_actors(f, 'M')))