Fix refreshing playlists and videonodes
This commit is contained in:
parent
dc2ae721e6
commit
cbfa41de99
1 changed files with 31 additions and 13 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
|
from os import path as ospath
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
@ -41,7 +42,6 @@ class VideoNodes(object):
|
||||||
return root
|
return root
|
||||||
|
|
||||||
def viewNode(self, indexnumber, tagname, mediatype, viewtype, viewid, delete=False):
|
def viewNode(self, indexnumber, tagname, mediatype, viewtype, viewid, delete=False):
|
||||||
|
|
||||||
# Plex: reassign mediatype due to Kodi inner workings
|
# Plex: reassign mediatype due to Kodi inner workings
|
||||||
mediatypes = {
|
mediatypes = {
|
||||||
'movie': 'movies',
|
'movie': 'movies',
|
||||||
|
@ -65,23 +65,41 @@ class VideoNodes(object):
|
||||||
"special://profile/library/video/Plex-%s/" % dirname).decode('utf-8')
|
"special://profile/library/video/Plex-%s/" % dirname).decode('utf-8')
|
||||||
|
|
||||||
# Verify the video directory
|
# Verify the video directory
|
||||||
if not xbmcvfs.exists(path.encode('utf-8')):
|
# KODI BUG
|
||||||
|
# Kodi caches the result of exists for directories
|
||||||
|
# so try creating a file
|
||||||
|
dummyfile = ospath.join(path, 'dummyfile.txt').encode('utf-8')
|
||||||
|
try:
|
||||||
|
etree.ElementTree(etree.Element('test')).write(dummyfile)
|
||||||
|
except:
|
||||||
|
# path does not exist yet
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
src=xbmc.translatePath("special://xbmc/system/library/video").decode('utf-8'),
|
src=xbmc.translatePath("special://xbmc/system/library/video").decode('utf-8'),
|
||||||
dst=xbmc.translatePath("special://profile/library/video").decode('utf-8'))
|
dst=xbmc.translatePath("special://profile/library/video").decode('utf-8'))
|
||||||
xbmcvfs.exists(path.encode('utf-8'))
|
else:
|
||||||
|
# path exists - delete dummy file
|
||||||
|
xbmcvfs.delete(dummyfile)
|
||||||
|
|
||||||
# Create the node directory
|
# Create the node directory
|
||||||
if not xbmcvfs.exists(nodepath.encode('utf-8')) and not mediatype == "photo":
|
if mediatype != "photo":
|
||||||
# We need to copy over the default items
|
dummyfile = ospath.join(nodepath, 'dummyfile.txt').encode('utf-8')
|
||||||
|
try:
|
||||||
|
etree.ElementTree(etree.Element('test')).write(dummyfile)
|
||||||
|
except:
|
||||||
|
# folder does not exist yet
|
||||||
|
self.logMsg('Creating folder %s' % nodepath, 1)
|
||||||
xbmcvfs.mkdirs(nodepath.encode('utf-8'))
|
xbmcvfs.mkdirs(nodepath.encode('utf-8'))
|
||||||
else:
|
else:
|
||||||
|
# path exists - delete dummy file
|
||||||
|
xbmcvfs.delete(dummyfile)
|
||||||
if delete:
|
if delete:
|
||||||
dirs, files = xbmcvfs.listdir(nodepath.encode('utf-8'))
|
dirs, files = xbmcvfs.listdir(nodepath.encode('utf-8'))
|
||||||
for file in files:
|
for file in files:
|
||||||
xbmcvfs.delete((nodepath + file).encode('utf-8'))
|
xbmcvfs.delete(
|
||||||
|
(nodepath + file.decode('utf-8')).encode('utf-8'))
|
||||||
|
|
||||||
self.logMsg("Sucessfully removed videonode: %s." % tagname, 1)
|
self.logMsg("Sucessfully removed videonode: %s."
|
||||||
|
% tagname, 1)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Create index entry
|
# Create index entry
|
||||||
|
|
Loading…
Add table
Reference in a new issue