def fillUpdateDB( self ) : """ Copies the Shows from the database to a temporary database, for determining what shows to update. :rtype: None """ self.updateDB = copy.deepcopy( self.currentDB ) backends = dict() ## Group every Show into the backend used. for Show in self.updateDB.database : Show.clearEpisodes() if backends.has_key( Show.backend ) == False : backends[ Show.backend ] = [ copy.deepcopy(Show) ] else : backends[ Show.backend ].append( copy.deepcopy(Show) ) for backend, Shows in backends.iteritems() : exec( 'backend = ' + backend + '()' ) ## Download every Show in one backend before moving on to another backend. dictionary = backend.downloadShowList( Shows ) DB = backend.getShowDetails( dictionary ) ## Populate the updateDB for Show in DB.database : show = self.updateDB.getShow( Show ) for Season in Show.seasons : show.addSeason( Season ) return self.incrementalUpdate()
def getShowDetails(self, filesystemDir, MatchingShow): """ Retrieves Show details. :param filesystemDir: Path to filetypes.xml :type filesystemDir: string :param Show: Show object to add file name details to. :type Show: :class:`api.dbapi.Show` """ if MatchingShow == None: return None #FIXME: Show should not be a list (but resolved after self.getMatchingShows() ). seasonNumber = self.getSeason() episodeNumber = self.getEpisode() try: NewSeason = MatchingShow.getSeason(Season(seasonNumber)) NewEpisode = NewSeason.getEpisode( Episode(episodeNumber, 'title', 'airdate')) NewSeason.episodes = [] except AttributeError: print "The episode does not exist. Update database!" return None ## Episode does not exist. if NewEpisode == None: return None #FIXME: Proper regex function to get file suffix. self.fileSuffix = self.fileName[-4:] NewShow = Show(MatchingShow.name, MatchingShow.duration, MatchingShow.backend, MatchingShow.url) NewShow.addEpisode(NewEpisode, NewSeason) return NewShow
def getShowDetails (self, filesystemDir, MatchingShow) : """ Retrieves Show details. :param filesystemDir: Path to filetypes.xml :type filesystemDir: string :param Show: Show object to add file name details to. :type Show: :class:`api.dbapi.Show` """ if MatchingShow == None : return None #FIXME: Show should not be a list (but resolved after self.getMatchingShows() ). seasonNumber = self.getSeason() episodeNumber = self.getEpisode() try : NewSeason = MatchingShow.getSeason( Season( seasonNumber ) ) NewEpisode = NewSeason.getEpisode( Episode( episodeNumber , 'title', 'airdate' )) NewSeason.episodes = [ ] except AttributeError : print "The episode does not exist. Update database!" return None ## Episode does not exist. if NewEpisode == None : return None #FIXME: Proper regex function to get file suffix. self.fileSuffix = self.fileName[-4:] NewShow = Show( MatchingShow.name, MatchingShow.duration, MatchingShow.backend, MatchingShow.url ) NewShow.addEpisode( NewEpisode, NewSeason ) return NewShow
def compareDetails( self, currentShow, newShow ) : """ Compares two Shows for differences. :param currentShow: Old show :type currentShow: :class:`api.dbapi.Show` :param newShow: New show :type newShow: :class:`api.dbapi.Show` :returns: Updated show. :rtype: :class:`api.dbapi.Show` """ editedShow = Show( currentShow.name, currentShow.duration, currentShow.backend, currentShow.url ) for newSeason in newShow.seasons : currentSeason = currentShow.getSeason( newSeason ) if currentSeason == None : editedShow.addSeason( newSeason ) else : editedShow.addSeason( self.compareSeasons( currentSeason, newSeason ) ) return editedShow