parent
c12c9c08d8
commit
61065e0cc5
3 changed files with 124 additions and 140 deletions
|
@ -1290,7 +1290,20 @@ class Music(Items):
|
|||
checksum=checksum)
|
||||
|
||||
# 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
|
||||
query = '''
|
||||
UPDATE album
|
||||
|
@ -1316,30 +1329,6 @@ class Music(Items):
|
|||
thumb, rating, lastScraped,
|
||||
v.KODI_TYPE_ALBUM, studio,
|
||||
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
|
||||
parent_id = api.parent_plex_id()
|
||||
|
@ -1400,8 +1389,8 @@ class Music(Items):
|
|||
kodicursor.execute(query, (artistid, name, year))
|
||||
# Update plex reference with parentid
|
||||
plex_db.updateParentId(artist_id, albumid)
|
||||
# Add genres
|
||||
self.kodi_db.addMusicGenres(albumid, self.genres, v.KODI_TYPE_ALBUM)
|
||||
if v.KODIVERSION < 18:
|
||||
self.kodi_db.addMusicGenres(albumid, self.genres, v.KODI_TYPE_ALBUM)
|
||||
# Update artwork
|
||||
artwork.modify_artwork(artworks, albumid, v.KODI_TYPE_ALBUM, kodicursor)
|
||||
# Add all children - all tracks
|
||||
|
@ -1517,18 +1506,33 @@ class Music(Items):
|
|||
kodicursor.execute(query, (path, '123', pathid))
|
||||
|
||||
# Update the song entry
|
||||
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))
|
||||
if v.KODIVERSION >= 18:
|
||||
# Kodi Leia
|
||||
query = '''
|
||||
UPDATE song
|
||||
SET idAlbum = ?, strArtistDisp = ?, 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))
|
||||
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
|
||||
plex_db.updateReference(itemid, checksum)
|
||||
|
@ -1615,18 +1619,33 @@ class Music(Items):
|
|||
dateadded))
|
||||
|
||||
# Create the song entry
|
||||
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))
|
||||
if v.KODIVERSION >= 18:
|
||||
# Kodi Leia
|
||||
query = '''
|
||||
INSERT INTO song(
|
||||
idSong, idAlbum, idPath, strArtistDisp, 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))
|
||||
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
|
||||
plex_db.addReference(itemid,
|
||||
|
@ -1637,15 +1656,14 @@ class Music(Items):
|
|||
parent_id=albumid,
|
||||
checksum=checksum,
|
||||
view_id=viewid)
|
||||
|
||||
# Link song to album
|
||||
query = '''
|
||||
INSERT OR REPLACE INTO albuminfosong(
|
||||
idAlbumInfoSong, idAlbumInfo, iTrack, strTitle, iDuration)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
'''
|
||||
kodicursor.execute(query, (songid, albumid, track, title, duration))
|
||||
|
||||
if v.KODIVERSION < 18:
|
||||
# Link song to album
|
||||
query = '''
|
||||
INSERT OR REPLACE INTO albuminfosong(
|
||||
idAlbumInfoSong, idAlbumInfo, iTrack, strTitle, iDuration)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
'''
|
||||
kodicursor.execute(query, (songid, albumid, track, title, duration))
|
||||
# Link song to artists
|
||||
artist_loop = [{
|
||||
'Name': api.grandparent_title(),
|
||||
|
|
|
@ -869,28 +869,20 @@ class KodiDBMethods(object):
|
|||
return seasonid
|
||||
|
||||
def addArtist(self, name, musicbrainz):
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT idArtist, strArtist",
|
||||
"FROM artist",
|
||||
"WHERE strMusicBrainzArtistID = ?"
|
||||
))
|
||||
query = '''
|
||||
SELECT idArtist, strArtist
|
||||
FROM artist
|
||||
WHERE strMusicBrainzArtistID = ?
|
||||
'''
|
||||
self.cursor.execute(query, (musicbrainz,))
|
||||
try:
|
||||
result = self.cursor.fetchone()
|
||||
artistid = result[0]
|
||||
artistname = result[1]
|
||||
|
||||
except TypeError:
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT idArtist",
|
||||
"FROM artist",
|
||||
"WHERE strArtist = ?",
|
||||
"COLLATE NOCASE"
|
||||
))
|
||||
query = '''
|
||||
SELECT idArtist FROM artist WHERE strArtist = ? COLLATE NOCASE
|
||||
'''
|
||||
self.cursor.execute(query, (name,))
|
||||
try:
|
||||
artistid = self.cursor.fetchone()[0]
|
||||
|
@ -899,113 +891,87 @@ class KodiDBMethods(object):
|
|||
# [Missing Tag] strMusicBrainzArtistID: Artist Tag Missing
|
||||
if v.KODIVERSION >= 17:
|
||||
self.cursor.execute(
|
||||
"select coalesce(max(idArtist),1) from artist")
|
||||
"SELECT COALESCE(MAX(idArtist),1) FROM artist")
|
||||
else:
|
||||
self.cursor.execute(
|
||||
"select coalesce(max(idArtist),0) from artist")
|
||||
"SELECT COALESCE(MAX(idArtist),0) FROM artist")
|
||||
artistid = self.cursor.fetchone()[0] + 1
|
||||
query = (
|
||||
'''
|
||||
INSERT INTO artist(idArtist, strArtist, strMusicBrainzArtistID)
|
||||
|
||||
query = '''
|
||||
INSERT INTO artist(idArtist, strArtist,
|
||||
strMusicBrainzArtistID)
|
||||
VALUES (?, ?, ?)
|
||||
'''
|
||||
)
|
||||
'''
|
||||
self.cursor.execute(query, (artistid, name, musicbrainz))
|
||||
else:
|
||||
if artistname != name:
|
||||
query = "UPDATE artist SET strArtist = ? WHERE idArtist = ?"
|
||||
self.cursor.execute(query, (name, artistid,))
|
||||
|
||||
return artistid
|
||||
|
||||
def addAlbum(self, name, musicbrainz):
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT idAlbum",
|
||||
"FROM album",
|
||||
"WHERE strMusicBrainzAlbumID = ?"
|
||||
))
|
||||
query = 'SELECT idAlbum FROM album WHERE strMusicBrainzAlbumID = ?'
|
||||
self.cursor.execute(query, (musicbrainz,))
|
||||
try:
|
||||
albumid = self.cursor.fetchone()[0]
|
||||
except TypeError:
|
||||
# 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
|
||||
query = (
|
||||
'''
|
||||
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType)
|
||||
|
||||
query = '''
|
||||
INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID,
|
||||
strReleaseType)
|
||||
VALUES (?, ?, ?, ?)
|
||||
'''
|
||||
)
|
||||
self.cursor.execute(query, (albumid, name, musicbrainz, "album"))
|
||||
'''
|
||||
self.cursor.execute(query, (albumid, name, musicbrainz, 'album'))
|
||||
return albumid
|
||||
|
||||
def addMusicGenres(self, kodiid, genres, mediatype):
|
||||
|
||||
if mediatype == "album":
|
||||
|
||||
# Delete current genres for clean slate
|
||||
query = ' '.join((
|
||||
|
||||
"DELETE FROM album_genre",
|
||||
"WHERE idAlbum = ?"
|
||||
))
|
||||
query = 'DELETE FROM album_genre WHERE idAlbum = ?'
|
||||
self.cursor.execute(query, (kodiid,))
|
||||
|
||||
for genre in genres:
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT idGenre",
|
||||
"FROM genre",
|
||||
"WHERE strGenre = ?",
|
||||
"COLLATE NOCASE"
|
||||
))
|
||||
query = '''
|
||||
SELECT idGenre FROM genre WHERE strGenre = ? COLLATE NOCASE
|
||||
'''
|
||||
self.cursor.execute(query, (genre,))
|
||||
try:
|
||||
genreid = self.cursor.fetchone()[0]
|
||||
except TypeError:
|
||||
# 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
|
||||
query = "INSERT INTO genre(idGenre, strGenre) values(?, ?)"
|
||||
query = 'INSERT INTO genre(idGenre, strGenre) VALUES(?, ?)'
|
||||
self.cursor.execute(query, (genreid, genre))
|
||||
|
||||
query = "INSERT OR REPLACE INTO album_genre(idGenre, idAlbum) values(?, ?)"
|
||||
query = '''
|
||||
INSERT OR REPLACE INTO album_genre(idGenre, idAlbum)
|
||||
VALUES (?, ?)
|
||||
'''
|
||||
self.cursor.execute(query, (genreid, kodiid))
|
||||
|
||||
elif mediatype == "song":
|
||||
|
||||
# Delete current genres for clean slate
|
||||
query = ' '.join((
|
||||
|
||||
"DELETE FROM song_genre",
|
||||
"WHERE idSong = ?"
|
||||
))
|
||||
query = 'DELETE FROM song_genre WHERE idSong = ?'
|
||||
self.cursor.execute(query, (kodiid,))
|
||||
|
||||
for genre in genres:
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT idGenre",
|
||||
"FROM genre",
|
||||
"WHERE strGenre = ?",
|
||||
"COLLATE NOCASE"
|
||||
))
|
||||
query = '''
|
||||
SELECT idGenre FROM genre WHERE strGenre = ?
|
||||
COLLATE NOCASE
|
||||
'''
|
||||
self.cursor.execute(query, (genre,))
|
||||
try:
|
||||
genreid = self.cursor.fetchone()[0]
|
||||
except TypeError:
|
||||
# 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
|
||||
query = "INSERT INTO genre(idGenre, strGenre) values(?, ?)"
|
||||
query = 'INSERT INTO genre(idGenre, strGenre) values(?, ?)'
|
||||
self.cursor.execute(query, (genreid, genre))
|
||||
|
||||
query = "INSERT OR REPLACE INTO song_genre(idGenre, idSong) values(?, ?)"
|
||||
query = '''
|
||||
INSERT OR REPLACE INTO song_genre(idGenre, idSong)
|
||||
VALUES (?, ?)
|
||||
'''
|
||||
self.cursor.execute(query, (genreid, kodiid))
|
||||
|
||||
# Krypton only stuff ##############################
|
||||
|
|
|
@ -85,7 +85,7 @@ _DB_VIDEO_VERSION = {
|
|||
15: 93, # Isengard
|
||||
16: 99, # Jarvis
|
||||
17: 107, # Krypton
|
||||
18: 108 # Leia
|
||||
18: 109 # Leia
|
||||
}
|
||||
DB_VIDEO_PATH = try_decode(xbmc.translatePath(
|
||||
"special://database/MyVideos%s.db" % _DB_VIDEO_VERSION[KODIVERSION]))
|
||||
|
@ -96,7 +96,7 @@ _DB_MUSIC_VERSION = {
|
|||
15: 52, # Isengard
|
||||
16: 56, # Jarvis
|
||||
17: 60, # Krypton
|
||||
18: 62 # Leia
|
||||
18: 70 # Leia
|
||||
}
|
||||
DB_MUSIC_PATH = try_decode(xbmc.translatePath(
|
||||
"special://database/MyMusic%s.db" % _DB_MUSIC_VERSION[KODIVERSION]))
|
||||
|
|
Loading…
Reference in a new issue