Skip to content

Commit

Permalink
Änderungen / Korrekturen siehe changelog.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
rols1 committed Sep 24, 2020
1 parent c8827a5 commit c442684
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 47 deletions.
4 changes: 2 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.image.flickrexplorer" name="FlickrExplorer" version="0.6.8" provider-name="rols1 (rols1@gmx.de)">
<addon id="plugin.image.flickrexplorer" name="FlickrExplorer" version="0.7.0" provider-name="rols1 (rols1@gmx.de)">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.kodi-six" />
Expand All @@ -20,7 +20,7 @@
<email>rols1@gmx.de</email>
<assets>
<icon>icon.png</icon>
<fanart>fanart.png</fanart>
<fanart>fanart.jpg</fanart>
</assets>
</extension>
</addon>
14 changes: 13 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ CHANGE HISTORY Kodi-Addon-FlickrExplorer
Releases: https://github.com/rols1/Kodi-Addon-FlickrExplorer/releases
--------------

24.09.2020 0.7.0 fanart.png changed to fanart.jpg (dto. in addon.xml).
Icons replaced: plugin-update.png, icon.png.
Matrix-Adaption 9.0-alpha 2: change xbmc.translatePath ->
xbmcvfs.translatePath via try/except.
Matrix-Adaption in modul util_flickr: set xbmc.LOGNOTICE/xbmc.LOGINFO
dependent on PY2/PY3.
Search: list of last search-terms added (max. 25)
BuildPath: quoting for query terms to prevent url errors.

13.04.2020 0.6.9 Updater-Modul: update adjust_AddonXml - consideration of changes
in addon.xml by addon-external tools (change of position of fields).

11.04.2020 0.6.8 Dialog-Calls for Kodi Matrix adapted:
new function MyDialog (Modul util_tunein2017) added.
new function MyDialog (Modul util_flickr) added.
xbmcgui.Dialog().ok replaced with MyDialog().
xbmcgui.Dialog().yesno replaced with MyDialog(ok=False).
Special search mark '#' replaced with '&' (coding problem -> missing pics),
Expand Down
Binary file added fanart.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 55 additions & 10 deletions flickrexplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
from urllib.parse import quote, unquote, quote_plus, unquote_plus, urlencode, urljoin, urlparse, urlunparse, urlsplit, parse_qs
from urllib.request import Request, urlopen, urlretrieve
from urllib.error import URLError
try: # https://github.com/xbmc/xbmc/pull/18345 (Matrix 19.0-alpha 2)
xbmc.translatePath = xbmcvfs.translatePath
except:
pass


# Python
Expand Down Expand Up @@ -51,8 +55,8 @@

# +++++ FlickrExplorer - Addon Kodi-Version, migriert von der Plexmediaserver-Version +++++

VERSION = '0.6.8'
VDATE = '10.04.2020'
VERSION = '0.7.0'
VDATE = '22.09.2020'

#
#
Expand Down Expand Up @@ -869,17 +873,57 @@ def Gallery_single(title, gallery_id, user_id):
# Verwendet wird die freie Textsuche (s. API): Treffer möglich in Titel, Beschreibung + Tags
# Mehrere Suchbegriffe, getrennt durch Blanks, bewirken UND-Verknüpfung.
#
# 23.09.2020 Liste für letzte Suchbegriffe - hier ohne Rücksicht auf
# das Suchergebnis
#
def Search(query='', user_id='', pagenr=1, title=''):
PLog('Search: ' + query);
# wir springen direkt - Ablauf:
# Search -> Search_Work -> BuildPages (-> SeparateVideos -> ShowPhotoObject, ShowVideos)

query = get_keyboard_input() # Modul util
if query == None or query.strip() == '':
return ""
query = query.strip()

Search_Work(query=py2_encode(query), user_id=user_id)
query_file = os.path.join("%s/search_terms") % ADDON_DATA

if query == '': # Liste letzte Sucheingaben
query_recent = RLoad(query_file, abs_path=True)
if query_recent.strip():
head = L('Suche')
search_list = [head]
query_recent= query_recent.strip().splitlines()
query_recent=sorted(query_recent, key=str.lower)
search_list = search_list + query_recent
title = L('Suche') + ': ' + L('im oeffentlichen Inhalt')
ret = xbmcgui.Dialog().select(title, search_list, preselect=0)
PLog(ret)
if ret == -1:
PLog("Liste Sucheingabe abgebrochen")
return Main()
elif ret == 0:
query = ''
else:
query = search_list[ret]

if query == '':
query = get_keyboard_input() # Modul util
if query == None or query.strip() == '':
return ""
query = query.strip(); query_org = query

