def create_or_update_movie_from_line(self, line):
        movie_parts_separator = "  "

        self.stdout.write(u'Processing line {line}'.format(line=line))

        movie_line_parts = filter(None, (line.split(movie_parts_separator)))

        title = movie_line_parts[3].split("\" (")[0][1:]
        year = movie_line_parts[3].split("\" (")[1][:-2]

        new_or_updated_movie = Movie()
        new_or_updated_movie.imdb_rank = float(movie_line_parts[2])
        new_or_updated_movie.title = title
        new_or_updated_movie.year = year
        new_or_updated_movie.imdb_votes = int(movie_line_parts[1])
        new_or_updated_movie.save()

        self.stdout.write(unicode(new_or_updated_movie))
        self.stdout.write('')
Example #2
0
                     sv = True
                     print "Adding rating to %s" % (m.title)
                 if (not m.metacritic_rating == int(mv['Metacritic'])):
                     m.metacritic_rating = mv['Metacritic']
                     sv = True
                     print "Adding metacritic to %s" % (m.title != '')
                 if (not m.poster) & (mv['Poster'] != ''):
                     m.poster = mv['Poster']
                     sv = True
                     print "Adding poster to %s (%s)" % (m.title,
                                                         mv['Poster'])
                 if m.date.year != int(mv["Released"][0:4]):
                     m.date = date(int(mv["Released"][0:4]),
                                   int(mv["Released"][5:7]),
                                   int(mv["Released"][8:10]))
                     sv = True
                     print "Adding date to %s" % (m.title)
                 if float(m.imdb_rating) != dec2(mv['imdbRating']):
                     m.imdb_votes = int2(mv['imdbVotes'])
                     m.imdb_rating = dec2(mv['imdbRating'])
                     sv = True
                     print "Adding imdb ratings to %s" % (m.title)
                 # else:
                 # print "Rating okay for %s" % (m.title)
                 if sv:
                     m.save()
                     saved = True
 except:
     pass
 if not saved:
     print "Skipped: %s" % mv['imdbID']