Failsafe incase view is named after existing tag
After the initial sync already completed.
This commit is contained in:
parent
77dd006f21
commit
b61b8ae894
1 changed files with 42 additions and 16 deletions
|
@ -852,26 +852,52 @@ class Kodidb_Functions():
|
||||||
|
|
||||||
if self.kodiversion in (15, 16):
|
if self.kodiversion in (15, 16):
|
||||||
# Kodi Isengard, Jarvis
|
# Kodi Isengard, Jarvis
|
||||||
query = ' '.join((
|
try:
|
||||||
|
query = ' '.join((
|
||||||
|
|
||||||
"UPDATE tag_link",
|
"UPDATE tag_link",
|
||||||
"SET tag_id = ?",
|
"SET tag_id = ?",
|
||||||
"WHERE media_id = ?",
|
"WHERE media_id = ?",
|
||||||
"AND media_type = ?",
|
"AND media_type = ?",
|
||||||
"AND tag_id = ?"
|
"AND tag_id = ?"
|
||||||
))
|
))
|
||||||
cursor.execute(query, (newtag, kodiid, mediatype, oldtag,))
|
cursor.execute(query, (newtag, kodiid, mediatype, oldtag,))
|
||||||
|
except Exception as e:
|
||||||
|
# The new tag we are going to apply already exists for this item
|
||||||
|
# delete current tag instead
|
||||||
|
self.logMsg("Exception: %s" % e, 1)
|
||||||
|
query = ' '.join((
|
||||||
|
|
||||||
|
"DELETE FROM tag_link",
|
||||||
|
"WHERE media_id = ?",
|
||||||
|
"AND media_type = ?",
|
||||||
|
"AND tag_id = ?"
|
||||||
|
))
|
||||||
|
cursor.execute(query, (kodiid, mediatype, oldtag,))
|
||||||
else:
|
else:
|
||||||
# Kodi Helix
|
# Kodi Helix
|
||||||
query = ' '.join((
|
try:
|
||||||
|
query = ' '.join((
|
||||||
|
|
||||||
"UPDATE taglinks",
|
"UPDATE taglinks",
|
||||||
"SET idTag = ?",
|
"SET idTag = ?",
|
||||||
"WHERE idMedia = ?",
|
"WHERE idMedia = ?",
|
||||||
"AND media_type = ?",
|
"AND media_type = ?",
|
||||||
"AND idTag = ?"
|
"AND idTag = ?"
|
||||||
))
|
))
|
||||||
cursor.execute(query, (newtag, kodiid, mediatype, oldtag,))
|
cursor.execute(query, (newtag, kodiid, mediatype, oldtag,))
|
||||||
|
except Exception as e:
|
||||||
|
# The new tag we are going to apply already exists for this item
|
||||||
|
# delete current tag instead
|
||||||
|
self.logMsg("Exception: %s" % e, 1)
|
||||||
|
query = ' '.join((
|
||||||
|
|
||||||
|
"DELETE FROM taglinks",
|
||||||
|
"WHERE idMedia = ?",
|
||||||
|
"AND media_type = ?",
|
||||||
|
"AND idTag = ?"
|
||||||
|
))
|
||||||
|
cursor.execute(query, (kodiid, mediatype, oldtag,))
|
||||||
|
|
||||||
def removeTag(self, kodiid, tagname, mediatype):
|
def removeTag(self, kodiid, tagname, mediatype):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue