Exemple #1
0
    def loadDB(self):
        log.info('Loading database...')
        settings = QSettings()
        dbfile = unicode(settings.value('database_file').toString())
        if not dbfile:
            dbfile = join(utils.smewtUserDirectory(), smewt.APP_NAME + '.database')
            settings.setValue('database_file', QVariant(dbfile))

        self.database = VersionedMediaGraph()
        try:
            self.database.load(dbfile)
        except:
            log.warning('Could not load database %s', dbfile)
    def savePoster(self, posterUrl, localId):
        imageDir = smewtUserDirectory('images')

        hiresFilename = os.path.join(imageDir, '%s_hires.jpg' % localId)
        open(hiresFilename, 'wb').write(urlopen(posterUrl).read())

        # lores = 80px high
        loresFilename = os.path.join(imageDir, '%s_lores.jpg' % localId)
        image = QImage()
        image.load(hiresFilename)
        image.scaledToHeight(80, Qt.SmoothTransformation).save(loresFilename)

        return loresFilename, hiresFilename