Merge branch 'hotfixes' into translations

This commit is contained in:
Croneter 2018-04-05 15:31:40 +02:00
commit 0fd65b7ee6
5 changed files with 259 additions and 1000 deletions

File diff suppressed because it is too large Load diff

View file

@ -1290,7 +1290,20 @@ class Music(Items):
checksum=checksum) checksum=checksum)
# Process the album info # Process the album info
if v.KODIVERSION >= 17: if v.KODIVERSION >= 18:
# Kodi Leia
query = '''
UPDATE album
SET strArtistDisp = ?, iYear = ?, strGenres = ?, strReview = ?,
strImage = ?, iUserrating = ?, lastScraped = ?,
strReleaseType = ?, strLabel = ?, bCompilation = ?
WHERE idAlbum = ?
'''
kodicursor.execute(query, (artistname, year, self.genre, bio,
thumb, rating, lastScraped,
v.KODI_TYPE_ALBUM, studio,
self.compilation, albumid))
elif v.KODIVERSION == 17:
# Kodi Krypton # Kodi Krypton
query = ''' query = '''
UPDATE album UPDATE album
@ -1316,30 +1329,6 @@ class Music(Items):
thumb, rating, lastScraped, thumb, rating, lastScraped,
v.KODI_TYPE_ALBUM, studio, v.KODI_TYPE_ALBUM, studio,
self.compilation, albumid)) self.compilation, albumid))
elif v.KODIVERSION == 15:
# Kodi Isengard
query = '''
UPDATE album
SET strArtists = ?, iYear = ?, strGenres = ?, strReview = ?,
strImage = ?, iRating = ?, lastScraped = ?, dateAdded = ?,
strReleaseType = ?, strLabel = ?
WHERE idAlbum = ?
'''
kodicursor.execute(query, (artistname, year, self.genre, bio,
thumb, rating, lastScraped, dateadded,
v.KODI_TYPE_ALBUM, studio, albumid))
else:
# Kodi Helix
query = '''
UPDATE album
SET strArtists = ?, iYear = ?, strGenres = ?, strReview = ?,
strImage = ?, iRating = ?, lastScraped = ?, dateAdded = ?,
strLabel = ?
WHERE idAlbum = ?
'''
kodicursor.execute(query, (artistname, year, self.genre, bio,
thumb, rating, lastScraped, dateadded,
studio, albumid))
# Associate the parentid for plex reference # Associate the parentid for plex reference
parent_id = api.parent_plex_id() parent_id = api.parent_plex_id()
@ -1400,7 +1389,7 @@ class Music(Items):
kodicursor.execute(query, (artistid, name, year)) kodicursor.execute(query, (artistid, name, year))
# Update plex reference with parentid # Update plex reference with parentid
plex_db.updateParentId(artist_id, albumid) plex_db.updateParentId(artist_id, albumid)
# Add genres if v.KODIVERSION < 18:
self.kodi_db.addMusicGenres(albumid, self.genres, v.KODI_TYPE_ALBUM) self.kodi_db.addMusicGenres(albumid, self.genres, v.KODI_TYPE_ALBUM)
# Update artwork # Update artwork
artwork.modify_artwork(artworks, albumid, v.KODI_TYPE_ALBUM, kodicursor) artwork.modify_artwork(artworks, albumid, v.KODI_TYPE_ALBUM, kodicursor)
@ -1517,18 +1506,33 @@ class Music(Items):
kodicursor.execute(query, (path, '123', pathid)) kodicursor.execute(query, (path, '123', pathid))
# Update the song entry # Update the song entry
if v.KODIVERSION >= 18:
# Kodi Leia
query = ''' query = '''
UPDATE song UPDATE song
SET idAlbum = ?, strArtists = ?, strGenres = ?, strTitle = ?, SET idAlbum = ?, strArtistDisp = ?, strGenres = ?,
iTrack = ?, iDuration = ?, iYear = ?, strFilename = ?, strTitle = ?, iTrack = ?, iDuration = ?, iYear = ?,
iTimesPlayed = ?, lastplayed = ?, rating = ?, comment = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?,
mood = ? rating = ?, comment = ?, mood = ?
WHERE idSong = ? WHERE idSong = ?
''' '''
kodicursor.execute(query, (albumid, artists, genre, title, track, kodicursor.execute(query, (albumid, artists, genre, title,
duration, year, filename, playcount, track, duration, year, filename,
dateplayed, rating, comment, mood, playcount, dateplayed, rating,
songid)) comment, mood, songid))
else:
query = '''
UPDATE song
SET idAlbum = ?, strArtists = ?, strGenres = ?,
strTitle = ?, iTrack = ?, iDuration = ?, iYear = ?,
strFilename = ?, iTimesPlayed = ?, lastplayed = ?,
rating = ?, comment = ?, mood = ?
WHERE idSong = ?
'''
kodicursor.execute(query, (albumid, artists, genre, title,
track, duration, year, filename,
playcount, dateplayed, rating,
comment, mood, songid))
# Update the checksum in plex table # Update the checksum in plex table
plex_db.updateReference(itemid, checksum) plex_db.updateReference(itemid, checksum)
@ -1615,18 +1619,33 @@ class Music(Items):
dateadded)) dateadded))
# Create the song entry # Create the song entry
if v.KODIVERSION >= 18:
# Kodi Leia
query = ''' query = '''
INSERT INTO song( INSERT INTO song(
idSong, idAlbum, idPath, strArtists, strGenres, strTitle, idSong, idAlbum, idPath, strArtistDisp, strGenres,
iTrack, iDuration, iYear, strFileName, strTitle, iTrack, iDuration, iYear, strFileName,
strMusicBrainzTrackID, iTimesPlayed, lastplayed, strMusicBrainzTrackID, iTimesPlayed, lastplayed,
rating, iStartOffset, iEndOffset, mood) rating, iStartOffset, iEndOffset, mood)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''' '''
kodicursor.execute( kodicursor.execute(
query, (songid, albumid, pathid, artists, genre, title, track, query, (songid, albumid, pathid, artists, genre, title,
duration, year, filename, musicBrainzId, playcount, track, duration, year, filename, musicBrainzId,
dateplayed, rating, 0, 0, mood)) playcount, dateplayed, rating, 0, 0, mood))
else:
query = '''
INSERT INTO song(
idSong, idAlbum, idPath, strArtists, strGenres,
strTitle, iTrack, iDuration, iYear, strFileName,
strMusicBrainzTrackID, iTimesPlayed, lastplayed,
rating, iStartOffset, iEndOffset, mood)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
'''
kodicursor.execute(
query, (songid, albumid, pathid, artists, genre, title,
track, duration, year, filename, musicBrainzId,
playcount, dateplayed, rating, 0, 0, mood))
# Create the reference in plex table # Create the reference in plex table
plex_db.addReference(itemid, plex_db.addReference(itemid,
@ -1637,7 +1656,7 @@ class Music(Items):
parent_id=albumid, parent_id=albumid,
checksum=checksum, checksum=checksum,
view_id=viewid) view_id=viewid)
if v.KODIVERSION < 18:
# Link song to album # Link song to album
query = ''' query = '''
INSERT OR REPLACE INTO albuminfosong( INSERT OR REPLACE INTO albuminfosong(
@ -1645,7 +1664,6 @@ class Music(Items):
VALUES (?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?)
''' '''
kodicursor.execute(query, (songid, albumid, track, title, duration)) kodicursor.execute(query, (songid, albumid, track, title, duration))
# Link song to artists # Link song to artists
artist_loop = [{ artist_loop = [{
'Name': api.grandparent_title(), 'Name': api.grandparent_title(),

View file

@ -869,28 +869,20 @@ class KodiDBMethods(object):
return seasonid return seasonid
def addArtist(self, name, musicbrainz): def addArtist(self, name, musicbrainz):
query = '''
query = ' '.join(( SELECT idArtist, strArtist
FROM artist
"SELECT idArtist, strArtist", WHERE strMusicBrainzArtistID = ?
"FROM artist", '''
"WHERE strMusicBrainzArtistID = ?"
))
self.cursor.execute(query, (musicbrainz,)) self.cursor.execute(query, (musicbrainz,))
try: try:
result = self.cursor.fetchone() result = self.cursor.fetchone()
artistid = result[0] artistid = result[0]
artistname = result[1] artistname = result[1]
except TypeError: except TypeError:
query = '''
query = ' '.join(( SELECT idArtist FROM artist WHERE strArtist = ? COLLATE NOCASE
'''
"SELECT idArtist",
"FROM artist",
"WHERE strArtist = ?",
"COLLATE NOCASE"
))
self.cursor.execute(query, (name,)) self.cursor.execute(query, (name,))
try: try:
artistid = self.cursor.fetchone()[0] artistid = self.cursor.fetchone()[0]
@ -899,113 +891,87 @@ class KodiDBMethods(object):
# [Missing Tag] strMusicBrainzArtistID: Artist Tag Missing # [Missing Tag] strMusicBrainzArtistID: Artist Tag Missing
if v.KODIVERSION >= 17: if v.KODIVERSION >= 17:
self.cursor.execute( self.cursor.execute(
"select coalesce(max(idArtist),1) from artist") "SELECT COALESCE(MAX(idArtist),1) FROM artist")
else: else:
self.cursor.execute( self.cursor.execute(
"select coalesce(max(idArtist),0) from artist") "SELECT COALESCE(MAX(idArtist),0) FROM artist")
artistid = self.cursor.fetchone()[0] + 1 artistid = self.cursor.fetchone()[0] + 1
query = ( query = '''
''' INSERT INTO artist(idArtist, strArtist,
INSERT INTO artist(idArtist, strArtist, strMusicBrainzArtistID) strMusicBrainzArtistID)
VALUES (?, ?, ?) VALUES (?, ?, ?)
''' '''
)
self.cursor.execute(query, (artistid, name, musicbrainz)) self.cursor.execute(query, (artistid, name, musicbrainz))
else: else:
if artistname != name: if artistname != name:
query = "UPDATE artist SET strArtist = ? WHERE idArtist = ?" query = "UPDATE artist SET strArtist = ? WHERE idArtist = ?"
self.cursor.execute(query, (name, artistid,)) self.cursor.execute(query, (name, artistid,))
return artistid return artistid
def addAlbum(self, name, musicbrainz): def addAlbum(self, name, musicbrainz):
query = 'SELECT idAlbum FROM album WHERE strMusicBrainzAlbumID = ?'
query = ' '.join((
"SELECT idAlbum",
"FROM album",
"WHERE strMusicBrainzAlbumID = ?"
))
self.cursor.execute(query, (musicbrainz,)) self.cursor.execute(query, (musicbrainz,))
try: try:
albumid = self.cursor.fetchone()[0] albumid = self.cursor.fetchone()[0]
except TypeError: except TypeError:
# Create the album # Create the album
self.cursor.execute("select coalesce(max(idAlbum),0) from album") self.cursor.execute('SELECT COALESCE(MAX(idAlbum),0) FROM album')
albumid = self.cursor.fetchone()[0] + 1 albumid = self.cursor.fetchone()[0] + 1
query = ( query = '''
''' INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID,
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType) strReleaseType)
VALUES (?, ?, ?, ?) VALUES (?, ?, ?, ?)
''' '''
) self.cursor.execute(query, (albumid, name, musicbrainz, 'album'))
self.cursor.execute(query, (albumid, name, musicbrainz, "album"))
return albumid return albumid
def addMusicGenres(self, kodiid, genres, mediatype): def addMusicGenres(self, kodiid, genres, mediatype):
if mediatype == "album": if mediatype == "album":
# Delete current genres for clean slate # Delete current genres for clean slate
query = ' '.join(( query = 'DELETE FROM album_genre WHERE idAlbum = ?'
"DELETE FROM album_genre",
"WHERE idAlbum = ?"
))
self.cursor.execute(query, (kodiid,)) self.cursor.execute(query, (kodiid,))
for genre in genres: for genre in genres:
query = ' '.join(( query = '''
SELECT idGenre FROM genre WHERE strGenre = ? COLLATE NOCASE
"SELECT idGenre", '''
"FROM genre",
"WHERE strGenre = ?",
"COLLATE NOCASE"
))
self.cursor.execute(query, (genre,)) self.cursor.execute(query, (genre,))
try: try:
genreid = self.cursor.fetchone()[0] genreid = self.cursor.fetchone()[0]
except TypeError: except TypeError:
# Create the genre # Create the genre
self.cursor.execute("select coalesce(max(idGenre),0) from genre") query = 'SELECT COALESCE(MAX(idGenre),0) FROM genre'
self.cursor.execute(query)
genreid = self.cursor.fetchone()[0] + 1 genreid = self.cursor.fetchone()[0] + 1
query = "INSERT INTO genre(idGenre, strGenre) values(?, ?)" query = 'INSERT INTO genre(idGenre, strGenre) VALUES(?, ?)'
self.cursor.execute(query, (genreid, genre)) self.cursor.execute(query, (genreid, genre))
query = '''
query = "INSERT OR REPLACE INTO album_genre(idGenre, idAlbum) values(?, ?)" INSERT OR REPLACE INTO album_genre(idGenre, idAlbum)
VALUES (?, ?)
'''
self.cursor.execute(query, (genreid, kodiid)) self.cursor.execute(query, (genreid, kodiid))
elif mediatype == "song": elif mediatype == "song":
# Delete current genres for clean slate # Delete current genres for clean slate
query = ' '.join(( query = 'DELETE FROM song_genre WHERE idSong = ?'
"DELETE FROM song_genre",
"WHERE idSong = ?"
))
self.cursor.execute(query, (kodiid,)) self.cursor.execute(query, (kodiid,))
for genre in genres: for genre in genres:
query = ' '.join(( query = '''
SELECT idGenre FROM genre WHERE strGenre = ?
"SELECT idGenre", COLLATE NOCASE
"FROM genre", '''
"WHERE strGenre = ?",
"COLLATE NOCASE"
))
self.cursor.execute(query, (genre,)) self.cursor.execute(query, (genre,))
try: try:
genreid = self.cursor.fetchone()[0] genreid = self.cursor.fetchone()[0]
except TypeError: except TypeError:
# Create the genre # Create the genre
self.cursor.execute("select coalesce(max(idGenre),0) from genre") query = 'SELECT COALESCE(MAX(idGenre),0) FROM genre'
self.cursor.execute(query)
genreid = self.cursor.fetchone()[0] + 1 genreid = self.cursor.fetchone()[0] + 1
query = "INSERT INTO genre(idGenre, strGenre) values(?, ?)" query = 'INSERT INTO genre(idGenre, strGenre) values(?, ?)'
self.cursor.execute(query, (genreid, genre)) self.cursor.execute(query, (genreid, genre))
query = '''
query = "INSERT OR REPLACE INTO song_genre(idGenre, idSong) values(?, ?)" INSERT OR REPLACE INTO song_genre(idGenre, idSong)
VALUES (?, ?)
'''
self.cursor.execute(query, (genreid, kodiid)) self.cursor.execute(query, (genreid, kodiid))
# Krypton only stuff ############################## # Krypton only stuff ##############################

