PK jPT30 0 script.module.worldtv/addon.py# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 - 2019 RACC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
from __future__ import unicode_literals
import sys
from xbmcgui import ListItem
from kodi_six import xbmc, xbmcgui, xbmcaddon, xbmcplugin
from routing import Plugin
import os
import time
from requests.exceptions import RequestException
from resources.lib.uktvnow import UKTVNow
addon = xbmcaddon.Addon()
plugin = Plugin()
plugin.name = addon.getAddonInfo("name")
USER_DATA_DIR = xbmc.translatePath(addon.getAddonInfo("profile"))
data_time = int(addon.getSetting("data_time") or "0")
cache_time = int(addon.getSetting("cache_time") or "0")
if not os.path.exists(USER_DATA_DIR):
os.makedirs(USER_DATA_DIR)
def log(msg, level=xbmc.LOGNOTICE):
xbmc.log("[{0}] {1}".format(plugin.name, msg), level=level)
TV = UKTVNow(USER_DATA_DIR)
current_time = int(time.time())
if current_time - data_time > cache_time * 60 * 60:
try:
TV.update_channels()
addon.setSetting("data_time", str(current_time))
log("[{0}] Channels updated".format(current_time))
except (ValueError, RequestException) as e:
if data_time == 0:
""" No data """
log(e.message)
dialog = xbmcgui.Dialog()
dialog.notification(plugin.name, repr(e.message), xbmcgui.NOTIFICATION_ERROR)
xbmcplugin.endOfDirectory(plugin.handle, False)
else:
""" Data update failed """
log("[{0}] Channels update fail, data age: {1}".format(current_time, data_time))
log(e.message)
@plugin.route("/")
def root():
list_items = []
for cat in TV.get_categories():
li = ListItem(cat.cat_name, offscreen=True)
url = plugin.url_for(list_channels, cat_id=cat.cat_id)
list_items.append((url, li, True))
xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.addDirectoryItems(plugin.handle, list_items)
xbmcplugin.endOfDirectory(plugin.handle)
@plugin.route("/list_channels/")
def list_channels(cat_id=None):
list_items = []
for channel in TV.get_channels_by_category(cat_id):
title = "{0} - {1}".format(channel.country, channel.channel_name.rstrip(".,-"))
image = TV.image_url(channel.img)
li = ListItem(title, offscreen=True)
li.setProperty("IsPlayable", "true")
li.setArt({"thumb": image, "icon": image})
li.setInfo(type="Video", infoLabels={"Title": title, "mediatype": "video"})
li.setContentLookup(False)
url = plugin.url_for(play, pk_id=channel.pk_id)
list_items.append((url, li, False))
xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.addDirectoryItems(plugin.handle, list_items)
xbmcplugin.setContent(plugin.handle, "videos")
xbmcplugin.endOfDirectory(plugin.handle)
@plugin.route("/play//play.pvr")
def play(pk_id):
channel = TV.get_channel_by_id(pk_id)
title = "{0} - {1}".format(channel.country, channel.channel_name.rstrip(".,-"))
image = TV.image_url(channel.img)
try:
links = TV.get_channel_links(pk_id)
if addon.getSetting("autoplay") == "true":
link = links[0]
elif len(links) > 1:
dialog = xbmcgui.Dialog()
ret = dialog.select("Choose Stream", links)
link = links[ret]
else:
link = links[0]
if "playlist.m3u8" in link:
if addon.getSetting("inputstream") == "true":
li = ListItem(title, path=link, offscreen=True)
li.setMimeType("application/vnd.apple.mpegurl")
li.setProperty("inputstreamaddon", "inputstream.adaptive")
li.setProperty("inputstream.adaptive.manifest_type", "hls")
li.setProperty("inputstream.adaptive.stream_headers", link.split("|")[-1])
else:
li = ListItem(title, path=link, offscreen=True)
li.setMimeType("application/vnd.apple.mpegurl")
else:
li = ListItem(title, path=link, offscreen=True)
li.setArt({"thumb": image, "icon": image})
li.setContentLookup(False)
xbmcplugin.setResolvedUrl(plugin.handle, True, li)
except (ValueError, RequestException) as e:
log(e.message)
dialog = xbmcgui.Dialog()
dialog.notification(plugin.name, repr(e.message), xbmcgui.NOTIFICATION_ERROR)
xbmcplugin.setResolvedUrl(plugin.handle, False, ListItem())
if __name__ == "__main__":
plugin.run(sys.argv)
del TV
PK jP%2 2 script.module.worldtv/addon.xml
alltrueThis module has been cloned from the Racc TvOne add-on. All credit to The Original Dev.World TVallGPL-3.0
PK jPm_!G G script.module.worldtv/fanart.jpg JFIF ` ` hExif MM * > F( 1 N ` ` paint.net 4.2.10 C
%,'..+'+*17F;14B4*+=S>BHJNON/;V\UL[FMNK C
$$K2+2KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 8!
} !1AQa"q2#BR$3br
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz
w !1AQaq"2B #3Rbr
$4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ? lQА Q@ Q@ b
1I \Q ( .( (PPhsJ
4fp4 i3@Z1@)( ▀Q@"c4b7 bP)3@h .i()3@
(h4 J1@
8 (&M4M4@% PJ .sFhE( C@ K@J(p)H 3A&I&&I@ qK@ R f@ J Z (4( .( CI@ K@
)h
P("
1@)bbHhQ@% b
Z (PPFh .1@ E % Q@ b RPhE8
1A
J (44P@ i 1E /JL
fA RbQ 1E E1@1@
( bQ \R( ▀
1@ ќP3@ 4 viA Qf
\ Bi2( B( E 4HM &h