def _addMovie(self, movie, quality, year=None): if self._checkMovieExists(movie=movie, qualityId=quality): return log.info('Adding movie to database: %s' % movie.name) if movie.id: exists = Db.query(Movie).filter_by(movieDb=movie.id).first() else: exists = Db.query(Movie).filter_by(imdb=movie.imdb).first() if exists: log.info('Movie already exists, do update.') # Delete old qualities for x in exists.queue: x.active = False Db.flush() new = exists else: new = Movie() Db.add(new) # Update the stuff new.status = u'want' new.name = movie.name new.imdb = movie.imdb new.movieDb = movie.id new.quality = quality new.year = year if year and movie.year == 'None' else movie.year Db.flush() # Add qualities to the queue quality = Db.query(QualityTemplate).filter_by(id=quality).one() for type in quality.types: queue = MovieQueue() queue.qualityType = type.type queue.movieId = new.id queue.order = type.order queue.active = True queue.completed = False queue.waitFor = 0 if type.markComplete else quality.waitFor queue.markComplete = type.markComplete Db.add(queue) Db.flush() #Get xml from themoviedb and save to cache self.searchers.get('movie').getExtraInfo(new.id, overwrite=True) #gogo find nzb for added movie via Cron self.cron.get('yarr').forceCheck(new.id) self.flash.add('movie-' + str(new.id), '"%s" (%s) added.' % (new.name, new.year))
def _addMovie(self, movie, quality, year = None): if self._checkMovieExists(movie=movie): return log.info('Adding movie to database: %s' % movie.name) if movie.id: exists = Db.query(Movie).filter_by(movieDb = movie.id).first() else: exists = Db.query(Movie).filter_by(imdb = movie.imdb).first() if exists: log.info('Movie already exists, do update.') # Delete old qualities for x in exists.queue: x.active = False Db.flush() new = exists else: new = Movie() Db.add(new) # Update the stuff new.status = u'want' new.name = movie.name new.imdb = movie.imdb new.movieDb = movie.id new.quality = quality new.year = year if year and movie.year == 'None' else movie.year Db.flush() # Add qualities to the queue quality = Db.query(QualityTemplate).filter_by(id = quality).one() for type in quality.types: queue = MovieQueue() queue.qualityType = type.type queue.movieId = new.id queue.order = type.order queue.active = True queue.completed = False queue.waitFor = 0 if type.markComplete else quality.waitFor queue.markComplete = type.markComplete Db.add(queue) Db.flush() #Get xml from themoviedb and save to cache self.searchers.get('movie').getExtraInfo(new.id, overwrite = True) #gogo find nzb for added movie via Cron self.cron.get('yarr').forceCheck(new.id) self.flash.add('movie-' + str(new.id), '"%s" (%s) added.' % (new.name, new.year))
def _addMovie(self, movie, quality, year=None): if cherrypy.config.get("config").get("XBMC", "dbpath"): log.debug("Checking if movie exists in XBMC by IMDB id:" + movie.imdb) dbfile = os.path.join(cherrypy.config.get("config").get("XBMC", "dbpath"), "MyVideos34.db") # ------Opening connection to XBMC DB------ connXbmc = MySqlite.connect(dbfile) if connXbmc: connXbmc.row_factory = MySqlite.Row cXbmc = connXbmc.cursor() cXbmc.execute('select c09 from movie where c09="' + movie.imdb + '"') # ------End of Opening connection to XBMC DB------ inXBMC = False for rowXbmc in cXbmc: # do a final check just to be sure log.debug("Found in XBMC:" + rowXbmc["c09"]) if movie.imdb == rowXbmc["c09"]: inXBMC = True else: inXBMC = False cXbmc.close() if inXBMC: log.info("Movie already exists in XBMC, skipping.") return else: log.info( "Could not connect to the XBMC database at " + cherrypy.config.get("config").get("XBMC", "dbpath") ) log.info("Adding movie to database: %s" % movie.name) if movie.id: exists = Db.query(Movie).filter_by(movieDb=movie.id).first() else: exists = Db.query(Movie).filter_by(imdb=movie.imdb).first() if exists: log.info("Movie already exists, do update.") # Delete old qualities for x in exists.queue: x.active = False Db.flush() new = exists else: new = Movie() Db.add(new) # Update the stuff new.status = u"want" new.name = movie.name new.imdb = movie.imdb new.movieDb = movie.id new.quality = quality new.year = year if year and movie.year == "None" else movie.year Db.flush() # Add qualities to the queue quality = Db.query(QualityTemplate).filter_by(id=quality).one() for type in quality.types: queue = MovieQueue() queue.qualityType = type.type queue.movieId = new.id queue.order = type.order queue.active = True queue.completed = False queue.waitFor = 0 if type.markComplete else quality.waitFor queue.markComplete = type.markComplete Db.add(queue) Db.flush() # Get xml from themoviedb and save to cache self.searchers.get("movie").getExtraInfo(new.id, overwrite=True) # gogo find nzb for added movie via Cron self.cron.get("yarr").forceCheck(new.id) self.flash.add("movie-" + str(new.id), '"%s" (%s) added.' % (new.name, new.year))
def _addMovie(self, movie, quality, year=None): if cherrypy.config.get('config').get('XBMC', 'dbpath'): for root, dirs, files in os.walk( cherrypy.config.get('config').get('XBMC', 'dbpath')): for file in files: if file.startswith('MyVideos'): dbfile = os.path.join(root, file) if dbfile: #------Opening connection to XBMC DB------ connXbmc = MySqlite.connect(dbfile) if connXbmc: log.debug('Checking if movie exists in XBMC by IMDB id:' + movie.imdb) connXbmc.row_factory = MySqlite.Row cXbmc = connXbmc.cursor() cXbmc.execute('select c09 from movie where c09="' + movie.imdb + '"') #------End of Opening connection to XBMC DB------ inXBMC = False for rowXbmc in cXbmc: # do a final check just to be sure log.debug('Found in XBMC:' + rowXbmc["c09"]) if movie.imdb == rowXbmc["c09"]: inXBMC = True else: inXBMC = False cXbmc.close() if inXBMC: log.info('Movie already exists in XBMC, skipping.') return else: log.info( 'Could not connect to the XBMC database at ' + cherrypy.config.get('config').get('XBMC', 'dbpath')) else: log.info('Could not find the XBMC MyVideos db at ' + cherrypy.config.get('config').get('XBMC', 'dbpath')) log.info('Adding movie to database: %s' % movie.name) if movie.id: exists = Db.query(Movie).filter_by(movieDb=movie.id).first() else: exists = Db.query(Movie).filter_by(imdb=movie.imdb).first() if exists: log.info('Movie already exists, do update.') # Delete old qualities for x in exists.queue: x.active = False Db.flush() new = exists else: new = Movie() Db.add(new) # Update the stuff new.status = u'want' new.name = movie.name new.imdb = movie.imdb new.movieDb = movie.id new.quality = quality new.year = year if year and movie.year == 'None' else movie.year Db.flush() # Add qualities to the queue quality = Db.query(QualityTemplate).filter_by(id=quality).one() for type in quality.types: queue = MovieQueue() queue.qualityType = type.type queue.movieId = new.id queue.order = type.order queue.active = True queue.completed = False queue.waitFor = 0 if type.markComplete else quality.waitFor queue.markComplete = type.markComplete Db.add(queue) Db.flush() #Get xml from themoviedb and save to cache self.searchers.get('movie').getExtraInfo(new.id, overwrite=True) #gogo find nzb for added movie via Cron self.cron.get('yarr').forceCheck(new.id) self.flash.add('movie-' + str(new.id), '"%s" (%s) added.' % (new.name, new.year))
def _addMovie(self, movie, quality, year = None): if cherrypy.config.get('config').get('XBMC', 'dbpath'): for root, dirs, files in os.walk(cherrypy.config.get('config').get('XBMC', 'dbpath')): for file in files: if file.startswith('MyVideos'): dbfile = os.path.join(root, file) if dbfile: #------Opening connection to XBMC DB------ connXbmc = MySqlite.connect(dbfile) if connXbmc: log.debug('Checking if movie exists in XBMC by IMDB id:' + movie.imdb) connXbmc.row_factory = MySqlite.Row cXbmc = connXbmc.cursor() cXbmc.execute('select c09 from movie where c09="' + movie.imdb + '"') #------End of Opening connection to XBMC DB------ inXBMC = False for rowXbmc in cXbmc: # do a final check just to be sure log.debug('Found in XBMC:' + rowXbmc["c09"]) if movie.imdb == rowXbmc["c09"]: inXBMC = True else: inXBMC = False cXbmc.close() if inXBMC: log.info('Movie already exists in XBMC, skipping.') return else: log.info('Could not connect to the XBMC database at ' + cherrypy.config.get('config').get('XBMC', 'dbpath')) else: log.info('Could not find the XBMC MyVideos db at ' + cherrypy.config.get('config').get('XBMC', 'dbpath')) log.info('Adding movie to database: %s' % movie.name) if movie.id: exists = Db.query(Movie).filter_by(movieDb = movie.id).first() else: exists = Db.query(Movie).filter_by(imdb = movie.imdb).first() if exists: log.info('Movie already exists, do update.') # Delete old qualities for x in exists.queue: x.active = False Db.flush() new = exists else: new = Movie() Db.add(new) # Update the stuff new.status = u'want' new.name = movie.name new.imdb = movie.imdb new.movieDb = movie.id new.quality = quality new.year = year if year and movie.year == 'None' else movie.year Db.flush() # Add qualities to the queue quality = Db.query(QualityTemplate).filter_by(id = quality).one() for type in quality.types: queue = MovieQueue() queue.qualityType = type.type queue.movieId = new.id queue.order = type.order queue.active = True queue.completed = False queue.waitFor = 0 if type.markComplete else quality.waitFor queue.markComplete = type.markComplete Db.add(queue) Db.flush() #Get xml from themoviedb and save to cache self.searchers.get('movie').getExtraInfo(new.id, overwrite = True) #gogo find nzb for added movie via Cron self.cron.get('yarr').forceCheck(new.id) self.flash.add('movie-' + str(new.id), '"%s" (%s) added.' % (new.name, new.year))