View file

@ -85,7 +85,7 @@ _DB_VIDEO_VERSION = {
15: 93, # Isengard 15: 93, # Isengard
16: 99, # Jarvis 16: 99, # Jarvis
17: 107, # Krypton 17: 107, # Krypton
18: 108 # Leia 18: 109 # Leia
} }
DB_VIDEO_PATH = try_decode(xbmc.translatePath( DB_VIDEO_PATH = try_decode(xbmc.translatePath(
"special://database/MyVideos%s.db" % _DB_VIDEO_VERSION[KODIVERSION])) "special://database/MyVideos%s.db" % _DB_VIDEO_VERSION[KODIVERSION]))
@ -96,7 +96,7 @@ _DB_MUSIC_VERSION = {
15: 52, # Isengard 15: 52, # Isengard
16: 56, # Jarvis 16: 56, # Jarvis
17: 60, # Krypton 17: 60, # Krypton
18: 62 # Leia 18: 70 # Leia
} }
DB_MUSIC_PATH = try_decode(xbmc.translatePath( DB_MUSIC_PATH = try_decode(xbmc.translatePath(
"special://database/MyMusic%s.db" % _DB_MUSIC_VERSION[KODIVERSION])) "special://database/MyMusic%s.db" % _DB_MUSIC_VERSION[KODIVERSION]))

