Move update user rating to read_embyserver
It's more appropriate
This commit is contained in:
parent
ae7131a7c1
commit
f33692f2f9
3 changed files with 44 additions and 10 deletions
|
@ -94,15 +94,15 @@ if __name__ == '__main__':
|
|||
ret = xbmcgui.Dialog().select(header, options)
|
||||
if ret != -1:
|
||||
if options[ret] == utils.language(30402):
|
||||
API.updateUserRating(embyid, deletelike=True)
|
||||
emby.updateUserRating(embyid, deletelike=True)
|
||||
if options[ret] == utils.language(30403):
|
||||
API.updateUserRating(embyid, like=True)
|
||||
emby.updateUserRating(embyid, like=True)
|
||||
if options[ret] == utils.language(30404):
|
||||
API.updateUserRating(embyid, like=False)
|
||||
emby.updateUserRating(embyid, like=False)
|
||||
if options[ret] == utils.language(30405):
|
||||
API.updateUserRating(embyid, favourite=True)
|
||||
emby.updateUserRating(embyid, favourite=True)
|
||||
if options[ret] == utils.language(30406):
|
||||
API.updateUserRating(embyid, favourite=False)
|
||||
emby.updateUserRating(embyid, favourite=False)
|
||||
if options[ret] == utils.language(30407):
|
||||
kodiconn = utils.kodiSQL('music')
|
||||
kodicursor = kodiconn.cursor()
|
||||
|
@ -117,7 +117,7 @@ if __name__ == '__main__':
|
|||
musicutils.updateRatingToFile(newvalue, API.getFilePath())
|
||||
if utils.settings('enableExportSongRating') == "true":
|
||||
like, favourite, deletelike = musicutils.getEmbyRatingFromKodiRating(newvalue)
|
||||
API.updateUserRating(embyid, like, favourite, deletelike)
|
||||
emby.updateUserRating(embyid, like, favourite, deletelike)
|
||||
query = ' '.join(( "UPDATE song","SET rating = ?", "WHERE idSong = ?" ))
|
||||
kodicursor.execute(query, (newvalue,itemid,))
|
||||
kodiconn.commit()
|
||||
|
|
|
@ -3,13 +3,19 @@
|
|||
#################################################################################################
|
||||
|
||||
import os
|
||||
import xbmc, xbmcaddon, xbmcvfs
|
||||
import utils
|
||||
|
||||
import xbmc
|
||||
import xbmcaddon
|
||||
import xbmcvfs
|
||||
|
||||
from mutagen.flac import FLAC, Picture
|
||||
from mutagen.id3 import ID3
|
||||
from mutagen import id3
|
||||
import base64
|
||||
|
||||
import read_embyserver as embyserver
|
||||
import utils
|
||||
|
||||
#################################################################################################
|
||||
|
||||
# Helper for the music library, intended to fix missing song ID3 tags on Emby
|
||||
|
@ -62,6 +68,9 @@ def getEmbyRatingFromKodiRating(rating):
|
|||
return(like, favourite, deletelike)
|
||||
|
||||
def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enableimportsongrating, enableexportsongrating, enableupdatesongrating):
|
||||
|
||||
emby = embyserver.Read_EmbyServer()
|
||||
|
||||
previous_values = None
|
||||
filename = API.getFilePath()
|
||||
rating = 0
|
||||
|
@ -163,7 +172,7 @@ def getAdditionalSongTags(embyid, emby_rating, API, kodicursor, emby_db, enablei
|
|||
# sync details to emby server. Translation needed between ID3 rating and emby likes/favourites:
|
||||
like, favourite, deletelike = getEmbyRatingFromKodiRating(rating)
|
||||
utils.window("ignore-update-%s" %embyid, "true") #set temp windows prop to ignore the update from webclient update
|
||||
API.updateUserRating(embyid, like, favourite, deletelike)
|
||||
emby.updateUserRating(embyid, like, favourite, deletelike)
|
||||
|
||||
return (rating, comment, hasEmbeddedCover)
|
||||
|
||||
|
|
|
@ -574,3 +574,28 @@ class Read_EmbyServer():
|
|||
sorted_items.setdefault(mediatype, []).append(item)
|
||||
|
||||
return sorted_items
|
||||
|
||||
def updateUserRating(self, itemid, like=None, favourite=None, deletelike=False):
|
||||
# Updates the user rating to Emby
|
||||
doUtils = self.doUtils
|
||||
|
||||
if favourite:
|
||||
url = "{server}/emby/Users/{UserId}/FavoriteItems/%s?format=json" % itemid
|
||||
doUtils(url, type="POST")
|
||||
elif favourite == False:
|
||||
url = "{server}/emby/Users/{UserId}/FavoriteItems/%s?format=json" % itemid
|
||||
doUtils(url, type="DELETE")
|
||||
|
||||
if not deletelike and like:
|
||||
url = "{server}/emby/Users/{UserId}/Items/%s/Rating?Likes=true&format=json" % itemid
|
||||
doUtils(url, type="POST")
|
||||
elif not deletelike and like == False:
|
||||
url = "{server}/emby/Users/{UserId}/Items/%s/Rating?Likes=false&format=json" % itemid
|
||||
doUtil(url, type="POST")
|
||||
elif deletelike:
|
||||
url = "{server}/emby/Users/{UserId}/Items/%s/Rating?format=json" % itemid
|
||||
doUtils(url, type="DELETE")
|
||||
|
||||
self.logMsg("Update user rating to emby for itemid: %s "
|
||||
"| like: %s | favourite: %s | deletelike: %s"
|
||||
% (itemid, like, favourite, deletelike), 1)
|
Loading…
Reference in a new issue