add support for latest kodi 18 music db changes

This commit is contained in:
im85288 2017-11-04 14:08:12 +00:00
parent 8041273c05
commit 7be8c49b14
4 changed files with 79 additions and 8 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby" <addon id="plugin.video.emby"
name="Emby" name="Emby"
version="2.3.54" version="2.3.55"
provider-name="Emby.media"> provider-name="Emby.media">
<requires> <requires>
<import addon="xbmc.python" version="2.19.0"/> <import addon="xbmc.python" version="2.19.0"/>
@ -32,5 +32,8 @@
<source>https://github.com/MediaBrowser/plugin.video.emby</source> <source>https://github.com/MediaBrowser/plugin.video.emby</source>
<summary lang="en"></summary> <summary lang="en"></summary>
<description lang="en">Welcome to Emby for Kodi A whole new way to manage and view your media library. The Emby addon for Kodi combines the best of Kodi - ultra smooth navigation, beautiful UIs and playback of any file under the sun, and Emby - the most powerful fully open source multi-client media metadata indexer and server.&#10;&#10;Emby for Kodi is the absolute best way to enjoy the incredible Kodi playback engine combined with the power of Emby's centralized database. Features: Direct integration with the Kodi library for native Kodi speed Instant synchronization with the Emby server Full support for Movie, TV and Music collections Emby Server direct stream and transcoding support - use Kodi when you are away from home!</description> <description lang="en">Welcome to Emby for Kodi A whole new way to manage and view your media library. The Emby addon for Kodi combines the best of Kodi - ultra smooth navigation, beautiful UIs and playback of any file under the sun, and Emby - the most powerful fully open source multi-client media metadata indexer and server.&#10;&#10;Emby for Kodi is the absolute best way to enjoy the incredible Kodi playback engine combined with the power of Emby's centralized database. Features: Direct integration with the Kodi library for native Kodi speed Instant synchronization with the Emby server Full support for Movie, TV and Music collections Emby Server direct stream and transcoding support - use Kodi when you are away from home!</description>
<news>v2.3.55
- Add support for Kodi Leia (Alpha) MusicDatabase v67
</news>
</extension> </extension>
</addon> </addon>

View File

@ -43,7 +43,7 @@ def music_database():
'15': 52, # Isengard '15': 52, # Isengard
'16': 56, # Jarvis '16': 56, # Jarvis
'17': 60, # Krypton '17': 60, # Krypton
'18': 65 # Leia '18': 67 # Leia
} }
return xbmc.translatePath("special://database/MyMusic%s.db" return xbmc.translatePath("special://database/MyMusic%s.db"
% db_version.get(KODI, "")).decode('utf-8') % db_version.get(KODI, "")).decode('utf-8')

View File

