Change artwork for music items

This commit is contained in:
croneter 2018-11-10 12:18:02 +01:00
parent da7d871af8
commit 48f5d67d63
3 changed files with 21 additions and 38 deletions

View file

@ -7,7 +7,7 @@ from .common import ItemBase
from ..plex_api import API
from ..plex_db import PlexDB
from ..kodi_db import KodiMusicDB
from .. import artwork, plex_functions as PF, utils, state, variables as v
from .. import plex_functions as PF, utils, state, variables as v
LOG = getLogger('PLEX.music')
@ -110,7 +110,7 @@ class MusicMixin(object):
self.kodidb.delete_song_from_song_genre(kodi_id)
query = 'DELETE FROM albuminfosong WHERE idAlbumInfoSong = ?'
self.kodicursor.execute(query, (kodi_id, ))
artwork.delete_artwork(kodi_id, v.KODI_TYPE_SONG, self.kodicursor)
self.kodidb.delete_artwork(kodi_id, v.KODI_TYPE_SONG)
def remove_album(self, kodi_id):
'''
@ -125,7 +125,7 @@ class MusicMixin(object):
(kodi_id, ))
self.kodicursor.execute('DELETE FROM album WHERE idAlbum = ?',
(kodi_id, ))
artwork.delete_artwork(kodi_id, v.KODI_TYPE_ALBUM, self.kodicursor)
self.kodidb.delete_artwork(kodi_id, v.KODI_TYPE_ALBUM)
def remove_artist(self, kodi_id):
'''
@ -139,7 +139,7 @@ class MusicMixin(object):
(kodi_id, ))
self.kodicursor.execute('DELETE FROM discography WHERE idArtist = ?',
(kodi_id, ))
artwork.delete_artwork(kodi_id, v.KODI_TYPE_ARTIST, self.kodicursor)
self.kodidb.delete_artwork(kodi_id, v.KODI_TYPE_ARTIST)
class Artist(MusicMixin, ItemBase):
@ -207,10 +207,9 @@ class Artist(MusicMixin, ItemBase):
utils.unix_date_to_kodi(self.last_sync),
kodi_id))
# Update artwork
artwork.modify_artwork(artworks,
self.kodidb.modify_artwork(artworks,
kodi_id,
v.KODI_TYPE_ARTIST,
self.kodicursor)
v.KODI_TYPE_ARTIST)
self.plexdb.add_artist(plex_id,
api.checksum(),
section_id,
@ -367,11 +366,9 @@ class Album(MusicMixin, ItemBase):
self.kodidb.add_music_genres(kodi_id,
genres,
v.KODI_TYPE_ALBUM)
# Update artwork
artwork.modify_artwork(artworks,
self.kodidb.modify_artwork(artworks,
kodi_id,
v.KODI_TYPE_ALBUM,
self.kodicursor)
v.KODI_TYPE_ALBUM)
self.plexdb.add_album(plex_id,
api.checksum(),
section_id,
@ -619,7 +616,7 @@ class Song(MusicMixin, ItemBase):
else:
LOG.info("ADD song plex_id: %s - %s", plex_id, title)
# Add path
kodi_pathid = self.kodidb.add_music_path(path, hash_string="123")
kodi_pathid = self.kodidb.add_path(path, hash_string="123")
# Create the song entry
if v.KODIVERSION >= 18:
# Kodi Leia
@ -736,17 +733,14 @@ class Song(MusicMixin, ItemBase):
if genres:
self.kodidb.add_music_genres(kodi_id, genres, v.KODI_TYPE_SONG)
artworks = api.artwork()
artwork.modify_artwork(artworks,
self.kodidb.modify_artwork(artworks,
kodi_id,
v.KODI_TYPE_SONG,
self.kodicursor)
v.KODI_TYPE_SONG)
if xml.get('parentKey') is None:
# Update album artwork
artwork.modify_artwork(artworks,
self.kodidb.modify_artwork(artworks,
parent_id,
v.KODI_TYPE_ALBUM,
self.kodicursor)
# Create the reference in plex table
v.KODI_TYPE_ALBUM)
self.plexdb.add_song(plex_id,
api.checksum(),
section_id,

View file

@ -1,11 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, unicode_literals
from logging import getLogger
from .video import KodiVideoDB
LOG = getLogger('PLEX.kodi_db.movies')
class KodiMovieDB(KodiVideoDB):

View file

@ -4,7 +4,7 @@ from __future__ import absolute_import, division, unicode_literals
from logging import getLogger
from . import common
from .. import utils, variables as v
from .. import utils
LOG = getLogger('PLEX.kodi_db.music')
@ -17,7 +17,7 @@ class KodiMusicDB(common.KodiDBBase):
self.cursor = self.kodiconn.cursor()
return self
def add_music_path(self, path, hash_string=None):
def add_path(self, path, hash_string=None):
"""
Add the path (unicode) to the music DB, if it does not exist already.
Returns the path id