View file

@ -74,11 +74,7 @@
<setting id="useDirectPaths" type="enum" label="30511" values="Addon(Default)|Native(Direct paths)" default="0" visible="true"/> <!-- Playback mode --> <setting id="useDirectPaths" type="enum" label="30511" values="Addon(Default)|Native(Direct paths)" default="0" visible="true"/> <!-- Playback mode -->
<setting id="streamMusic" type="bool" label="30510" default="false" visible="false" subsetting="true"/> <!-- Direct stream Music library --> <setting id="streamMusic" type="bool" label="30510" default="false" visible="false" subsetting="true"/> <!-- Direct stream Music library -->
<setting type="lsep" label="30523" visible="false"/> <!-- Music metadata options -->
<setting id="enableImportSongRating" type="bool" label="30524" default="true" visible="false"/>
<setting id="enableExportSongRating" type="bool" label="30525" default="false" visible="false" />
<setting id="kodiplextimeoffset" type="number" label="Time difference in seconds (Koditime - Plextime)" default="0" visible="false" option="int" /> <setting id="kodiplextimeoffset" type="number" label="Time difference in seconds (Koditime - Plextime)" default="0" visible="false" option="int" />
<setting id="enableUpdateSongRating" type="bool" label="30526" default="false" visible="false" />
<setting id="themoviedbAPIKey" type="text" default="19c90103adb9e98f2172c6a6a3d85dc4" visible="false"/> <setting id="themoviedbAPIKey" type="text" default="19c90103adb9e98f2172c6a6a3d85dc4" visible="false"/>
<setting id="FanArtTVAPIKey" type="text" default="639191cb0774661597f28a47e7e2bad5" visible="false"/> <setting id="FanArtTVAPIKey" type="text" default="639191cb0774661597f28a47e7e2bad5" visible="false"/>
</category> </category>
@ -136,7 +132,6 @@
<setting id="enableCoverArt" type="bool" label="30157" default="true" visible="false"/> <setting id="enableCoverArt" type="bool" label="30157" default="true" visible="false"/>
<setting id="additionalUsers" type="text" label="30528" default="" visible="false"/> <setting id="additionalUsers" type="text" label="30528" default="" visible="false"/>
<setting type="lsep" label="30534" visible="false" /> <setting type="lsep" label="30534" visible="false" />
<setting id="restartMsg" type="bool" label="30530" default="false" visible="false" />
<setting id="newContent" type="bool" label="30531" default="false" visible="false" /> <setting id="newContent" type="bool" label="30531" default="false" visible="false" />
<setting id="newvideotime" type="number" label="30532" visible="false" default="5" option="int" subsetting="true" /> <setting id="newvideotime" type="number" label="30532" visible="false" default="5" option="int" subsetting="true" />
<setting id="newmusictime" type="number" label="30533" visible="false" default="2" option="int" subsetting="true" /> <setting id="newmusictime" type="number" label="30533" visible="false" default="2" option="int" subsetting="true" />
@ -161,7 +156,6 @@
<setting id="startupDelay" type="number" label="30529" default="0" option="int" /> <setting id="startupDelay" type="number" label="30529" default="0" option="int" />
<setting label="39018" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=repair)" option="close" /> <!-- Repair local database (force update all content) --> <setting label="39018" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=repair)" option="close" /> <!-- Repair local database (force update all content) -->
<setting label="30535" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect?mode=deviceid)" /><!-- Reset device id uuid --> <setting label="30535" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect?mode=deviceid)" /><!-- Reset device id uuid -->
<setting label="39021" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=thememedia)" option="close" visible="false" /> <!-- Sync Plex Theme Media to Kodi -->
<setting type="lsep" label="39049" /><!-- Nothing works? Try a full reset --> <setting type="lsep" label="39049" /><!-- Nothing works? Try a full reset -->
<setting label="39019" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=reset)" option="close" /> <!-- Partial or full reset of Database and PKC --> <setting label="39019" type="action" action="RunPlugin(plugin://plugin.video.plexkodiconnect/?mode=reset)" option="close" /> <!-- Partial or full reset of Database and PKC -->
</category> </category>