# wg. fehlender Rückgabewerte speichern wir ohne Rücksicht
# auf das Suchergebnis:
if query: # leere Eingabe vermeiden
query_recent= RLoad(query_file, abs_path=True) # Sucheingabe speichern
query_recent= query_recent.strip().splitlines()
if len(query_recent) >= 24: # 1. Eintrag löschen (ältester)
del query_recent[0]
query_org=py2_encode(query_org) # unquoted speichern
if query_org not in query_recent:
query_recent.append(query_org)
query_recent = "\n".join(query_recent)
query_recent = py2_encode(query_recent)
RSave(query_file, query_recent) # withcodec: code-error

Search_Work(query=py2_encode(query), user_id=user_id)

return

# --------------------------
Expand Down Expand Up @@ -945,12 +989,12 @@ def BuildPages(title, searchname, SEARCHPATH, pagemax=1, perpage=1, pagenr=1):
if page == '':
msg1=msg
MyDialog(msg1, '', '')
return li
return
PLog(page[:100])
if '<rsp stat="ok">' not in page or 'pages="0"' in page:
msg1 = L('kein Treffer')
MyDialog(msg1, '', '')
return li
return

pagemax = stringextract('pages="', '"', page)
photototal = stringextract('total="', '"', page) # z.Z. n.b.
Expand Down Expand Up @@ -1453,6 +1497,7 @@ def BuildPath(method, query_flickr, user_id, pagenr):
if 'photosets.getList' in method: # primary_photo_extras statt extras
PATH = PATH + "&text=%s&page=%s&primary_photo_extras=%s&format=rest" % (query_flickr, pagenr, extras)
else:
query_flickr = quote(query_flickr)
PATH = PATH + "&text=%s&page=%s&extras=%s&format=rest" % (query_flickr, pagenr, extras)

if SETTINGS.getSetting('sort_order'): # Bsp. 1 / date-posted-desc
Expand Down
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/__init__.pyo
Binary file not shown.
Binary file modified resources/images/plugin-update.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 55 additions & 27 deletions resources/lib/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
################################################################################
# 01.12.2019 Migration Python3 Modul kodi_six + manuelle Anpassungen
# 18.03.2020 adjust_AddonXml: Anpassung python-Version an Kodi-Version
# 13.04.2020 Aktualisierung adjust_AddonXml
################################################################################
#

Expand Down Expand Up @@ -35,7 +36,7 @@
import io # Python2+3 -> update() io.BytesIO für Zipfile

import resources.lib.util_flickr as util
PLog=util.PLog; stringextract=util.stringextract;
PLog=util.PLog; stringextract=util.stringextract; MyDialog=util.MyDialog;
cleanhtml=util.cleanhtml; RLoad=util.RLoad; RSave=util.RSave;

ADDON_ID = 'plugin.image.flickrexplorer'
Expand Down Expand Up @@ -110,7 +111,7 @@ def update_available(VERSION):

################################################################################
def update(url, ver):
PLog('update:')
PLog('update: ' + ver)

if ver:
msg1 = 'Addon Update auf Version {0}'.format(ver)
Expand Down Expand Up @@ -138,52 +139,79 @@ def update(url, ver):
msg1 = 'Update fehlgeschlagen'
msg2 = 'Error: ' + str(exception)

xbmcgui.Dialog().ok(ADDON_NAME, msg1, msg2, '')
MyDialog(msg1, msg2, '')
else:
msg1 = 'Update fehlgeschlagen'
msg2 = 'Version ' + ver + 'nicht gefunden!'
xbmcgui.Dialog().ok(ADDON_NAME, msg1, msg2, '')
MyDialog(msg1, msg2, '')

################################################################################
# adjust_AddonXml: Anpassung der python-Version in der neu installierten
# addon.xml an die akt. Kodi-Version. Passende addon.xml bleibt unver-
# ändert. Da Kodi die addon.xml erst bei Neustart od. Addon-Installation
# prüft, muss die Änderung nicht bereits vor dem Speichern erfolgen.
# prüft, muss die Änderung nicht bereits vor dem Speichern im zip erfolgen.
#
# Voraussetzung für replace: die Einträge in addon.xml entsprechen exakt
# den Marken repl_leia + repl_matrix
# Python-Versionen s. https://kodi.wiki/view/Addon.xml#Dependency_versions
# Leia / Matrix version="2.25.0" / version="3.0.0"
# Addon-Version (Bsp.): version="2.8.5" / version="2.8.5+matrix"
#
# Nach Beendigung des Updates wird bei jedem Laden des Moduls util
# in check_AddonXml das Verzeichnis ADDON_DATA angepasst (s. dort)
#
#
def adjust_AddonXml():
PLog('adjust_AddonXml:')
repl_leia = 'addon="xbmc.python" version="2.25.0"'
repl_matrix = 'addon="xbmc.python" version="3.0.0"'
KODI_VERSION = xbmc.getInfoLabel('System.BuildVersion')
path = xbmc.translatePath('special://home/addons/' + ADDON_ID + '/addon.xml')
PLog(KODI_VERSION); PLog(path)

