add compatibility with KODI < 17

more minor cleanups
This commit is contained in:
bassdart 2018-11-16 22:26:08 +01:00
parent c70ca839e6
commit 52309f543a
2 changed files with 41 additions and 15 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.vidfltr" name="VIDFLTR Music Videos" version="0.9.3" provider-name="bassdart">
<addon id="plugin.video.vidfltr" name="VIDFLTR Music Videos" version="0.9.4" provider-name="bassdart">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.kodi-six" />
@ -11,10 +11,10 @@
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">assorted collection of mostly electronic music videos</summary>
<description lang="en_GB">Addon for https://vidfltr.slashproc.org</description>
<description lang="en_GB">Add-on to play videos listed on https://vidfltr.slashproc.org</description>
<disclaimer lang="en_GB">A few videos don't work in every country</disclaimer>
<summary lang="de_DE">assorted collection of mostly electronic music videos</summary>
<description lang="de_DE">Addon für https://vidfltr.slashproc.org</description>
<description lang="de_DE">Add-on für https://vidfltr.slashproc.org</description>
<disclaimer lang="de_DE">Ein Paar Videos funktionieren nicht in allen Ländern</disclaimer>
<language></language>
<platform>all</platform>
@ -23,7 +23,10 @@
<website>https://vidfltr.slashproc.org/</website>
<email></email>
<source>https://kodi.slashproc.org/repo/plugin.video.vidfltr/</source>
<news>0.9.3
<news>0.9.4
- add compatibility with KODI < 17
- more minor cleanups
0.9.3
- Minor cleanups
0.9.2
- New: "More from..." artist context menu

View file

@ -18,7 +18,9 @@ pluginhandle = int(sys.argv[1])
translation = addon.getLocalizedString
addonDir = xbmc.translatePath(addon.getAddonInfo('path'))
defaultFanart = os.path.join(addonDir, 'resources/images/noicon.png')
fanart = os.path.join(addonDir, 'noicon.png')
#fanart = os.path.join(addonDir, 'noicon.png')
# don't use special folder icons as long as there is'nt a nice icon for every style
fanart = 'DefaultFolder.png'
icon = os.path.join(addonDir, 'noicon.png')
addon_work_folder = xbmc.translatePath("special://profile/addon_data/" + addonID)
jsonVideos = xbmc.translatePath("special://profile/addon_data/" + addonID + "/videos.json")
@ -48,6 +50,8 @@ ccounthigh = int(addon.getSetting("ccounthigh"))
likecounthigh = int(addon.getSetting("likecounthigh"))
# dislike count considered to be high
dislikecounthigh = int(addon.getSetting("dislikecounthigh"))
# needed for comapatibilty mode used with KODI <= 17 aka Krypton
xbmcversion = int(xbmc.getInfoLabel('System.BuildVersion')[:2])
# play from here. Does work in general but refreshes the container which is bit contra-productive in random lists ;)
# XBMC.PlayMedia(plugin://plugin.video.vidfltr/?mode=sortTitlesBy&url=year%7crandom%7c-1,isdir)
@ -276,7 +280,10 @@ def styles():
length = len(channels)
channels.sort()
for channel in channels:
addDir(channel, '&style=' + channel + '&sort=' + sort, 'showChannel', getFanart(channel), length)
# don't use special folder icons as long as there is'nt a nice icon for every style
# addDir(channel, '&style=' + channel + '&sort=' + sort, 'showChannel', getFanart(channel), length)
# don't use special folder icons as long as there is'nt a nice icon for every style
addDir(channel, '&style=' + channel + '&sort=' + sort, 'showChannel', fanart, length)
endOfDirectory()
@ -753,10 +760,13 @@ def sortTitlesBy(limit, sort, start):
else:
maximum = len(result)
# play all (TODO)
addDir(translation(30109), '', '', fanart)
# addDir(translation(30109), '', '', fanart)
# back to VIDFLTR (only useful if the back history would be cleared)
# if start > 0:
# addDir(translation(30108), '', 'main', fanart)
# hm, do I really want to replace the playlist on entering a folder?
# playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
# playlist.clear()
for entry in result[start:end]:
addVideo(entry, mycount)
if maximum > end and sort != "random" and channel != "year":
@ -829,7 +839,7 @@ def search(channel=""):
result.append(cEntry)
result.sort(key=lambda entry: entry['style'].lower())
result.sort(key=lambda entry: entry['title'].lower())
for entry in result:
addVideo(entry)
endOfDirectory()
@ -893,7 +903,12 @@ def addDir(name, url, mode, iconimage, total=0):
u = sys.argv[0] + "?url=" + urllib.quote_plus(url.encode('utf-8')) + "&mode=" + str(mode)
# xbmc.log(msg=u, level=xbmc.LOGNOTICE)
ok = True
liz = xbmcgui.ListItem(name, iconImage=icon, thumbnailImage=iconimage, offscreen=True)
# if (xbmcversion < 17):
liz = xbmcgui.ListItem(name, iconImage=icon, thumbnailImage=iconimage)
# else:
# With offscreen=true large lists (=folder) load much faster (needs >= krypton)
# But at the end, the differences are minimal in VIDFLTR, so just drop it :-)
# liz = xbmcgui.ListItem(name, iconImage=icon, thumbnailImage=iconimage, offscreen=True)
description = ""
if mode == "showChannel":
data = getStyles()
@ -912,6 +927,10 @@ def addDir(name, url, mode, iconimage, total=0):
def addVideo(entry, mycount="playcount"):
ok = True
# initiaize the global video playlist. The item will be added later
# playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
# Altlast. Sinn dahinter?
if len(entry) > 7:
dateadded = datetime.utcfromtimestamp(float(entry['slug']))
@ -944,20 +963,24 @@ def addVideo(entry, mycount="playcount"):
#link = entry['slug']
fanart = entry['thumbnail']
duration = entry['duration']
# Soll man das nun nutzen oder nicht?
# Mit offscreen=true werden Listen zigmal schneller dargestellt (klappt erst ab krypton)
li = xbmcgui.ListItem(title, offscreen=True)
# if (xbmcversion < 17):
li = xbmcgui.ListItem(title)
# else:
# li = xbmcgui.ListItem(title, offscreen=True)
li.setInfo(type="video", infoLabels={ "mediatype": mediatype, "Title": title, "Originaltitle": tracktitle, "Genre": style, "Director": director, "PlotOutline": description, "Plot": description, "Tagline": style, "Artist": entry['artists'], "dateadded": dateadded, "playcount": playcount, "Duration": duration})
li.setArt({'thumb': fanart})
li.setProperty("fanart_image", fanart)
li.setProperty('IsPlayable', 'true')
# I could add all entries to the current, global playlist but it doesn't look right
# Imo at the end it's better if the user just uses "play from here" or the auto play next setting
# playlist.add(url=url, listitem=li)
li.addContextMenuItems([
(translation(30121),'XBMC.Container.Update(plugin://'+addonID+'/?mode=sortTitlesBy&url=%26start%3d'+slug+'%26limit%3drelated%26sort%3dnone)',),
(translation(30122),'XBMC.Container.Update(plugin://'+addonID+'/?mode=sortArtists&url=relartists%7C'+slug+')',)
],replaceItems=True)
])
ok = xbmcplugin.addDirectoryItem(handle=pluginhandle, url=url, listitem=li)
return ok