@ -198,6 +198,16 @@ class KodiMusic(KodiItems):
)) ))
self.cursor.execute(query, (args)) self.cursor.execute(query, (args))
def update_album_18(self, *args):
query = ' '.join((
"UPDATE album",
"SET strArtistsDisp = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?,",
"iUserrating = ?, lastScraped = ?, strReleaseType = ?",
"WHERE idAlbum = ?"
))
self.cursor.execute(query, (args))
def update_album_17(self, *args): def update_album_17(self, *args):
query = ' '.join(( query = ' '.join((
@ -246,11 +256,33 @@ class KodiMusic(KodiItems):
if curr_artists != artists: if curr_artists != artists:
self._update_album_artist(album_id, artists) self._update_album_artist(album_id, artists)
def get_album_artist_18(self, album_id, artists):
query = ' '.join((
"SELECT strArtistDisp",
"FROM album",
"WHERE idAlbum = ?"
))
self.cursor.execute(query, (album_id,))
try:
curr_artists = self.cursor.fetchone()[0]
except TypeError:
return
if curr_artists != artists:
self._update_album_artist_18(album_id, artists)
def _update_album_artist(self, album_id, artists): def _update_album_artist(self, album_id, artists):
query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?" query = "UPDATE album SET strArtists = ? WHERE idAlbum = ?"
self.cursor.execute(query, (artists, album_id)) self.cursor.execute(query, (artists, album_id))
def _update_album_artist_18(self, album_id, artists):
query = "UPDATE album SET strArtistDisp = ? WHERE idAlbum = ?"
self.cursor.execute(query, (artists, album_id))
def add_single(self, *args): def add_single(self, *args):
query = ( query = (
''' '''
@ -295,6 +327,19 @@ class KodiMusic(KodiItems):
) )
self.cursor.execute(query, (args)) self.cursor.execute(query, (args))
def add_song_18(self, *args):
query = (
'''
INSERT INTO song(
idSong, idAlbum, idPath, strArtistDisp, strGenres, strTitle, iTrack,
iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed,
rating)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
'''
)
self.cursor.execute(query, (args))
def update_song(self, *args): def update_song(self, *args):
query = ' '.join(( query = ' '.join((
@ -306,6 +351,17 @@ class KodiMusic(KodiItems):
)) ))
self.cursor.execute(query, (args)) self.cursor.execute(query, (args))
def update_song_18(self, *args):
query = ' '.join((
"UPDATE song",
"SET idAlbum = ?, strArtistDisp = ?, strGenres = ?, strTitle = ?, iTrack = ?,",
"iDuration = ?, iYear = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?,",
"rating = ?, comment = ?",
"WHERE idSong = ?"
))
self.cursor.execute(query, (args))
def link_song_artist(self, kodi_id, song_id, index, artist): def link_song_artist(self, kodi_id, song_id, index, artist):
if self.kodi_version > 16: if self.kodi_version > 16:

View File

@ -303,8 +303,8 @@ class Music(Items):
emby_db.addReference(itemid, albumid, "MusicAlbum", "album", checksum=checksum) emby_db.addReference(itemid, albumid, "MusicAlbum", "album", checksum=checksum)
# Process the album info # Process the album info
if self.kodi_version == 17: if self.kodi_version in [17,18]:
# Kodi Krypton # Kodi Krypton/Leia
self.kodi_db.update_album_17(artistname, year, genre, bio, thumb, rating, lastScraped, self.kodi_db.update_album_17(artistname, year, genre, bio, thumb, rating, lastScraped,
"album", albumid) "album", albumid)
elif self.kodi_version == 16: elif self.kodi_version == 16:
@ -440,8 +440,12 @@ class Music(Items):
self.kodi_db.update_path(pathid, path) self.kodi_db.update_path(pathid, path)
# Update the song entry # Update the song entry
if self.kodi_version < 18:
self.kodi_db.update_song(albumid, artists, genre, title, track, duration, year, self.kodi_db.update_song(albumid, artists, genre, title, track, duration, year,
filename, playcount, dateplayed, rating, comment, songid) filename, playcount, dateplayed, rating, comment, songid)
else:
self.kodi_db.update_song_18(albumid, artists, genre, title, track, duration, year,
filename, playcount, dateplayed, rating, comment, songid)
# Update the checksum in emby table # Update the checksum in emby table
emby_db.updateReference(itemid, checksum) emby_db.updateReference(itemid, checksum)
@ -494,14 +498,19 @@ class Music(Items):
self.kodi_db.add_single_14(albumid, genre, year, dateadded) self.kodi_db.add_single_14(albumid, genre, year, dateadded)
# Create the song entry # Create the song entry
if self.kodi_version < 18:
self.kodi_db.add_song(songid, albumid, pathid, artists, genre, title, track, duration, self.kodi_db.add_song(songid, albumid, pathid, artists, genre, title, track, duration,
year, filename, musicBrainzId, playcount, dateplayed, rating) year, filename, musicBrainzId, playcount, dateplayed, rating)
else:
self.kodi_db.add_song_18(songid, albumid, pathid, artists, genre, title, track, duration,
year, filename, musicBrainzId, playcount, dateplayed, rating)
# Create the reference in emby table # Create the reference in emby table
emby_db.addReference(itemid, songid, "Audio", "song", pathid=pathid, parentid=albumid, emby_db.addReference(itemid, songid, "Audio", "song", pathid=pathid, parentid=albumid,
checksum=checksum) checksum=checksum)
# Link song to album # Link song to album
if self.kodi_version < 18:
self.kodi_db.link_song_album(songid, albumid, track, title, duration) self.kodi_db.link_song_album(songid, albumid, track, title, duration)
# Create default role # Create default role
if self.kodi_version > 16: if self.kodi_version > 16:
@ -553,7 +562,10 @@ class Music(Items):
# Artist names # Artist names
album_artists = " / ".join(album_artists) album_artists = " / ".join(album_artists)
if self.kodi_version < 18:
self.kodi_db.get_album_artist(albumid, album_artists) self.kodi_db.get_album_artist(albumid, album_artists)
else:
self.kodi_db.get_album_artist_18(albumid, album_artists)
# Add genres # Add genres
self.kodi_db.add_genres(songid, genres, "song") self.kodi_db.add_genres(songid, genres, "song")