diff --git a/addon.xml b/addon.xml index 449d028..dee9be0 100644 --- a/addon.xml +++ b/addon.xml @@ -4,10 +4,8 @@ version="4.0.0" provider-name="dualB"> - - - - + + video diff --git a/default.py b/default.py index 41683a1..b142514 100644 --- a/default.py +++ b/default.py @@ -2,11 +2,17 @@ # version 3.2.2 - By dualB -import os, sys, traceback, xbmcplugin, xbmcaddon, xbmc, simplejson, xbmcgui +import os, sys, traceback +import xbmcaddon, xbmcplugin, xbmcvfs from resources.lib.log import log from resources.lib import content, navig +try: + import json +except ImportError: + import simplejson as json + if sys.version_info.major >= 3: # Python 3 stuff from urllib.parse import quote_plus, unquote_plus, unquote @@ -16,6 +22,8 @@ ADDON = xbmcaddon.Addon() + + def get_params(): """ function docstring """ param = [] @@ -76,7 +84,7 @@ def set_sorting_methods(mode): except Exception: pass -filtres = simplejson.loads(FILTERS) +filtres = json.loads(FILTERS) if SOURCE_ID !='': navig.jouer_video(URL,SOURCE_ID) @@ -93,7 +101,7 @@ def set_sorting_methods(mode): xbmcplugin.endOfDirectory(int(sys.argv[1])) if MODE != 4 and xbmcaddon.Addon().getSetting('DeleteTempFiFilesEnabled') == 'true': - PATH = xbmc.translatePath('special://temp').decode('utf-8') + PATH = xbmcvfs.translatePath('special://temp').decode('utf-8') FILENAMES = next(os.walk(PATH))[2] for i in FILENAMES: if ".fi" in i: diff --git a/resources/lib/cache.py b/resources/lib/cache.py index e7f21c9..e93d6f5 100644 --- a/resources/lib/cache.py +++ b/resources/lib/cache.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- # version 3.2.2 - By dualB -import xbmcaddon, os, xbmc, time, sys +import os, time, sys, io +import xbmcaddon, xbmcvfs from . import log, html ADDON = xbmcaddon.Addon() -ADDON_CACHE_BASEDIR = os.path.join(xbmc.translatePath(ADDON.getAddonInfo('path')), ".cache") +ADDON_CACHE_BASEDIR = os.path.join(xbmcvfs.translatePath(ADDON.getAddonInfo('path')), ".cache") ADDON_CACHE_TTL = float(ADDON.getSetting('CacheTTL').replace("0", ".5").replace("73", "0")) if not os.path.exists(ADDON_CACHE_BASEDIR): @@ -27,18 +28,23 @@ def is_cached_content_expired(last_update): def get_cached_content(path,verified=True,headers=[]): """ function docstring """ content = None + try: filename = get_cached_filename(path) if os.path.exists(filename) and not is_cached_content_expired(os.path.getmtime(filename)): log.log('Lecture en CACHE du contenu suivant :' + path) - content = open(filename).read() + with io.open(filename, 'r', encoding='utf-8') as fo: + content = fo.read() else: + log.log('Lecture en LIGNE du contenu suivant :' + path) content = html.get_url_txt(path,verified,headers) if len(content)>0: try: if sys.version >= "3": - file(filename, "w").write(content) # cache the requested web content + with io.open(filename, 'w', encoding='utf-8') as fo: + fo.write(content) + # open(filename, "w", encoding="utf-8").write(content) # cache the requested web content else: open(filename, "w").write(content) # cache the requested web content except Exception: @@ -51,5 +57,6 @@ def get_cached_content(path,verified=True,headers=[]): def get_cached_filename(path): """ function docstring """ - filename = "%s" % _hash(repr(path)).hexdigest() + utfName = repr(path).encode('utf-8') + filename = "%s" % _hash(utfName).hexdigest() return os.path.join(ADDON_CACHE_BASEDIR, filename) diff --git a/resources/lib/clearcache.py b/resources/lib/clearcache.py index 1faeffb..9c71306 100644 --- a/resources/lib/clearcache.py +++ b/resources/lib/clearcache.py @@ -2,17 +2,14 @@ import os import sys - -import xbmc -import xbmcgui -import xbmcvfs +import xbmcaddon, xbmcgui, xbmcvfs from xbmcaddon import Addon addon = Addon('plugin.video.telequebec') -addon_cache_basedir = os.path.join(xbmc.translatePath(addon.getAddonInfo('path')).decode('utf-8'),".cache") +addon_cache_basedir = os.path.join(xbmcvfs.translatePath(addon.getAddonInfo('path')).decode('utf-8'),".cache") if sys.argv[1].lower() == "full": - print "["+addon.getAddonInfo('name')+"] deleting full cache" + print("["+addon.getAddonInfo('name')+"] deleting full cache") for root, dirs, files in os.walk(addon_cache_basedir): for file in files: xbmcvfs.delete(os.path.join(root,file)) diff --git a/resources/lib/content.py b/resources/lib/content.py index d95e361..3700361 100644 --- a/resources/lib/content.py +++ b/resources/lib/content.py @@ -1,9 +1,14 @@ # -*- coding: utf-8 -*- # version 3.2.2 - By dualB -import sys, simplejson, re, xbmcaddon,xbmc +import sys, re +import xbmcaddon from . import cache, html, log, parse -import simplejson as json + +try: + import json +except ImportError: + import simplejson as json if sys.version_info.major >= 3: # Python 3 stuff @@ -252,17 +257,18 @@ def getImage(url,width,height): return link def getShow(mediaBundleId): - database = simplejson.loads(cache.get_cached_content(MEDIA_BUNDLE_URL + str(mediaBundleId))) + database = json.loads(cache.get_cached_content(MEDIA_BUNDLE_URL + str(mediaBundleId))) return database['data'] def getLinkPop(url): - database = simplejson.loads(cache.get_cached_content(POPULAIRE_URL + str(url))) + + database = json.loads(cache.get_cached_content(POPULAIRE_URL + str(url))) return database['data'][0] def getJsonBlock(url, block): dataBlock = [] try: - db = simplejson.loads(cache.get_cached_content(url)) + db = json.loads(cache.get_cached_content(url)) dataBlock = db['data'][block]['items'] except Exception: dataBlock = [] diff --git a/resources/lib/html.py b/resources/lib/html.py index 654992c..29ee3d4 100644 --- a/resources/lib/html.py +++ b/resources/lib/html.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # version 3.2.2 - By dualB -import sys, re, socket, xbmc, ssl +import sys, re, socket, ssl from . import log if sys.version_info.major >= 3: diff --git a/resources/lib/log.py b/resources/lib/log.py index b81630f..c5fba7e 100644 --- a/resources/lib/log.py +++ b/resources/lib/log.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # version 3.2.2 - By dualB -import xbmcaddon, xbmc +import xbmc, xbmcaddon def log(msg): """ function docstring """ diff --git a/resources/lib/navig.py b/resources/lib/navig.py index 9569f41..d5254d3 100644 --- a/resources/lib/navig.py +++ b/resources/lib/navig.py @@ -1,9 +1,15 @@ # -*- coding: utf-8 -*- # version 3.2.2 - By dualB -import sys, xbmcgui, xbmcplugin, xbmcaddon, re, simplejson, xbmc +import sys, re +import xbmc, xbmcaddon, xbmcplugin, xbmcgui from . import log, parse, content, cache +try: + import json +except ImportError: + import simplejson as json + if sys.version_info.major >= 3: # Python 3 stuff from urllib.parse import quote_plus, unquote, quote @@ -81,7 +87,7 @@ def ajouterRepertoire(show): """ function docstring """ entry_url = sys.argv[0]+"?url="+url+\ "&mode=1"+\ - "&filters="+quote(simplejson.dumps(filtres)) + "&filters="+quote(json.dumps(filtres)) is_it_ok = True liz = xbmcgui.ListItem(nom) @@ -135,7 +141,10 @@ def ajouterVideo(show): resume = name.lstrip() liz = xbmcgui.ListItem(\ - remove_any_html_tags(name), iconImage=ADDON_IMAGES_BASEPATH+"default-video.png", thumbnailImage=iconimage) + # remove_any_html_tags(name), iconImage=ADDON_IMAGES_BASEPATH+"default-video.png", thumbnailImage=iconimage) + remove_any_html_tags(name)) + #liz.setArt({'icon': ADDON_IMAGES_BASEPATH+"default-video.png"}) + liz.setArt({ 'thumb' : iconimage } ) liz.setInfo(\ type="Video",\ infoLabels={\ @@ -152,10 +161,12 @@ def ajouterVideo(show): liz.setProperty('IsPlayable', 'true') #Assumé que tous les liens sont pour Brightcove - liz.setProperty('inputstreamaddon', 'inputstream.adaptive') - liz.setProperty('inputstream.adaptive.manifest_type', 'mpd') - liz.setMimeType('application/dash+xml') liz.setContentLookup(False) + #deprecated inputstreamaddon prop was causing playback failure + liz.setProperty('inputstream', 'inputstream.adaptive') + liz.setProperty('inputstream.adaptive.manifest_type', 'mpd') + liz.setMimeType('application/xml+dash') + is_it_ok = xbmcplugin.addDirectoryItem(handle=__handle__, url=entry_url, listitem=liz, isFolder=False) return is_it_ok @@ -178,7 +189,6 @@ def liveStreamURL(): return 'https://bcovlive-a.akamaihd.net/575d86160eb143458d51f7ab187a4e68/us-east-1/6101674910001/' + obtenirMeilleurStream(a,'profile') def jouer_video(url,media_uid): - if "live" in url: jouer_live() else: @@ -187,15 +197,15 @@ def jouer_video(url,media_uid): refID = ref[len(ref)-1] - video_json = simplejson.loads(cache.get_cached_content('https://mnmedias.api.telequebec.tv/api/v4/player/%s' % refID)) + video_json = json.loads(cache.get_cached_content('https://mnmedias.api.telequebec.tv/api/v4/player/%s' % refID)) thumbnail_url = content.getImage(video_json['imageUrlTemplate'], '320', '180') uri = getURI(video_json,refID) if uri: item = xbmcgui.ListItem(\ video_json['title'],\ - iconImage=thumbnail_url,\ - thumbnailImage=thumbnail_url, path=uri) + path=uri) + item.setArt({'icon': thumbnail_url}) play_item = xbmcgui.ListItem(path=uri) xbmcplugin.setResolvedUrl(__handle__,True, item) else: @@ -214,7 +224,7 @@ def m3u8BC(sourceId): log.log('KEY : %s' % config['key']) log.log('Ad_Config_ID : %s' %config['ad']) header = {'key':'Accept','value':'application/json;pk=%s'% config['key'] } - a= simplejson.loads(cache.get_cached_content('https://edge.api.brightcove.com/playback/v1/accounts/6150020952001/videos/%s?ad_config_id=%s' %(sourceId,config['ad']) ,True,[header])) + a= json.loads(cache.get_cached_content('https://edge.api.brightcove.com/playback/v1/accounts/6150020952001/videos/%s?ad_config_id=%s' %(sourceId,config['ad']) ,True,[header])) last = None for source in a['sources']: protocol = "dash+xml" @@ -233,7 +243,7 @@ def getBrightcoveConfig(): answer['ad'] = 'dcd6de5f-a864-4ef6-b416-dcdc4f4af216' try: data = cache.get_cached_content('https://players.brightcove.net/6150020952001/default_default/config.json',True) - jsonData = simplejson.loads(data) + jsonData = json.loads(data) answer['key'] =jsonData['video_cloud']['policy_key'] answer['ad'] = jsonData['ad_config_id'] diff --git a/resources/lib/parse.py b/resources/lib/parse.py index a72495a..d05f505 100644 --- a/resources/lib/parse.py +++ b/resources/lib/parse.py @@ -35,7 +35,7 @@ def ListeVideosGroupees(filtres): if index >= len(filtresShow): return liste else: - groupBy = filtresShow.keys()[index] + groupBy = list(filtresShow)[index] showsGroupes = {} cle = '' diff --git a/resources/settings.xml b/resources/settings.xml index 8fc799b..cec83c0 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -1,21 +1,21 @@ - - - - - + + + + + - - - - + + + + --> - - + +