Example #1
0
    def __init__(self, config):

        self.config = config

        #config TheMovieDB
        self.theMovieDb = theMovieDb(config)
        self.sources.append(self.theMovieDb)

        #config imdb
        self.imdb = imdbWrapper(config)
        self.sources.append(self.imdb)

        # Update the cache
        movies = Db.query(Movie).order_by(Movie.name).filter(or_(Movie.status == u'want', Movie.status == u'waiting')).all()
        for movie in movies:
            if not movie.extra:
                self.getExtraInfo(movie.id)
Example #2
0
    def __init__(self, config):

        self.config = config

        # Config TheMovieDB
        self.theMovieDb = theMovieDb(self.config)
        self.sources.append(self.theMovieDb)

        # Config imdbWrapper
        self.imdb = imdbWrapper(self.config)
        self.sources.append(self.imdb)

        # Update the cache
        movies = Db.query(Movie).order_by(Movie.name).filter(or_(Movie.status == u'want', Movie.status == u'waiting')).all()
        for movie in movies:
            if not movie.extra:
                self.getExtraInfo(movie)

            # Fix db errors
            try:

                # Clear wrong value
                imdb_is_int = False
                try:
                    imdb_is_int = float(movie.imdb)
                except ValueError:
                    pass

                if not imdb_is_int and movie.imdb[:2] != 'tt':
                    movie.imdb = None
                    Db.flush()

                if movie.imdb and movie.imdb[:2] != 'tt':
                    movie.imdb = 'tt%s' % movie.imdb
                    Db.flush()
                elif not movie.imdb and movie.movieDb:
                    results = self.findById(movie.movieDb)
                    if results.get('imdb'):
                        movie.imdb = results.get('imdb')
                        Db.flush()

                if not movie.imdb:
                    log.error('Errors in your database, try and remove & re-add: %s' % movie.name)
            except:
                pass