path = xbmc.translatePath('special://home/addons/' + ADDON_ID + '/addon.xml')
PLog(path)
page = RLoad(path, abs_path=True)
change = False
if KODI_VERSION.startswith('19.'): # Kodi Matrix
if repl_leia in page:
page = page.replace(repl_leia, repl_matrix)
page = py2_encode(page)
PLog('adjust_AddonXml: ersetze %s durch %s' % (repl_leia, repl_matrix))
RSave(path, page)
change = True
else: # Kodi <= Leia
if repl_matrix in page:
page = page.replace(repl_matrix, repl_leia)
page = py2_encode(page)
PLog('adjust_AddonXml: ersetze %s durch %s' % (repl_matrix, repl_leia))
RSave(path, page)
change = True
new_lines = []
lines = page.splitlines()

for line in lines:
new_line = line
# PLog(line) # Debug
if 'addon="xbmc.python"' in line or 'addon id=' in line:
new_line = adjust_line(line)
if new_line != line:
change = True
PLog('adjust_AddonXml_oldline: %s' % line)
PLog('adjust_AddonXml_newline: %s' % new_line)
new_line = line.replace(line, new_line)
new_lines.append(new_line)

if change == False:
PLog(u'adjust_AddonXml: addon.xml unverändert')
else:
page = '\n'.join(new_lines)
RSave(path, page)
return

#------------------------------
def adjust_line(line):
PLog('adjust_line:')
KODI_VERSION = xbmc.getInfoLabel('System.BuildVersion')
PLog(KODI_VERSION)
new_line = line

if KODI_VERSION.startswith('19.'): # Anp. Kodi Matrix
if 'addon="xbmc.python"' in line:
python_ver = stringextract('version="', '"', line)
new_line = line.replace(python_ver, '3.0.0')
if 'addon id=' in line:
addon_ver = stringextract('version="', '"', line)
if 'matrix' not in line: # Anp. Addon-Version
new_line = line.replace(addon_ver, '%s+matrix' % addon_ver)

else: # Anp. Kodi <= Leia
if 'addon="xbmc.python"' in line:
python_ver = stringextract('version="', '"', line)
new_line = line.replace(python_ver, '2.25.0') # Anp. Python-Version
if 'addon id=' in line:
new_line = line.replace('+matrix', '') # Anp. Addon-Version

return new_line # unverändert

################################################################################
# save_restore: Cache sichern / wieder herstellen
# funktioniert nicht unter Windows im updater-Modul - daher hierher verlagert
Expand Down
22 changes: 15 additions & 7 deletions resources/lib/util_flickr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# util_flickr.py
#
# Stand: 10.04.2020
# Stand: 23.09.2020

# Python3-Kompatibilität:
from __future__ import absolute_import
Expand All @@ -19,10 +19,16 @@
from urllib import quote, unquote, quote_plus, unquote_plus, urlencode, urlretrieve
from urllib2 import Request, urlopen, URLError
from urlparse import urljoin, urlparse, urlunparse , urlsplit, parse_qs
LOG_MSG = xbmc.LOGNOTICE # s. PLog
elif PYTHON3:
from urllib.parse import quote, unquote, quote_plus, unquote_plus, urlencode, urljoin, urlparse, urlunparse, urlsplit, parse_qs
from urllib.request import Request, urlopen, urlretrieve
from urllib.error import URLError
LOG_MSG = xbmc.LOGINFO # s. PLog
try: # https://github.com/xbmc/xbmc/pull/18345 (Matrix 19.0-alpha 2)
xbmc.translatePath = xbmcvfs.translatePath
except:
pass

import glob, shutil, time, ssl, string
import json # json -> Textstrings
Expand Down Expand Up @@ -63,18 +69,20 @@
#
# convert_util_imports.py generiert aus util.py die Zuordnungen PLog=util.PLog; ...
####################################################################################################
#----------------------------------------------------------------
#----------------------------------------------------------------
# 23.09.2020 loglevel in Abhängigkeit von PY2/PY3 gesetzt - LOG_MSG
# s. Modulkopf
#
def PLog(msg, loglevel=xbmc.LOGDEBUG):
if DEBUG == 'false':
return

#if isinstance(msg, str): # entf. mit six
#if isinstance(msg, unicode): # entf. mit six
# msg = msg.encode('utf-8')

loglevel = xbmc.LOGNOTICE
# PLog('loglevel: ' + str(loglevel))
if loglevel >= 2:
xbmc.log("%s --> %s" % (NAME, msg), level=loglevel)
# loglevel = xbmc.LOGNOTICE # s.o.
# PLog('loglevel: ' + str(LOG_MSG))
xbmc.log("%s --> %s" % (NAME, msg), level=LOG_MSG)

#----------------------------------------------------------------
# 10.04.2020 Konvertierung 3-zeiliger Dialoge in message (Multiline)
Expand Down

0 comments on commit c442684

Please sign in to comment.