Ejemplo n.º 1
0
 def add(self, url, content_type, label=None, thumb=''):
     if label is None:
         label = url
     label = unquote(label)
     thumb = unquote(thumb)
     execute = 'INSERT INTO {0!s} (addon_id, url, content_type, label, thumbnail) VALUES (?, ?, ?, ?, ?)'.format(
         self.TABLE)
     inserted = DATABASE.execute(
         execute, (self.ID, str(url), str(content_type), label, thumb))
     if inserted == 1:
         execute = 'SELECT COUNT(*) FROM {0!s} WHERE addon_id=?'.format(
             self.TABLE)
         result = int(DATABASE.fetch(execute, (self.ID, ))[0][0])
         if result > self.size_limit():
             execute = 'DELETE FROM {0!s} WHERE ROWID = (SELECT MIN(ROWID) FROM {0!s}) AND addon_id=?'.format(
                 self.TABLE)
             result, rowcount = DATABASE.execute_w_rowcount(
                 execute, (self.ID, ))
             if rowcount < 1:
                 execute = 'DELETE * FROM {0!s} WHERE addon_id=?'.format(
                     self.TABLE)
                 result, rowcount = DATABASE.execute_w_rowcount(
                     execute, (self.ID, ))
                 if rowcount < 1:
                     result = DATABASE.execute('DROP TABLE {0!s}'.format(
                         self.TABLE))
                     self.vacuum()
                     self.create_table()
             if rowcount > 0:
                 self.vacuum()
Ejemplo n.º 2
0
 def delete_row_id(self, row_id):
     execute = 'DELETE FROM {0!s} WHERE id=? AND addon_id=?'.format(
         self.TABLE)
     result, rowcount = DATABASE.execute_w_rowcount(execute,
                                                    (row_id, self.ID))
     if result != 1:
         kodi.notify(msg=kodi.i18n('delete_failed'), sound=False)
     return result, rowcount
Ejemplo n.º 3
0
 def delete_url(self, url):
     execute = 'DELETE FROM {0!s} WHERE url=? AND addon_id=?'.format(
         self.TABLE)
     result, rowcount = DATABASE.execute_w_rowcount(execute, (url, self.ID))
     if result != 1:
         kodi.notify(msg=kodi.i18n('delete_failed'), sound=False)
     if rowcount > 0:
         self.vacuum()
     return result, rowcount