Skip to content
6 changes: 2 additions & 4 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
version="4.0.0"
provider-name="dualB">
<requires>
<import addon="xbmc.json" version="6.0.0"/>
<import addon="xbmc.addon" version="12.0.0"/>
<import addon="script.module.simplejson" version="3.16.1"/>
<import addon="script.module.inputstreamhelper" version="0.5.2"/>
<import addon="script.module.simplejson" version="3.17.0"/>
<import addon="inputstream.adaptive" version="19.0.2"/>
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
<provides>video</provides>
Expand Down
14 changes: 11 additions & 3 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,6 +22,8 @@

ADDON = xbmcaddon.Addon()



def get_params():
""" function docstring """
param = []
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
17 changes: 12 additions & 5 deletions resources/lib/cache.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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:
Expand All @@ -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)
9 changes: 3 additions & 6 deletions resources/lib/clearcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
16 changes: 11 additions & 5 deletions resources/lib/content.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/html.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/log.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# version 3.2.2 - By dualB

import xbmcaddon, xbmc
import xbmc, xbmcaddon

def log(msg):
""" function docstring """
Expand Down
34 changes: 22 additions & 12 deletions resources/lib/navig.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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={\
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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"
Expand All @@ -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']

Expand Down
2 changes: 1 addition & 1 deletion resources/lib/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def ListeVideosGroupees(filtres):
if index >= len(filtresShow):
return liste
else:
groupBy = filtresShow.keys()[index]
groupBy = list(filtresShow)[index]
showsGroupes = {}
cle = ''

Expand Down
22 changes: 11 additions & 11 deletions resources/settings.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<!-- APPARENCE -->
<category label="32100">
<setting label="32101" type="bool" id="FanartEnabled" default="true"/>
<setting label="32102" type="bool" id="FanartEmissionsEnabled" default="true" enable="eq(-1,true)"/>
<setting label="32114" type="bool" id="EmissionNameInPlotEnabled" default="true"/>
<setting label="32116" type="select" id="MaxResolution" values="480|540|720|1080" default="1080"/>
<category label="Apparence">
<setting label="Activer le fanart de l'addiciel" type="bool" id="FanartEnabled" default="true"/>
<setting label="Si disponible, utiliser l'image de l'émission en fanart" type="bool" id="FanartEmissionsEnabled" default="true" enable="eq(-1,true)"/>
<setting label="Afficher le nom de l'émission dans le section descriptive" type="bool" id="EmissionNameInPlotEnabled" default="true"/>
<setting label="Résolution maximale" type="select" id="MaxResolution" values="480|540|720|1080" default="1080"/>
</category>

<!-- ADVANCE -->
<category label="32110">
<setting label="32122" type="bool" id="DeleteTempFiFilesEnabled" default="false"/>
<setting label="32106" type="enum" id="CacheTTL" lvalues="32200|32201|32202|32203|32204|32205|32206|32207|32208|32209|32210|32211|32212|32213|32214|32215|32216|32217|32218|32219|32220|32221|32222|32223|32224|32225|32226|32227|32228|32229|32230|32231|32232|32233|32234|32235|32236|32237|32238|32239|32240|32241|32242|32243|32244|32245|32246|32247|32248|32249|32250|32251|32252|32253|32254|32255|32256|32257|32258|32259|32260|32261|32262|32263|32264|32265|32266|32267|32268|32269|32270|32271|32272|32273" default="24" />
<setting label="32107" type="action" action="RunScript($CWD/resources/lib/clearcache.py,full)" default="" />
<category label="Paramètres Avancés">
<setting label="Auto-supprimer les fichiers temporaires .fi de Kodi" type="bool" id="DeleteTempFiFilesEnabled" default="false"/>
<setting label="Durée de vie des informations gardées en cache" type="enum" id="CacheTTL" lvalues="32200|32201|32202|32203|32204|32205|32206|32207|32208|32209|32210|32211|32212|32213|32214|32215|32216|32217|32218|32219|32220|32221|32222|32223|32224|32225|32226|32227|32228|32229|32230|32231|32232|32233|32234|32235|32236|32237|32238|32239|32240|32241|32242|32243|32244|32245|32246|32247|32248|32249|32250|32251|32252|32253|32254|32255|32256|32257|32258|32259|32260|32261|32262|32263|32264|32265|32266|32267|32268|32269|32270|32271|32272|32273" default="24" />
<setting label="Nettoyer le cache maintenant!" type="action" action="RunScript($CWD/resources/lib/clearcache.py,full)" default="" />
<setting type="lsep" /> -->
<setting label="32115" type="bool" id="NetworkDetection" default="true"/>
<setting label="32104" type="bool" id="DebugMode" default="false"/>
<setting label="Afficher un message au démarrage" type="bool" id="NetworkDetection" default="true"/>
<setting label="Mode débogue - Consultez le fichier des logs de Kodi" type="bool" id="DebugMode" default="false"/>
</category>

</settings>