parent
216159d96c
commit
fd84d97a46
7 changed files with 60 additions and 30 deletions
|
@ -39,16 +39,16 @@ import xml.etree.ElementTree as etree
|
||||||
from re import compile as re_compile, sub
|
from re import compile as re_compile, sub
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from urllib import urlencode, quote_plus, unquote
|
from urllib import urlencode, quote_plus, unquote
|
||||||
from os.path import basename, join, exists
|
from os.path import basename, join
|
||||||
|
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
from xbmc import sleep, executebuiltin
|
from xbmc import sleep, executebuiltin
|
||||||
from xbmcvfs import mkdirs
|
from xbmcvfs import mkdirs, exists
|
||||||
|
|
||||||
import clientinfo as client
|
import clientinfo as client
|
||||||
from downloadutils import DownloadUtils
|
from downloadutils import DownloadUtils
|
||||||
from utils import window, settings, language as lang, tryDecode, tryEncode, \
|
from utils import window, settings, language as lang, tryDecode, tryEncode, \
|
||||||
DateToKodi
|
DateToKodi, exists_dir
|
||||||
from PlexFunctions import PMSHttpsEnabled
|
from PlexFunctions import PMSHttpsEnabled
|
||||||
import plexdb_functions as plexdb
|
import plexdb_functions as plexdb
|
||||||
import variables as v
|
import variables as v
|
||||||
|
@ -2117,10 +2117,9 @@ class API():
|
||||||
continue
|
continue
|
||||||
if fanartcount > maxfanarts:
|
if fanartcount > maxfanarts:
|
||||||
break
|
break
|
||||||
if exists(tryEncode(entry['url'])):
|
allartworks['Backdrop'].append(
|
||||||
allartworks['Backdrop'].append(
|
entry['url'].replace(' ', '%20'))
|
||||||
entry['url'].replace(' ', '%20'))
|
fanartcount += 1
|
||||||
fanartcount += 1
|
|
||||||
return allartworks
|
return allartworks
|
||||||
|
|
||||||
def getSetArtwork(self, parentInfo=False):
|
def getSetArtwork(self, parentInfo=False):
|
||||||
|
@ -2344,7 +2343,7 @@ class API():
|
||||||
|
|
||||||
Returns the path to the downloaded subtitle or None
|
Returns the path to the downloaded subtitle or None
|
||||||
"""
|
"""
|
||||||
if not exists(v.EXTERNAL_SUBTITLE_TEMP_PATH):
|
if not exists_dir(v.EXTERNAL_SUBTITLE_TEMP_PATH):
|
||||||
mkdirs(v.EXTERNAL_SUBTITLE_TEMP_PATH)
|
mkdirs(v.EXTERNAL_SUBTITLE_TEMP_PATH)
|
||||||
path = join(v.EXTERNAL_SUBTITLE_TEMP_PATH, filename)
|
path = join(v.EXTERNAL_SUBTITLE_TEMP_PATH, filename)
|
||||||
r = DownloadUtils().downloadUrl(url, return_response=True)
|
r = DownloadUtils().downloadUrl(url, return_response=True)
|
||||||
|
@ -2547,11 +2546,17 @@ class API():
|
||||||
check = exists(tryEncode(path))
|
check = exists(tryEncode(path))
|
||||||
else:
|
else:
|
||||||
# directories
|
# directories
|
||||||
if "\\" in path and not path.endswith('\\'):
|
if "\\" in path:
|
||||||
# Add the missing backslash
|
if not path.endswith('\\'):
|
||||||
check = exists(tryEncode(path + "\\"))
|
# Add the missing backslash
|
||||||
elif "/" in path and not path.endswith('/'):
|
check = exists_dir(tryEncode(path + "\\"))
|
||||||
check = exists(tryEncode(path + "/"))
|
else:
|
||||||
|
check = exists_dir(tryEncode(path))
|
||||||
|
else:
|
||||||
|
if not path.endswith('/'):
|
||||||
|
check = exists_dir(tryEncode(path + "/"))
|
||||||
|
else:
|
||||||
|
check = exists_dir(tryEncode(path))
|
||||||
|
|
||||||
if not check:
|
if not check:
|
||||||
if forceCheck is False:
|
if forceCheck is False:
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
import logging
|
import logging
|
||||||
from json import dumps, loads
|
from json import dumps, loads
|
||||||
import requests
|
import requests
|
||||||
from os.path import exists
|
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from urllib import quote_plus, unquote
|
from urllib import quote_plus, unquote
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue, Empty
|
from Queue import Queue, Empty
|
||||||
|
|
||||||
from xbmc import executeJSONRPC, sleep, translatePath
|
from xbmc import executeJSONRPC, sleep, translatePath
|
||||||
|
from xbmcvfs import exists
|
||||||
|
|
||||||
from utils import window, settings, language as lang, kodiSQL, tryEncode, \
|
from utils import window, settings, language as lang, kodiSQL, tryEncode, \
|
||||||
ThreadMethods, ThreadMethodsAdditionalStop, dialog
|
ThreadMethods, ThreadMethodsAdditionalStop, dialog, exists_dir
|
||||||
|
|
||||||
# Disable annoying requests warnings
|
# Disable annoying requests warnings
|
||||||
import requests.packages.urllib3
|
import requests.packages.urllib3
|
||||||
|
@ -229,7 +229,7 @@ class Artwork():
|
||||||
log.info("Resetting all cache data first")
|
log.info("Resetting all cache data first")
|
||||||
# Remove all existing textures first
|
# Remove all existing textures first
|
||||||
path = translatePath("special://thumbnails/")
|
path = translatePath("special://thumbnails/")
|
||||||
if exists(path):
|
if exists_dir(path):
|
||||||
rmtree(path, ignore_errors=True)
|
rmtree(path, ignore_errors=True)
|
||||||
|
|
||||||
# remove all existing data from texture DB
|
# remove all existing data from texture DB
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import logging
|
import logging
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from os import walk
|
from os import walk
|
||||||
from os.path import basename, join, exists
|
from os.path import basename, join
|
||||||
from sys import argv
|
from sys import argv
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ from xbmcgui import ListItem
|
||||||
from xbmcvfs import mkdirs
|
from xbmcvfs import mkdirs
|
||||||
|
|
||||||
from utils import window, settings, language as lang, dialog, tryEncode, \
|
from utils import window, settings, language as lang, dialog, tryEncode, \
|
||||||
CatchExceptions, JSONRPC
|
CatchExceptions, JSONRPC, exists_dir
|
||||||
import downloadutils
|
import downloadutils
|
||||||
|
|
||||||
from PlexFunctions import GetPlexMetadata, GetPlexSectionResults, \
|
from PlexFunctions import GetPlexMetadata, GetPlexSectionResults, \
|
||||||
|
@ -499,7 +499,7 @@ def getVideoFiles(plexId, params):
|
||||||
path = path.replace('\\', '\\\\')
|
path = path.replace('\\', '\\\\')
|
||||||
# Directory only, get rid of filename
|
# Directory only, get rid of filename
|
||||||
path = path.replace(basename(path), '')
|
path = path.replace(basename(path), '')
|
||||||
if exists(path):
|
if exists_dir(path):
|
||||||
for root, dirs, files in walk(path):
|
for root, dirs, files in walk(path):
|
||||||
for directory in dirs:
|
for directory in dirs:
|
||||||
item_path = join(root, directory)
|
item_path = join(root, directory)
|
||||||
|
@ -514,6 +514,7 @@ def getVideoFiles(plexId, params):
|
||||||
xbmcplugin.addDirectoryItem(handle=HANDLE,
|
xbmcplugin.addDirectoryItem(handle=HANDLE,
|
||||||
url=file,
|
url=file,
|
||||||
listitem=li)
|
listitem=li)
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
log.error('Kodi cannot access folder %s' % path)
|
log.error('Kodi cannot access folder %s' % path)
|
||||||
xbmcplugin.endOfDirectory(HANDLE)
|
xbmcplugin.endOfDirectory(HANDLE)
|
||||||
|
@ -537,7 +538,7 @@ def getExtraFanArt(plexid, plexPath):
|
||||||
# We need to store the images locally for this to work
|
# We need to store the images locally for this to work
|
||||||
# because of the caching system in xbmc
|
# because of the caching system in xbmc
|
||||||
fanartDir = translatePath("special://thumbnails/plex/%s/" % plexid)
|
fanartDir = translatePath("special://thumbnails/plex/%s/" % plexid)
|
||||||
if not exists(fanartDir):
|
if not exists_dir(fanartDir):
|
||||||
# Download the images to the cache directory
|
# Download the images to the cache directory
|
||||||
mkdirs(fanartDir)
|
mkdirs(fanartDir)
|
||||||
xml = GetPlexMetadata(plexid)
|
xml = GetPlexMetadata(plexid)
|
||||||
|
|
|
@ -4,10 +4,10 @@ import logging
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import Queue
|
import Queue
|
||||||
from random import shuffle
|
from random import shuffle
|
||||||
from os.path import exists
|
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
from xbmcvfs import exists
|
||||||
|
|
||||||
from utils import window, settings, getUnixTimestamp, sourcesXML,\
|
from utils import window, settings, getUnixTimestamp, sourcesXML,\
|
||||||
ThreadMethods, ThreadMethodsAdditionalStop, LogTime, getScreensaver,\
|
ThreadMethods, ThreadMethodsAdditionalStop, LogTime, getScreensaver,\
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from os.path import exists
|
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
|
from xbmcvfs import exists
|
||||||
|
|
||||||
|
|
||||||
from utils import window, settings, language as lang, ThreadMethods, \
|
from utils import window, settings, language as lang, ThreadMethods, \
|
||||||
|
|
|
@ -21,10 +21,10 @@ from urllib import quote_plus
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
from xbmcvfs import exists as kodi_exists, mkdirs
|
from xbmcvfs import exists, mkdirs, delete
|
||||||
|
|
||||||
from variables import DB_VIDEO_PATH, DB_MUSIC_PATH, DB_TEXTURE_PATH, \
|
from variables import DB_VIDEO_PATH, DB_MUSIC_PATH, DB_TEXTURE_PATH, \
|
||||||
DB_PLEX_PATH, KODI_PROFILE
|
DB_PLEX_PATH, KODI_PROFILE, KODIVERSION
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -92,6 +92,30 @@ def settings(setting, value=None):
|
||||||
return tryDecode(addon.getSetting(setting))
|
return tryDecode(addon.getSetting(setting))
|
||||||
|
|
||||||
|
|
||||||
|
def exists_dir(path):
|
||||||
|
"""
|
||||||
|
Safe way to check whether the directory path exists already (broken in Kodi
|
||||||
|
<17)
|
||||||
|
|
||||||
|
Feed with encoded string
|
||||||
|
"""
|
||||||
|
if KODIVERSION >= 17:
|
||||||
|
answ = exists(path)
|
||||||
|
else:
|
||||||
|
dummyfile = join(path, 'dummyfile.txt')
|
||||||
|
try:
|
||||||
|
with open(dummyfile, 'w') as f:
|
||||||
|
f.write('text')
|
||||||
|
except IOError:
|
||||||
|
# folder does not exist yet
|
||||||
|
answ = 0
|
||||||
|
else:
|
||||||
|
# Folder exists. Delete file again.
|
||||||
|
delete(dummyfile)
|
||||||
|
answ = 1
|
||||||
|
return answ
|
||||||
|
|
||||||
|
|
||||||
def language(stringid):
|
def language(stringid):
|
||||||
# Central string retrieval
|
# Central string retrieval
|
||||||
return ADDON.getLocalizedString(stringid)
|
return ADDON.getLocalizedString(stringid)
|
||||||
|
|
|
@ -4,13 +4,13 @@ import logging
|
||||||
from shutil import copytree
|
from shutil import copytree
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
from os import remove, listdir
|
from os import remove, listdir
|
||||||
from os.path import exists, isfile, join
|
from os.path import isfile, join
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
from xbmcvfs import mkdirs
|
from xbmcvfs import mkdirs, exists
|
||||||
|
|
||||||
from utils import window, settings, language as lang, tryEncode, indent, \
|
from utils import window, settings, language as lang, tryEncode, indent, \
|
||||||
normalize_nodes
|
normalize_nodes, exists_dir
|
||||||
import variables as v
|
import variables as v
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -75,14 +75,14 @@ class VideoNodes(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Verify the video directory
|
# Verify the video directory
|
||||||
if exists(path) is False:
|
if exists_dir(path) is False:
|
||||||
copytree(
|
copytree(
|
||||||
src=xbmc.translatePath("special://xbmc/system/library/video"),
|
src=xbmc.translatePath("special://xbmc/system/library/video"),
|
||||||
dst=xbmc.translatePath("special://profile/library/video"))
|
dst=xbmc.translatePath("special://profile/library/video"))
|
||||||
|
|
||||||
# Create the node directory
|
# Create the node directory
|
||||||
if mediatype != "photos":
|
if mediatype != "photos":
|
||||||
if exists(nodepath) is False:
|
if exists_dir(nodepath) is False:
|
||||||
# folder does not exist yet
|
# folder does not exist yet
|
||||||
log.debug('Creating folder %s' % nodepath)
|
log.debug('Creating folder %s' % nodepath)
|
||||||
mkdirs(nodepath)
|
mkdirs(nodepath)
|
||||||
|
@ -388,7 +388,7 @@ class VideoNodes(object):
|
||||||
windowpath = "ActivateWindow(Video,%s,return)" % path
|
windowpath = "ActivateWindow(Video,%s,return)" % path
|
||||||
|
|
||||||
# Create the video node directory
|
# Create the video node directory
|
||||||
if not exists(nodepath):
|
if not exists_dir(nodepath):
|
||||||
# We need to copy over the default items
|
# We need to copy over the default items
|
||||||
copytree(
|
copytree(
|
||||||
src=xbmc.translatePath("special://xbmc/system/library/video"),
|
src=xbmc.translatePath("special://xbmc/system/library/video"),
|
||||||
|
|
Loading…
Reference in a new issue