Merge conflicts videonodes.py

This commit is contained in:
tomkat83 2016-09-04 16:34:25 +02:00
parent 13ca30c742
commit bc1a9138e6

View file

@ -9,17 +9,16 @@ import xml.etree.ElementTree as etree
import xbmc import xbmc
import xbmcvfs import xbmcvfs
import utils from utils import window, settings, language as lang, IfExists, tryDecode, \
from utils import window, language as lang tryEncode, indent, normalize_nodes
################################################################################################# ###############################################################################
log = logging.getLogger("EMBY."+__name__) log = logging.getLogger("PLEX."+__name__)
################################################################################################# ###############################################################################
@utils.logging
class VideoNodes(object): class VideoNodes(object):
def __init__(self): def __init__(self):
@ -64,33 +63,33 @@ class VideoNodes(object):
else: else:
dirname = viewid dirname = viewid
path = utils.tryDecode(xbmc.translatePath( path = tryDecode(xbmc.translatePath(
"special://profile/library/video/")) "special://profile/library/video/"))
nodepath = utils.tryDecode(xbmc.translatePath( nodepath = tryDecode(xbmc.translatePath(
"special://profile/library/video/Plex-%s/" % dirname)) "special://profile/library/video/Plex-%s/" % dirname))
# Verify the video directory # Verify the video directory
# KODI BUG # KODI BUG
# Kodi caches the result of exists for directories # Kodi caches the result of exists for directories
# so try creating a file # so try creating a file
if utils.IfExists(path) is False: if IfExists(path) is False:
shutil.copytree( shutil.copytree(
src=utils.tryDecode(xbmc.translatePath( src=tryDecode(xbmc.translatePath(
"special://xbmc/system/library/video")), "special://xbmc/system/library/video")),
dst=utils.tryDecode(xbmc.translatePath( dst=tryDecode(xbmc.translatePath(
"special://profile/library/video"))) "special://profile/library/video")))
# Create the node directory # Create the node directory
if mediatype != "photos": if mediatype != "photos":
if utils.IfExists(nodepath) is False: if IfExists(nodepath) is False:
# folder does not exist yet # folder does not exist yet
self.logMsg('Creating folder %s' % nodepath, 1) log.debug('Creating folder %s' % nodepath)
xbmcvfs.mkdirs(utils.tryEncode(nodepath)) xbmcvfs.mkdirs(tryEncode(nodepath))
if delete: if delete:
dirs, files = xbmcvfs.listdir(utils.tryEncode(nodepath)) dirs, files = xbmcvfs.listdir(tryEncode(nodepath))
for file in files: for file in files:
xbmcvfs.delete(utils.tryEncode( xbmcvfs.delete(tryEncode(
(nodepath + utils.tryDecode(file)))) (nodepath + tryDecode(file))))
log.info("Sucessfully removed videonode: %s." % tagname) log.info("Sucessfully removed videonode: %s." % tagname)
return return
@ -117,7 +116,7 @@ class VideoNodes(object):
else: else:
root = self.commonRoot(order=0, label=tagname, tagname=tagname, roottype=0) root = self.commonRoot(order=0, label=tagname, tagname=tagname, roottype=0)
try: try:
utils.indent(root) indent(root)
except: pass except: pass
etree.ElementTree(root).write(nodeXML) etree.ElementTree(root).write(nodeXML)
@ -283,7 +282,7 @@ class VideoNodes(object):
# To do: add our photos nodes to kodi picture sources somehow # To do: add our photos nodes to kodi picture sources somehow
continue continue
if xbmcvfs.exists(utils.tryEncode(nodeXML)): if xbmcvfs.exists(tryEncode(nodeXML)):
# Don't recreate xml if already exists # Don't recreate xml if already exists
continue continue
@ -307,7 +306,7 @@ class VideoNodes(object):
elif nodetype == "recent": elif nodetype == "recent":
etree.SubElement(root, 'order', {'direction': "descending"}).text = "dateadded" etree.SubElement(root, 'order', {'direction': "descending"}).text = "dateadded"
etree.SubElement(root, 'limit').text = limit etree.SubElement(root, 'limit').text = limit
if utils.settings('MovieShowWatched') == 'false': if settings('MovieShowWatched') == 'false':
rule = etree.SubElement(root, rule = etree.SubElement(root,
'rule', 'rule',
{'field': "playcount", {'field': "playcount",
@ -363,15 +362,15 @@ class VideoNodes(object):
attrib={'field': "inprogress", 'operator':"true"}) attrib={'field': "inprogress", 'operator':"true"})
try: try:
utils.indent(root) indent(root)
except: pass except: pass
etree.ElementTree(root).write(nodeXML) etree.ElementTree(root).write(nodeXML)
def singleNode(self, indexnumber, tagname, mediatype, itemtype): def singleNode(self, indexnumber, tagname, mediatype, itemtype):
tagname = utils.tryEncode(tagname) tagname = tryEncode(tagname)
cleantagname = utils.normalize_nodes(tagname) cleantagname = normalize_nodes(tagname)
nodepath = utils.tryDecode(xbmc.translatePath( nodepath = tryDecode(xbmc.translatePath(
"special://profile/library/video/")) "special://profile/library/video/"))
nodeXML = "%splex_%s.xml" % (nodepath, cleantagname) nodeXML = "%splex_%s.xml" % (nodepath, cleantagname)
path = "library://video/plex_%s.xml" % cleantagname path = "library://video/plex_%s.xml" % cleantagname
@ -385,9 +384,9 @@ class VideoNodes(object):
if not xbmcvfs.exists(nodepath): if not xbmcvfs.exists(nodepath):
# We need to copy over the default items # We need to copy over the default items
shutil.copytree( shutil.copytree(
src=utils.tryDecode(xbmc.translatePath( src=tryDecode(xbmc.translatePath(
"special://xbmc/system/library/video")), "special://xbmc/system/library/video")),
dst=utils.tryDecode(xbmc.translatePath( dst=tryDecode(xbmc.translatePath(
"special://profile/library/video"))) "special://profile/library/video")))
xbmcvfs.exists(path) xbmcvfs.exists(path)
@ -418,7 +417,7 @@ class VideoNodes(object):
etree.SubElement(root, 'content').text = mediatype etree.SubElement(root, 'content').text = mediatype
try: try:
utils.indent(root) indent(root)
except: pass except: pass
etree.ElementTree(root).write(nodeXML) etree.ElementTree(root).write(nodeXML)