예제 #1
0
    def _rate_song(self):

        conn = kodiSQL('music')
        cursor = conn.cursor()
        query = "SELECT rating FROM song WHERE idSong = ?"
        cursor.execute(query, (self.kodi_id, ))
        try:
            value = cursor.fetchone()[0]
            current_value = int(round(float(value), 0))
        except TypeError:
            pass
        else:
            new_value = dialog("numeric", 0, lang(30411), str(current_value))
            if new_value > -1:

                new_value = int(new_value)
                if new_value > 5:
                    new_value = 5

                if settings('enableUpdateSongRating') == "true":
                    musicutils.updateRatingToFile(new_value,
                                                  self.api.get_file_path())

                query = "UPDATE song SET rating = ? WHERE idSong = ?"
                cursor.execute(query, (
                    new_value,
                    self.kodi_id,
                ))
                conn.commit()
        finally:
            cursor.close()
예제 #2
0
            if options[ret] == utils.language(30406):
                emby.updateUserRating(plexid, favourite=False)
            if options[ret] == utils.language(30407):
                kodiconn = utils.kodiSQL('music')
                kodicursor = kodiconn.cursor()
                query = ' '.join(
                    ("SELECT rating", "FROM song", "WHERE idSong = ?"))
                kodicursor.execute(query, (itemid, ))
                currentvalue = int(round(float(kodicursor.fetchone()[0]), 0))
                newvalue = xbmcgui.Dialog().numeric(
                    0, "Set custom song rating (0-5)", str(currentvalue))
                if newvalue:
                    newvalue = int(newvalue)
                    if newvalue > 5: newvalue = "5"
                    if utils.settings('enableUpdateSongRating') == "true":
                        musicutils.updateRatingToFile(newvalue,
                                                      API.getFilePath())
                    if utils.settings('enableExportSongRating') == "true":
                        like, favourite, deletelike = musicutils.getEmbyRatingFromKodiRating(
                            newvalue)
                        emby.updateUserRating(plexid, like, favourite,
                                              deletelike)
                    query = ' '.join(
                        ("UPDATE song", "SET rating = ?", "WHERE idSong = ?"))
                    kodicursor.execute(query, (
                        newvalue,
                        itemid,
                    ))
                    kodiconn.commit()

            if options[ret] == utils.language(30408):
                #Open addon settings