From e74160a72645b936295da8bed6dbd260789b23ce Mon Sep 17 00:00:00 2001 From: Cigaras Date: Fri, 17 Mar 2017 13:35:42 +0200 Subject: [PATCH] Version 2.0.5 * Images path fix (#96) * Local images path support (experimental) --- Contents/Code/__init__.py | 23 +++++++++++++++-------- Contents/DefaultPrefs.json | 4 ++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 7d7d2fe..5a3f2e9 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -12,7 +12,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# Version 2.0.4 +# Version 2.0.5 from m3u_parser import LoadPlaylist, PlaylistReloader from xmltv_parser import GuideReloader @@ -209,13 +209,20 @@ def GetImage(file_name, default): if file_name: if file_name.startswith('http'): return Resource.ContentsOfURLWithFallback(file_name, fallback = R(default)) - elif Prefs['images_url'].startswith('http'): - file_name = Prefs['images_url'] + file_name if Prefs['images_url'].endswith('/') else Prefs['images_url'] + '/' + file_name - return Resource.ContentsOfURLWithFallback(file_name, fallback = R(default)) - else: - r = R(file_name) - if r: - return r + if Prefs['images_path']: + path = Prefs['images_path'] + if path.startswith('http'): + file_name = path + file_name if path.endswith('/') else path + '/' + file_name + return Resource.ContentsOfURLWithFallback(file_name, fallback = R(default)) + else: + if '/' in path and not '\\' in path: + # must be unix system, might not work + file_name = path + file_name if path.endswith('/') else path + '/' + file_name + elif '\\' in path and not '/' in path: + file_name = path + file_name if path.endswith('\\') else path + '\\' + file_name + r = R(file_name) + if r: + return r return R(default) #################################################################################################### diff --git a/Contents/DefaultPrefs.json b/Contents/DefaultPrefs.json index 50c0296..604ef37 100644 --- a/Contents/DefaultPrefs.json +++ b/Contents/DefaultPrefs.json @@ -12,8 +12,8 @@ "default": "" }, { - "id": "images_url", - "label": "URL path where images are located, if left empty images will be loaded from Resources folder", + "id": "images_path", + "label": "Local path (experimental) or URL where images are located, if left empty images will be loaded from Resources folder", "type": "text", "default": "" },