Exemplo n.º 1
0
 def set_stream_continuity(self, profile_guid, videoid, value):
     """Update or insert a stream continuity value to current profile"""
     # Update or insert approach, if there is no updated row then insert new one
     value = common.convert_to_string(value)
     date_last_modified = common.convert_to_string(datetime.now())
     if self.is_mysql_database:
         query = db_utils.mysql_insert_or_update(
             'stream_continuity', ['ProfileGuid', 'VideoID'],
             ['Value', 'DateLastModified'])
         self._execute_non_query(
             query, (profile_guid, videoid, value, date_last_modified),
             multi=True)
     else:
         update_query = ('UPDATE stream_continuity '
                         'SET Value = ?, DateLastModified = ? '
                         'WHERE ProfileGuid = ? AND VideoID = ?')
         cur = self._execute_query(
             update_query,
             (value, date_last_modified, profile_guid, videoid))
         if cur.rowcount == 0:
             insert_query = (
                 'INSERT INTO stream_continuity '
                 '(ProfileGuid, VideoID, Value, DateLastModified) '
                 'VALUES (?, ?, ?, ?)')
             self._execute_non_query(
                 insert_query,
                 (profile_guid, videoid, value, date_last_modified))
 def set_value(self, key, value, table=db_utils.TABLE_SHARED_APP_CONF):
     """
     Store a single value to database
     :param key: The key to store the value
     :param value: Value to save
     :param table: Table map
     """
     table_name = table[0]
     table_columns = table[1]
     # Update or insert approach, if there is no updated row then insert new one (no id changes)
     query = db_utils.mysql_insert_or_update(table_name, [table_columns[0]], [table_columns[1]])
     value = common.convert_to_string(value)
     self._execute_non_query(query, (key, value), multi=True)
Exemplo n.º 3
0
 def set_movie(self, movieid, file_path, nfo_export):
     """Update or insert a movie"""
     # Update or insert approach, if there is no updated row then insert new one
     if self.is_mysql_database:
         query = db_utils.mysql_insert_or_update('video_lib_movies', ['MovieID'],
                                                 ['FilePath', 'NfoExport'])
         self._execute_non_query(query, (movieid, file_path, str(nfo_export)), multi=True)
     else:
         update_query = ('UPDATE video_lib_movies SET FilePath = ?, NfoExport = ? '
                         'WHERE MovieID = ?')
         cur = self._execute_query(update_query, (file_path, str(nfo_export), movieid))
         if cur.rowcount == 0:
             insert_query = ('INSERT INTO video_lib_movies (MovieID, FilePath, NfoExport) '
                             'VALUES (?, ?, ?)')
             self._execute_non_query(insert_query, (movieid, file_path, str(nfo_export)))
Exemplo n.º 4
0
 def set_profile(self, guid, sort_order):
     """Update or Insert a profile"""
     # Update or insert approach,
     # if there is no updated row then insert new one (no id changes)
     if self.is_mysql_database:
         query = db_utils.mysql_insert_or_update(
             'profiles', ['Guid'], ['SortOrder'])
         self._execute_non_query(query, (guid, sort_order), multi=True)
     else:
         data = db_utils.sql_filtered_update('profiles', ['SortOrder'],
                                             ['Guid'],
                                             [sort_order, guid])
         cur = self._execute_query(data[0], data[1])
         if cur.rowcount == 0:
             data = db_utils.sql_filtered_insert(
                 'profiles', ['Guid', 'SortOrder'], [guid, sort_order])
             self._execute_non_query(data[0], data[1])
Exemplo n.º 5
0
 def set_tvshow(self, tvshowid, nfo_export, exclude_update):
     """Update or insert a tvshow"""
     # Update or insert approach, if there is no updated row then insert new one
     if self.is_mysql_database:
         query = db_utils.mysql_insert_or_update('video_lib_tvshows', ['TvShowID'],
                                                 ['ExcludeUpdate', 'NfoExport'])
         self._execute_non_query(query, (tvshowid, str(exclude_update), str(nfo_export)),
                                 multi=True)
     else:
         update_query = ('UPDATE video_lib_tvshows SET NfoExport = ?, ExcludeUpdate = ? '
                         'WHERE TvShowID = ?')
         cur = self._execute_query(update_query, (str(nfo_export),
                                                  str(exclude_update), tvshowid))
         if cur.rowcount == 0:
             insert_query = \
                 ('INSERT INTO video_lib_tvshows (TvShowID, NfoExport, ExcludeUpdate) '
                  'VALUES (?, ?, ?)')
             self._execute_non_query(insert_query, (tvshowid,
                                                    str(nfo_export),
                                                    str(exclude_update)))
Exemplo n.º 6
0
 def set_watched_status(self, profile_guid, videoid, value):
     """Update or insert the watched status override value to current profile"""
     # Update or insert approach, if there is no updated row then insert new one
     value = common.convert_to_string(value)
     if self.is_mysql_database:
         query = db_utils.mysql_insert_or_update('watched_status_override',
                                                 ['ProfileGuid', 'VideoID'],
                                                 ['Value'])
         self._execute_non_query(query, (profile_guid, videoid, value),
                                 multi=True)
     else:
         update_query = ('UPDATE watched_status_override '
                         'SET Value = ? '
                         'WHERE ProfileGuid = ? AND VideoID = ?')
         cur = self._execute_query(update_query, (value, profile_guid, videoid))
         if cur.rowcount == 0:
             insert_query = ('INSERT INTO watched_status_override '
                             '(ProfileGuid, VideoID, Value) '
                             'VALUES (?, ?, ?)')
             self._execute_non_query(insert_query, (profile_guid, videoid, value))