Merge pull request #855 from croneter/revert_libraryUUID

Revert "Merge pull request #841 from croneter/section-uuid"
This commit is contained in:
croneter 2019-05-28 18:57:13 +02:00 committed by GitHub
commit 1453b6c2f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 170 additions and 196 deletions

View file

@ -14,7 +14,8 @@ class Movie(ItemBase):
"""
Used for plex library-type movies
"""
def add_update(self, xml, section, children=None):
def add_update(self, xml, section_name=None, section_id=None,
children=None):
"""
Process single movie
"""
@ -173,7 +174,7 @@ class Movie(ItemBase):
self.kodidb.modify_streams(file_id, api.mediastreams(), runtime)
self.kodidb.modify_studios(kodi_id, v.KODI_TYPE_MOVIE, studios)
tags = [section.name]
tags = [section_name]
if collections:
for plex_set_id, set_name in collections:
set_api = None
@ -188,7 +189,7 @@ class Movie(ItemBase):
# e.g. when added via websocket
LOG.debug('Costly looking up Plex collection %s: %s',
plex_set_id, set_name)
for index, coll_plex_id in api.collections_match(section.id):
for index, coll_plex_id in api.collections_match(section_id):
# Get Plex artwork for collections - a pain
if index == plex_set_id:
set_xml = PF.GetPlexMetadata(coll_plex_id)
@ -216,8 +217,7 @@ class Movie(ItemBase):
dateplayed)
self.plexdb.add_movie(plex_id=plex_id,
checksum=api.checksum(),
section_id=section.id,
section_uuid=section.uuid,
section_id=section_id,
kodi_id=kodi_id,
kodi_fileid=file_id,
kodi_pathid=kodi_pathid,

View file

@ -154,7 +154,8 @@ class Artist(MusicMixin, ItemBase):
"""
For Plex library-type artists
"""
def add_update(self, xml, section, children=None):
def add_update(self, xml, section_name=None, section_id=None,
children=None):
"""
Process a single artist
"""
@ -209,14 +210,14 @@ class Artist(MusicMixin, ItemBase):
v.KODI_TYPE_ARTIST)
self.plexdb.add_artist(plex_id,
api.checksum(),
section.id,
section.uuid,
section_id,
kodi_id,
self.last_sync)
class Album(MusicMixin, ItemBase):
def add_update(self, xml, section, children=None, scan_children=True):
def add_update(self, xml, section_name=None, section_id=None,
children=None, scan_children=True):
"""
Process a single album
scan_children: set to False if you don't want to add children, e.g. to
@ -249,7 +250,8 @@ class Album(MusicMixin, ItemBase):
Artist(self.last_sync,
plexdb=self.plexdb,
kodidb=self.kodidb).add_update(artist_xml[0],
section=section)
section_name,
section_id)
artist = self.plexdb.artist(parent_id)
if not artist:
LOG.error('Adding artist %s failed for %s',
@ -361,8 +363,7 @@ class Album(MusicMixin, ItemBase):
v.KODI_TYPE_ALBUM)
self.plexdb.add_album(plex_id,
api.checksum(),
section.id,
section.uuid,
section_id,
artist_id,
parent_id,
kodi_id,
@ -374,7 +375,8 @@ class Album(MusicMixin, ItemBase):
kodidb=self.kodidb)
for song in children:
context.add_update(song,
section=section,
section_name=section_name,
section_id=section_id,
album_xml=xml,
genres=genres,
genre=genre,
@ -382,8 +384,9 @@ class Album(MusicMixin, ItemBase):
class Song(MusicMixin, ItemBase):
def add_update(self, xml, section, children=None, album_xml=None,
genres=None, genre=None, compilation=None):
def add_update(self, xml, section_name=None, section_id=None,
children=None, album_xml=None, genres=None, genre=None,
compilation=None):
"""
Process single song/track
"""
@ -418,7 +421,8 @@ class Song(MusicMixin, ItemBase):
Artist(self.last_sync,
plexdb=self.plexdb,
kodidb=self.kodidb).add_update(artist_xml[0],
section=section)
section_name,
section_id)
artist = self.plexdb.artist(artist_id)
if not artist:
LOG.error('Still could not find grandparent artist %s for %s',
@ -473,7 +477,8 @@ class Song(MusicMixin, ItemBase):
Album(self.last_sync,
plexdb=self.plexdb,
kodidb=self.kodidb).add_update(album_xml[0],
section=section,
section_name,
section_id,
children=[xml],
scan_children=False)
album = self.plexdb.album(album_id)
@ -654,8 +659,7 @@ class Song(MusicMixin, ItemBase):
v.KODI_TYPE_ALBUM)
self.plexdb.add_song(plex_id,
api.checksum(),
section.id,
section.uuid,
section_id,
artist_id,
grandparent_id,
album_id,

View file

@ -143,7 +143,8 @@ class Show(TvShowMixin, ItemBase):
"""
For Plex library-type TV shows
"""
def add_update(self, xml, section, children=None):
def add_update(self, xml, section_name=None, section_id=None,
children=None):
"""
Process a single show
"""
@ -273,20 +274,20 @@ class Show(TvShowMixin, ItemBase):
# Process studios
self.kodidb.modify_studios(kodi_id, v.KODI_TYPE_SHOW, studios)
# Process tags: view, PMS collection tags
tags = [section.name]
tags = [section_name]
tags.extend([i for _, i in api.collection_list()])
self.kodidb.modify_tags(kodi_id, v.KODI_TYPE_SHOW, tags)
self.plexdb.add_show(plex_id=plex_id,
checksum=api.checksum(),
section_id=section.id,
section_uuid=section.uuid,
section_id=section_id,
kodi_id=kodi_id,
kodi_pathid=kodi_pathid,
last_sync=self.last_sync)
class Season(TvShowMixin, ItemBase):
def add_update(self, xml, section, children=None):
def add_update(self, xml, section_name=None, section_id=None,
children=None):
"""
Process a single season of a certain tv show
"""
@ -314,7 +315,8 @@ class Season(TvShowMixin, ItemBase):
Show(self.last_sync,
plexdb=self.plexdb,
kodidb=self.kodidb).add_update(show_xml[0],
section=section)
section_name,
section_id)
show = self.plexdb.show(show_id)
if not show:
LOG.error('Still could not find parent tv show %s', show_id)
@ -344,8 +346,7 @@ class Season(TvShowMixin, ItemBase):
v.KODI_TYPE_SEASON)
self.plexdb.add_season(plex_id=plex_id,
checksum=api.checksum(),
section_id=section.id,
section_uuid=section.uuid,
section_id=section_id,
show_id=show_id,
parent_id=parent_id,
kodi_id=kodi_id,
@ -353,7 +354,8 @@ class Season(TvShowMixin, ItemBase):
class Episode(TvShowMixin, ItemBase):
def add_update(self, xml, section, children=None):
def add_update(self, xml, section_name=None, section_id=None,
children=None):
"""
Process single episode
"""
@ -400,7 +402,8 @@ class Episode(TvShowMixin, ItemBase):
Show(self.last_sync,
plexdb=self.plexdb,
kodidb=self.kodidb).add_update(show_xml[0],
section=section)
section_name,
section_id)
show = self.plexdb.show(show_id)
if not show:
LOG.error('Still could not find grandparent tv show %s', show_id)
@ -420,7 +423,8 @@ class Episode(TvShowMixin, ItemBase):
Season(self.last_sync,
plexdb=self.plexdb,
kodidb=self.kodidb).add_update(season_xml[0],
section=section)
section_name,
section_id)
season = self.plexdb.season(season_id)
if not season:
LOG.error('Still could not find parent season %s', season_id)
@ -539,8 +543,7 @@ class Episode(TvShowMixin, ItemBase):
userdata['LastPlayedDate'])
self.plexdb.add_episode(plex_id=plex_id,
checksum=api.checksum(),
section_id=section.id,
section_uuid=section.uuid,
section_id=section_id,
show_id=show_id,
grandparent_id=grandparent_id,
season_id=season_id,
@ -616,8 +619,7 @@ class Episode(TvShowMixin, ItemBase):
userdata['LastPlayedDate'])
self.plexdb.add_episode(plex_id=plex_id,
checksum=api.checksum(),
section_id=section.id,
section_uuid=section.uuid,
section_id=section_id,
show_id=show_id,
grandparent_id=grandparent_id,
season_id=season_id,

View file

@ -25,16 +25,18 @@ UPDATED_AT_SAFETY = 60 * 5
LAST_VIEWED_AT_SAFETY = 60 * 5
class InitNewSection(sections.Section):
class InitNewSection(object):
"""
Throw this into the queue used for ProcessMetadata to tell it which
Plex library section we're looking at
"""
def __init__(self, total_number_of_items, section):
super(InitNewSection, self).__init__()
# Copy all section attributes to this instance
self.__dict__.update(section.__dict__)
def __init__(self, context, total_number_of_items, section_name,
section_id, plex_type):
self.context = context
self.total = total_number_of_items
self.name = section_name
self.id = section_id
self.plex_type = plex_type
class FullSync(common.fullsync_mixin):
@ -138,7 +140,8 @@ class FullSync(common.fullsync_mixin):
self.queue.task_done()
if isinstance(item, dict):
context.add_update(item['xml'][0],
section=section,
section_name=section.name,
section_id=section.id,
children=item['children'])
self.title = item['xml'][0].get('title')
self.processed += 1
@ -165,7 +168,12 @@ class FullSync(common.fullsync_mixin):
# Sync new, updated and deleted items
iterator = section.iterator
# Tell the processing thread about this new section
queue_info = InitNewSection(iterator.total, section)
queue_info = InitNewSection(section.context,
iterator.total,
iterator.get('librarySectionTitle',
iterator.get('title1')),
section.section_id,
section.plex_type)
self.queue.put(queue_info)
last = True
# To keep track of the item-number in order to kill while loops
@ -203,7 +211,11 @@ class FullSync(common.fullsync_mixin):
# Sync new, updated and deleted items
iterator = section.iterator
# Tell the processing thread about this new section
queue_info = InitNewSection(iterator.total, section)
queue_info = InitNewSection(section.context,
iterator.total,
section.name,
section.section_id,
section.plex_type)
self.queue.put(queue_info)
self.total = iterator.total
self.section_name = section.name
@ -221,7 +233,8 @@ class FullSync(common.fullsync_mixin):
if not itemtype.update_userdata(xml_item, section.plex_type):
# Somehow did not sync this item yet
itemtype.add_update(xml_item,
section=section)
section_name=section.name,
section_id=section.section_id)
itemtype.plexdb.update_last_sync(int(xml_item.attrib['ratingKey']),
section.plex_type,
self.current_sync)
@ -261,7 +274,7 @@ class FullSync(common.fullsync_mixin):
updated_at = section.last_sync - UPDATED_AT_SAFETY \
if section.last_sync else None
try:
element.iterator = PF.SectionItems(section.id,
element.iterator = PF.SectionItems(section.section_id,
plex_type=element.plex_type,
updated_at=updated_at,
last_viewed_at=None)
@ -318,7 +331,7 @@ class FullSync(common.fullsync_mixin):
# some items from the PMS
with PlexDB() as plexdb:
# Set the new time mark for the next delta sync
plexdb.update_section_last_sync(section.id,
plexdb.update_section_last_sync(section.section_id,
self.current_sync)
common.update_kodi_library(video=True, music=True)
# In order to not delete all your songs again

View file

@ -41,12 +41,10 @@ class Section(object):
"""
def __init__(self, index=None, xml_element=None, section_db_element=None):
# Unique Plex id of this Plex library section
self._id = None # int
# Plex librarySectionUUID, unique for this section
self.uuid = None
self._section_id = None # int
# Building block for window variable
self._node = None # unicode
# Index of this section (as id might not be subsequent)
# Index of this section (as section_id might not be subsequent)
# This follows 1:1 the sequence in with the PMS returns the sections
self._index = None # Codacy-bug
self.index = index # int
@ -60,6 +58,9 @@ class Section(object):
# Do we sync all items of this section to the Kodi DB?
# This will be set with section_type!!
self.sync_to_kodi = None # bool
# For sections to be synched, the section name will be recorded as a
# tag. This is the corresponding id for this tag
self.kodi_tagid = None # int
# When was this section last successfully/completely synched to the
# Kodi database?
self.last_sync = None # int
@ -89,28 +90,24 @@ class Section(object):
elif section_db_element:
self.from_db_element(section_db_element)
def __unicode__(self):
def __repr__(self):
return ("{{"
"'index': {self.index}, "
"'name': '{self.name}', "
"'id': {self.id}, "
"'section_id': {self.section_id}, "
"'section_type': '{self.section_type}', "
"'sync_to_kodi': {self.sync_to_kodi}, "
"'last_sync': {self.last_sync}, "
"'uuid': {self.uuid}"
"}}").format(self=self)
def __str__(self):
return unicode(self).encode('utf-8')
__repr__ = __str__
"'last_sync': {self.last_sync}"
"}}").format(self=self).encode('utf-8')
__str__ = __repr__
def __nonzero__(self):
return (self.id is not None and
return (self.section_id is not None and
self.name is not None and
self.section_type is not None)
def __eq__(self, section):
return (self.id == section.id and
return (self.section_id == section.section_id and
self.name == section.name and
self.section_type == section.section_type)
@ -118,12 +115,12 @@ class Section(object):
return not self == section
@property
def id(self):
return self._id
def section_id(self):
return self._section_id
@id.setter
def id(self, value):
self._id = value
@section_id.setter
def section_id(self, value):
self._section_id = value
self._path = path_ops.path.join(LIBRARY_PATH, 'Plex-%s' % value, '')
self._playlist_path = path_ops.path.join(PLAYLISTS_PATH,
'Plex %s.xsp' % value)
@ -166,10 +163,10 @@ class Section(object):
return self._playlist_path
def from_db_element(self, section_db_element):
self.id = section_db_element['section_id']
self.uuid = section_db_element['uuid']
self.section_id = section_db_element['section_id']
self.name = section_db_element['section_name']
self.section_type = section_db_element['plex_type']
self.kodi_tagid = section_db_element['kodi_tagid']
self.sync_to_kodi = section_db_element['sync_to_kodi']
self.last_sync = section_db_element['last_sync']
@ -178,8 +175,7 @@ class Section(object):
Reads section from a PMS xml (Plex id, name, Plex type)
"""
api = API(xml_element)
self.id = utils.cast(int, xml_element.get('key'))
self.uuid = xml_element.get('uuid')
self.section_id = utils.cast(int, xml_element.get('key'))
self.name = api.title()
self.section_type = api.plex_type()
self.icon = api.one_artwork('composite')
@ -207,18 +203,18 @@ class Section(object):
if not self:
raise RuntimeError('Section not clearly defined: %s' % self)
if plexdb:
plexdb.add_section(self.id,
self.uuid,
plexdb.add_section(self.section_id,
self.name,
self.section_type,
self.kodi_tagid,
self.sync_to_kodi,
self.last_sync)
else:
with PlexDB(lock=False) as plexdb:
plexdb.add_section(self.id,
self.uuid,
plexdb.add_section(self.section_id,
self.name,
self.section_type,
self.kodi_tagid,
self.sync_to_kodi,
self.last_sync)
@ -245,21 +241,21 @@ class Section(object):
# nodes as "submenus" once the user navigates into this section
args = {
'mode': 'browseplex',
'key': '/library/sections/%s' % self.id,
'key': '/library/sections/%s' % self.section_id,
'plex_type': self.section_type,
'section_id': unicode(self.id)
'section_id': unicode(self.section_id)
}
if not self.sync_to_kodi:
args['synched'] = 'false'
addon_index = self.addon_path(args)
if self.sync_to_kodi and self.section_type in v.PLEX_VIDEOTYPES:
path = 'library://video/Plex-{0}/{0}_all.xml'
path = path.format(self.id)
index = 'library://video/Plex-%s' % self.id
path = path.format(self.section_id)
index = 'library://video/Plex-%s' % self.section_id
else:
# No xmls to link to - let's show the listings on the fly
index = addon_index
args['key'] = '/library/sections/%s/all' % self.id
args['key'] = '/library/sections/%s/all' % self.section_id
path = self.addon_path(args)
# .index will list all possible nodes for this library
utils.window('%s.index' % self.node, value=index)
@ -277,7 +273,7 @@ class Section(object):
# Pictures
utils.window('%s.path' % self.node,
value='ActivateWindow(pictures,%s,return)' % path)
utils.window('%s.id' % self.node, value=str(self.id))
utils.window('%s.id' % self.node, value=str(self.section_id))
# To let the user navigate into this node when selecting widgets
utils.window('%s.addon_index' % self.node, value=addon_index)
if not self.sync_to_kodi:
@ -295,7 +291,7 @@ class Section(object):
path_ops.makedirs(self.path)
# Create a tag just like the section name in the Kodi DB
with kodi_db.KodiVideoDB(lock=False) as kodidb:
kodidb.create_tag(self.name)
self.kodi_tagid = kodidb.create_tag(self.name)
# The xmls are numbered in order of appearance
self.order = 0
if not path_ops.exists(path_ops.path.join(self.path, 'index.xml')):
@ -316,7 +312,7 @@ class Section(object):
def _build_node(self, node_type, node_name, args, content, pms_node):
self.content = content
node_name = node_name.format(self=self)
xml_name = '%s_%s.xml' % (self.id, node_type)
xml_name = '%s_%s.xml' % (self.section_id, node_type)
path = path_ops.path.join(self.path, xml_name)
if not path_ops.exists(path):
if pms_node:
@ -327,7 +323,7 @@ class Section(object):
xml = getattr(nodes, 'node_%s' % node_type)(self, node_name)
self._write_xml(xml, xml_name)
self.order += 1
path = 'library://video/Plex-%s/%s' % (self.id, xml_name)
path = 'library://video/Plex-%s/%s' % (self.section_id, xml_name)
self._window_node(path, node_name, node_type, pms_node)
def _write_xml(self, xml, xml_name):
@ -366,13 +362,13 @@ class Section(object):
# if node_type == 'all':
# var = self.node
# utils.window('%s.index' % var,
# value=path.replace('%s_all.xml' % self.id, ''))
# value=path.replace('%s_all.xml' % self.section_id, ''))
# utils.window('%s.title' % var, value=self.name)
# else:
var = '%s.%s' % (self.node, node_type)
utils.window('%s.index' % var, value=path)
utils.window('%s.title' % var, value=node_name)
utils.window('%s.id' % var, value=str(self.id))
utils.window('%s.id' % var, value=str(self.section_id))
utils.window('%s.path' % var, value=window_path)
utils.window('%s.type' % var, value=self.content)
utils.window('%s.content' % var, value=path)
@ -407,10 +403,10 @@ class Section(object):
Removes this sections completely from the Plex DB
"""
if plexdb:
plexdb.remove_section(self.id)
plexdb.remove_section(self.section_id)
else:
with PlexDB(lock=False) as plexdb:
plexdb.remove_section(self.id)
plexdb.remove_section(self.section_id)
def remove(self):
"""
@ -445,6 +441,7 @@ def _retrieve_old_settings(sections, old_sections):
Thus sets to the old values:
section.last_sync
section.kodi_tagid
section.sync_to_kodi
section.last_sync
"""
@ -452,6 +449,7 @@ def _retrieve_old_settings(sections, old_sections):
for old_section in old_sections:
if section == old_section:
section.last_sync = old_section.last_sync
section.kodi_tagid = old_section.kodi_tagid
section.sync_to_kodi = old_section.sync_to_kodi
section.last_sync = old_section.last_sync
@ -473,7 +471,7 @@ def _delete_kodi_db_items(section):
for plex_type, context in types:
while True:
with PlexDB() as plexdb:
plex_ids = list(plexdb.plexid_by_sectionid(section.id,
plex_ids = list(plexdb.plexid_by_sectionid(section.section_id,
plex_type,
BATCH_SIZE))
with kodi_context(texture_db=True) as kodidb:

View file

@ -3,7 +3,6 @@
from __future__ import absolute_import, division, unicode_literals
from logging import getLogger
from . import sections
from .common import update_kodi_library, PLAYLIST_SYNC_ENABLED
from .fanart import SYNC_FANART, FanartTask
from ..plex_api import API
@ -123,16 +122,10 @@ def process_new_item_message(message):
LOG.error('Could not download metadata for %s', message['plex_id'])
return False, False, False
LOG.debug("Processing new/updated PMS item: %s", message['plex_id'])
section_id = utils.cast(int, xml.get('librarySectionID'))
for section in sections.SECTIONS:
if section.id == section_id:
break
else:
LOG.error('Section id %s not yet encountered', section_id)
return False, False, False
with itemtypes.ITEMTYPE_FROM_PLEXTYPE[plex_type](timing.unix_timestamp()) as typus:
typus.add_update(xml[0],
section=section)
section_name=xml.get('librarySectionTitle'),
section_id=xml.get('librarySectionID'))
cache_artwork(message['plex_id'], plex_type)
return True, plex_type in v.PLEX_VIDEOTYPES, plex_type in v.PLEX_AUDIOTYPES

View file

@ -194,9 +194,9 @@ def initialize():
plexdb.cursor.execute('''
CREATE TABLE IF NOT EXISTS sections(
section_id INTEGER PRIMARY KEY,
uuid TEXT,
section_name TEXT,
plex_type TEXT,
kodi_tagid INTEGER,
sync_to_kodi INTEGER,
last_sync INTEGER)
''')
@ -205,7 +205,6 @@ def initialize():
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER,
kodi_fileid INTEGER,
kodi_pathid INTEGER,
@ -217,7 +216,6 @@ def initialize():
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER,
kodi_pathid INTEGER,
fanart_synced INTEGER,
@ -228,7 +226,6 @@ def initialize():
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
show_id INTEGER,
parent_id INTEGER,
kodi_id INTEGER,
@ -240,7 +237,6 @@ def initialize():
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
show_id INTEGER,
grandparent_id INTEGER,
season_id INTEGER,
@ -257,7 +253,6 @@ def initialize():
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER,
last_sync INTEGER)
''')
@ -266,7 +261,6 @@ def initialize():
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
artist_id INTEGER,
parent_id INTEGER,
kodi_id INTEGER,
@ -277,7 +271,6 @@ def initialize():
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
artist_id INTEGER,
grandparent_id INTEGER,
album_id INTEGER,

View file

@ -5,8 +5,8 @@ from .. import variables as v
class Movies(object):
def add_movie(self, plex_id, checksum, section_id, section_uuid, kodi_id,
kodi_fileid, kodi_pathid, last_sync):
def add_movie(self, plex_id, checksum, section_id, kodi_id, kodi_fileid,
kodi_pathid, last_sync):
"""
Appends or replaces an entry into the plex table for movies
"""
@ -15,20 +15,18 @@ class Movies(object):
plex_id,
checksum,
section_id,
section_uuid,
kodi_id,
kodi_fileid,
kodi_pathid,
fanart_synced,
last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
'''
self.cursor.execute(
query,
(plex_id,
checksum,
section_id,
section_uuid,
kodi_id,
kodi_fileid,
kodi_pathid,
@ -41,7 +39,6 @@ class Movies(object):
plex_id INTEGER PRIMARY KEY ASC,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER,
kodi_fileid INTEGER,
kodi_pathid INTEGER,
@ -64,10 +61,9 @@ class Movies(object):
'plex_id': entry[0],
'checksum': entry[1],
'section_id': entry[2],
'section_uuid': entry[3],
'kodi_id': entry[4],
'kodi_fileid': entry[5],
'kodi_pathid': entry[6],
'fanart_synced': entry[7],
'last_sync': entry[8]
'kodi_id': entry[3],
'kodi_fileid': entry[4],
'kodi_pathid': entry[5],
'fanart_synced': entry[6],
'last_sync': entry[7]
}

View file

@ -5,8 +5,7 @@ from .. import variables as v
class Music(object):
def add_artist(self, plex_id, checksum, section_id, section_uuid, kodi_id,
last_sync):
def add_artist(self, plex_id, checksum, section_id, kodi_id, last_sync):
"""
Appends or replaces music artist entry into the plex table
"""
@ -15,22 +14,20 @@ class Music(object):
plex_id,
checksum,
section_id,
section_uuid,
kodi_id,
last_sync)
VALUES (?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?)
'''
self.cursor.execute(
query,
(plex_id,
checksum,
section_id,
section_uuid,
kodi_id,
last_sync))
def add_album(self, plex_id, checksum, section_id, section_uuid, artist_id,
parent_id, kodi_id, last_sync):
def add_album(self, plex_id, checksum, section_id, artist_id, parent_id,
kodi_id, last_sync):
"""
Appends or replaces an entry into the plex table
"""
@ -39,27 +36,24 @@ class Music(object):
plex_id,
checksum,
section_id,
section_uuid,
artist_id,
parent_id,
kodi_id,
last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?)
'''
self.cursor.execute(
query,
(plex_id,
checksum,
section_id,
section_uuid,
artist_id,
parent_id,
kodi_id,
last_sync))
def add_song(self, plex_id, checksum, section_id, section_uuid, artist_id,
grandparent_id, album_id, parent_id, kodi_id, kodi_pathid,
last_sync):
def add_song(self, plex_id, checksum, section_id, artist_id, grandparent_id,
album_id, parent_id, kodi_id, kodi_pathid, last_sync):
"""
Appends or replaces an entry into the plex table
"""
@ -68,7 +62,6 @@ class Music(object):
plex_id,
checksum,
section_id,
section_uuid,
artist_id,
grandparent_id,
album_id,
@ -76,14 +69,13 @@ class Music(object):
kodi_id,
kodi_pathid,
last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
'''
self.cursor.execute(
query,
(plex_id,
checksum,
section_id,
section_uuid,
artist_id,
grandparent_id,
album_id,
@ -98,7 +90,6 @@ class Music(object):
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER,
last_sync INTEGER
"""
@ -114,7 +105,6 @@ class Music(object):
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
artist_id INTEGER, # plex_id of the parent artist
parent_id INTEGER, # kodi_id of the parent artist
kodi_id INTEGER,
@ -132,7 +122,6 @@ class Music(object):
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
artist_id INTEGER, # plex_id of the parent artist
grandparent_id INTEGER, # kodi_id of the parent artist
album_id INTEGER, # plex_id of the parent album
@ -157,14 +146,13 @@ class Music(object):
'plex_id': entry[0],
'checksum': entry[1],
'section_id': entry[2],
'section_uuid': entry[3],
'artist_id': entry[4],
'grandparent_id': entry[5],
'album_id': entry[6],
'parent_id': entry[7],
'kodi_id': entry[8],
'kodi_pathid': entry[9],
'last_sync': entry[10]
'artist_id': entry[3],
'grandparent_id': entry[4],
'album_id': entry[5],
'parent_id': entry[6],
'kodi_id': entry[7],
'kodi_pathid': entry[8],
'last_sync': entry[9]
}
@staticmethod
@ -177,11 +165,10 @@ class Music(object):
'plex_id': entry[0],
'checksum': entry[1],
'section_id': entry[2],
'section_uuid': entry[3],
'artist_id': entry[4],
'parent_id': entry[5],
'kodi_id': entry[6],
'last_sync': entry[7]
'artist_id': entry[3],
'parent_id': entry[4],
'kodi_id': entry[5],
'last_sync': entry[6]
}
@staticmethod
@ -194,9 +181,8 @@ class Music(object):
'plex_id': entry[0],
'checksum': entry[1],
'section_id': entry[2],
'section_uuid': entry[3],
'kodi_id': entry[4],
'last_sync': entry[5]
'kodi_id': entry[3],
'last_sync': entry[4]
}
def album_has_songs(self, plex_id):

View file

@ -15,9 +15,9 @@ class Sections(object):
"""
For section_id, returns the dict
section_id INTEGER PRIMARY KEY,
uuid TEXT,
section_name TEXT,
plex_type TEXT,
kodi_tagid INTEGER,
sync_to_kodi BOOL,
last_sync INTEGER
"""
@ -31,9 +31,9 @@ class Sections(object):
return
return {
'section_id': entry[0],
'uuid': entry[1],
'section_name': entry[2],
'plex_type': entry[3],
'section_name': entry[1],
'plex_type': entry[2],
'kodi_tagid': entry[3],
'sync_to_kodi': entry[4] == 1,
'last_sync': entry[5]
}
@ -49,7 +49,7 @@ class Sections(object):
except TypeError:
pass
def add_section(self, section_id, uuid, section_name, plex_type,
def add_section(self, section_id, section_name, plex_type, kodi_tagid,
sync_to_kodi, last_sync):
"""
Appends a Plex section to the Plex sections table
@ -58,18 +58,18 @@ class Sections(object):
query = '''
INSERT OR REPLACE INTO sections(
section_id,
uuid,
section_name,
plex_type,
kodi_tagid,
sync_to_kodi,
last_sync)
VALUES (?, ?, ?, ?, ?, ?)
'''
self.cursor.execute(query,
(section_id,
uuid,
section_name,
plex_type,
kodi_tagid,
sync_to_kodi,
last_sync))

View file

@ -5,8 +5,8 @@ from .. import variables as v
class TVShows(object):
def add_show(self, plex_id, checksum, section_id, section_uuid, kodi_id,
kodi_pathid, last_sync):
def add_show(self, plex_id, checksum, section_id, kodi_id, kodi_pathid,
last_sync):
"""
Appends or replaces tv show entry into the plex table
"""
@ -16,24 +16,22 @@ class TVShows(object):
plex_id,
checksum,
section_id,
section_uuid,
kodi_id,
kodi_pathid,
fanart_synced,
last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?)
''',
(plex_id,
checksum,
section_id,
section_uuid,
kodi_id,
kodi_pathid,
0,
last_sync))
def add_season(self, plex_id, checksum, section_id, section_uuid, show_id,
parent_id, kodi_id, last_sync):
def add_season(self, plex_id, checksum, section_id, show_id, parent_id,
kodi_id, last_sync):
"""
Appends or replaces an entry into the plex table
"""
@ -43,25 +41,23 @@ class TVShows(object):
plex_id,
checksum,
section_id,
section_uuid,
show_id,
parent_id,
kodi_id,
fanart_synced,
last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
''',
(plex_id,
checksum,
section_id,
section_uuid,
show_id,
parent_id,
kodi_id,
0,
last_sync))
def add_episode(self, plex_id, checksum, section_id, section_uuid, show_id,
def add_episode(self, plex_id, checksum, section_id, show_id,
grandparent_id, season_id, parent_id, kodi_id, kodi_fileid,
kodi_fileid_2, kodi_pathid, last_sync):
"""
@ -73,7 +69,6 @@ class TVShows(object):
plex_id,
checksum,
section_id,
section_uuid,
show_id,
grandparent_id,
season_id,
@ -84,12 +79,11 @@ class TVShows(object):
kodi_pathid,
fanart_synced,
last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''',
(plex_id,
checksum,
section_id,
section_uuid,
show_id,
grandparent_id,
season_id,
@ -107,7 +101,6 @@ class TVShows(object):
plex_id INTEGER PRIMARY KEY ASC,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER,
kodi_pathid INTEGER,
fanart_synced INTEGER,
@ -125,7 +118,6 @@ class TVShows(object):
plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE,
section_id INTEGER,
section_uuid TEXT,
show_id INTEGER, # plex_id of the parent show
parent_id INTEGER, # kodi_id of the parent show
kodi_id INTEGER,
@ -155,17 +147,16 @@ class TVShows(object):
'plex_id': entry[0],
'checksum': entry[1],
'section_id': entry[2],
'section_uuid': entry[3],
'show_id': entry[4],
'grandparent_id': entry[5],
'season_id': entry[6],
'parent_id': entry[7],
'kodi_id': entry[8],
'kodi_fileid': entry[9],
'kodi_fileid_2': entry[10],
'kodi_pathid': entry[11],
'fanart_synced': entry[12],
'last_sync': entry[13]
'show_id': entry[3],
'grandparent_id': entry[4],
'season_id': entry[5],
'parent_id': entry[6],
'kodi_id': entry[7],
'kodi_fileid': entry[8],
'kodi_fileid_2': entry[9],
'kodi_pathid': entry[10],
'fanart_synced': entry[11],
'last_sync': entry[12]
}
@staticmethod
@ -178,11 +169,10 @@ class TVShows(object):
'plex_id': entry[0],
'checksum': entry[1],
'section_id': entry[2],
'section_uuid': entry[3],
'kodi_id': entry[4],
'kodi_pathid': entry[5],
'fanart_synced': entry[6],
'last_sync': entry[7]
'kodi_id': entry[3],
'kodi_pathid': entry[4],
'fanart_synced': entry[5],
'last_sync': entry[6]
}
@staticmethod
@ -195,12 +185,11 @@ class TVShows(object):
'plex_id': entry[0],
'checksum': entry[1],
'section_id': entry[2],
'section_uuid': entry[3],
'show_id': entry[4],
'parent_id': entry[5],
'kodi_id': entry[6],
'fanart_synced': entry[7],
'last_sync': entry[8]
'show_id': entry[3],
'parent_id': entry[4],
'kodi_id': entry[5],
'fanart_synced': entry[6],
'last_sync': entry[7]
}
def season_has_episodes(self, plex_id):