summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLunatixz <Lunatixz@users.noreply.github.com>2017-09-01 09:12:34 -0400
committerenen92 <enen92@users.noreply.github.com>2017-09-01 14:12:34 +0100
commit16143b1eed2b3e60d8bd1ce86f79966c09ae9059 (patch)
treebac24c73195216939cf77f28b588678fd5134100
parent89c72fc264899e6d36a4e4378ab2d8540d095554 (diff)
[plugin.video.newson] 1.0.3 (#1388)
-rw-r--r--plugin.video.newson/addon.xml8
-rw-r--r--plugin.video.newson/default.py255
-rw-r--r--plugin.video.newson/fanart.jpgbin139008 -> 0 bytes
-rw-r--r--plugin.video.newson/resources/__init__.py0
-rw-r--r--plugin.video.newson/resources/images/fanart.jpgbin0 -> 103323 bytes
-rw-r--r--plugin.video.newson/resources/images/icon.png (renamed from plugin.video.newson/icon.png)bin34531 -> 34531 bytes
-rw-r--r--plugin.video.newson/resources/images/newscast.jpgbin35353 -> 41811 bytes
-rw-r--r--plugin.video.newson/resources/images/videoclips.jpgbin34096 -> 40763 bytes
-rw-r--r--plugin.video.newson/resources/lib/__init__.py0
-rw-r--r--plugin.video.newson/resources/lib/newson.py271
10 files changed, 278 insertions, 256 deletions
diff --git a/plugin.video.newson/addon.xml b/plugin.video.newson/addon.xml
index a2d754c..61b7dfd 100644
--- a/plugin.video.newson/addon.xml
+++ b/plugin.video.newson/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<addon id="plugin.video.newson" version="1.0.2" name="NewsON" provider-name="Lunatixz">
+<addon id="plugin.video.newson" version="1.0.3" name="NewsON" provider-name="Lunatixz">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.simplecache" version="1.0.0"/>
@@ -16,10 +16,10 @@
<source>https://github.com/Lunatixz/XBMC_Addons/tree/master/plugin.video.newson</source>
<website>http://watchnewson.com/</website>
<forum>https://forum.kodi.tv/showthread.php?tid=315924</forum>
- <news>v1.0.1[CR]- Updated cache parameters, Improved error detection.,v1.0.2[CR]- Updated cache parameters.</news>
+ <news>v1.0.3[CR]- Plugin improvments.[CR]v1.0.2[CR]- Updated cache parameters.[CR]v1.0.1[CR]- Updated cache parameters, Improved error detection.</news>
<assets>
- <icon>icon.png</icon>
- <fanart>fanart.jpg</fanart>
+ <icon>resources/images/icon.png</icon>
+ <fanart>resources/images/fanart.jpg</fanart>
<screenshot>resources/images/screenshot01.png</screenshot>
<screenshot>resources/images/screenshot02.png</screenshot>
<screenshot>resources/images/screenshot03.png</screenshot>
diff --git a/plugin.video.newson/default.py b/plugin.video.newson/default.py
index 30e1be0..4d85239 100644
--- a/plugin.video.newson/default.py
+++ b/plugin.video.newson/default.py
@@ -17,256 +17,7 @@
# along with NewsOn. If not, see <http://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
-import os, sys, time, datetime, re, traceback, feedparser
-import urllib, urllib2, socket, json, collections, gzip
-import xbmc, xbmcgui, xbmcplugin, xbmcvfs, xbmcaddon
-from StringIO import StringIO
-from simplecache import SimpleCache
-# Plugin Info
-ADDON_ID = 'plugin.video.newson'
-REAL_SETTINGS = xbmcaddon.Addon(id=ADDON_ID)
-ADDON_NAME = REAL_SETTINGS.getAddonInfo('name')
-SETTINGS_LOC = REAL_SETTINGS.getAddonInfo('profile')
-ADDON_PATH = REAL_SETTINGS.getAddonInfo('path').decode('utf-8')
-ADDON_VERSION = REAL_SETTINGS.getAddonInfo('version')
-ICON = REAL_SETTINGS.getAddonInfo('icon')
-FANART = REAL_SETTINGS.getAddonInfo('fanart')
-LANGUAGE = REAL_SETTINGS.getLocalizedString
-NEWSART = os.path.join(ADDON_PATH,'resources','images','newscast.jpg')
-CLIPART = os.path.join(ADDON_PATH,'resources','images','videoclips.jpg')
-
-## GLOBALS ##
-TIMEOUT = 30
-DEBUG = REAL_SETTINGS.getSetting('Enable_Debugging') == 'true'
-BASE_API = 'http://watchnewson.com/api/linear/channels'
-MENU = [("Newscasts" , '0', 0, False, {"thumb":NEWSART,"poster":NEWSART,"fanart":FANART,"icon":ICON,"logo":ICON}),
- ("Video Clips", '2', 2, False, {"thumb":CLIPART,"poster":CLIPART,"fanart":FANART,"icon":ICON,"logo":ICON})]
-
-def log(msg, level=xbmc.LOGDEBUG):
- if DEBUG == True:
- if level == xbmc.LOGERROR:
- msg += ' ,' + traceback.format_exc()
- xbmc.log(ADDON_ID + '-' + ADDON_VERSION + '-' + stringify(msg), level)
-
-def stringify(string):
- if isinstance(string, list):
- string = (string[0])
- elif isinstance(string, (int, float, long, complex, bool)):
- string = str(string)
-
- if isinstance(string, basestring):
- if not isinstance(string, unicode):
- string = unicode(string, 'utf-8')
- elif isinstance(string, unicode):
- string = string.encode('ascii', 'ignore')
- else:
- string = string.encode('utf-8', 'ignore')
- return string
-
-def getParams():
- param=[]
- if len(sys.argv[2])>=2:
- params=sys.argv[2]
- cleanedparams=params.replace('?','')
- if (params[len(params)-1]=='/'):
- params=params[0:len(params)-2]
- pairsofparams=cleanedparams.split('&')
- param={}
- for i in range(len(pairsofparams)):
- splitparams={}
- splitparams=pairsofparams[i].split('=')
- if (len(splitparams))==2:
- param[splitparams[0]]=splitparams[1]
- return param
-
-socket.setdefaulttimeout(TIMEOUT)
-class NewsOn():
- def __init__(self):
- log('__init__')
- self.cache = SimpleCache()
- self.stateMenu = self.getStates()
-
-
- def openURL(self, url):
- try:
- cacheResponce = self.cache.get(ADDON_NAME + '.openURL, url = %s'%url)
- if not cacheResponce:
- request = urllib2.Request(url)
- request.add_header('Accept-encoding', 'gzip')
- request.add_header('User-Agent','Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)')
- responce = urllib2.urlopen(request, timeout = TIMEOUT)
- log(responce.headers['content-type'])
- log(responce.headers['content-encoding'])
- if responce.info().get('content-encoding') == 'gzip':
- buf = StringIO(responce.read())
- f = gzip.GzipFile(fileobj=buf)
- results = json.loads(f.read())
- else:
- results = json.load(responce)
- responce.close()
- self.cache.set(ADDON_NAME + '.openURL, url = %s'%url, results, expiration=datetime.timedelta(hours=1))
- return self.cache.get(ADDON_NAME + '.openURL, url = %s'%url)
- except urllib2.URLError, e:
- log("openURL Failed! " + str(e), xbmc.LOGERROR)
- except socket.timeout, e:
- log("openURL Failed! " + str(e), xbmc.LOGERROR)
- except:
- xbmcgui.Dialog().notification(ADDON_NAME, LANGUAGE(30001), ICON, 4000)
-
-
- def mainMenu(self):
- log('mainMenu')
- for item in MENU:
- self.addDir(*item)
-
-
- def browseMenu(self, id=1):
- log('browseMenu, id = ' + str(id))
- self.stateMenu = [tuple(s.format(id) for s in tup) for tup in self.stateMenu]
- for item in self.stateMenu:
- self.addDir(*item)
-
-
- def getStates(self):
- log('getStates')
- state = []
- stateLST = []
- data = self.openURL(BASE_API)
- if data:
- for channel in data:
- state.append(channel['config']['state'])
- states = collections.Counter(state)
- for key, value in sorted(states.iteritems()):
- stateLST.append(("%s"%(key), key , '{}'))
- return stateLST
-
-
- def newsCasts(self, state):
- log('newsCasts, state = ' + state)
- urls = []
- data = self.openURL(BASE_API)
- if data:
- for channel in data:
- if state in channel['config']['state']:
- chid = channel['identifier']
- title = channel['title']
- icon = (channel['icon'] or ICON)
- for idx, stream in enumerate(channel['streams']):
- #multiple urls, only add unique.
- url = (stream['Url'].split('.m3u8?')[0])+'.m3u8'
- offset = stream['OffsetFromNow']
- delay = url+'&delay=%d'
- #todo do something with delay option?
- if url not in urls:
- urls.append(url)
- chid = chid+'.%d'%idx if idx > 0 else chid
- label = "%s - %s" % (chid, title)
- infoLabels ={"mediatype":"video","label":label ,"title":label}
- infoArt ={"thumb":icon,"poster":icon,"fanart":FANART,"icon":icon,"logo":icon}
- self.addLink(title, url, 9, infoLabels, infoArt)
-
-
- def videoclips(self, state):
- log('videoclips, state = ' + state)
- data = self.openURL(BASE_API)
- if data:
- for channel in data:
- if state in channel['config']['state']:
- chid = channel['identifier']
- title = channel['title']
- icon = (channel['icon'] or ICON)
- vidURL = channel['config']['localvodfeed']
- if vidURL:
- label = "%s - %s" % (chid, title)
- infoLabels ={"mediatype":"video","label":label,"title":label}
- infoArt ={"thumb":icon,"poster":icon,"fanart":FANART,"icon":ICON,"logo":ICON}
- self.addDir(label, vidURL, 4, infoLabels, infoArt)
-
-
- def parseclips(self, url):
- log('parseclips, url = ' + url)
- #using xmltodict, feedparser too bulky for the job.
- feed = feedparser.parse(url)
- for item in feed['entries']:
- if item and 'summary_detail' in item:
- for vids in item['media_content']:
- title = item['title']
- url = vids['url']
- plot = item['summary']
- thumb = item['media_thumbnail'][0]['url']
- infoLabels ={"mediatype":"video","label":title,"title":title,"plot":plot}
- infoArt ={"thumb":thumb,"poster":thumb,"fanart":FANART,"icon":ICON,"logo":ICON}
- self.addLink(title, url, 9, infoLabels, infoArt)
-
-
- def playVideo(self, name, url, list=None):
- log('playVideo')
- if not list:
- list = xbmcgui.ListItem(name, path=url)
- xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, list)
-
-
- def addLink(self, name, u, mode, infoList=False, infoArt=False, total=0):
- name = stringify(name)
- log('addLink, name = ' + name)
- liz=xbmcgui.ListItem(name)
- liz.setProperty('IsPlayable', 'true')
- if infoList == False:
- liz.setInfo( type="Video", infoLabels={"mediatype":"video","label":name,"title":name})
- else:
- liz.setInfo(type="Video", infoLabels=infoList)
-
- if infoArt == False:
- liz.setArt({'thumb':ICON,'fanart':FANART})
- else:
- liz.setArt(infoArt)
- u=sys.argv[0]+"?url="+urllib.quote_plus(u)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
- xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,totalItems=total)
-
-
- def addDir(self, name, u, mode, infoList=False, infoArt=False):
- name = stringify(name)
- log('addDir, name = ' + name)
- liz=xbmcgui.ListItem(name)
- liz.setProperty('IsPlayable', 'false')
- if infoList == False:
- liz.setInfo(type="Video", infoLabels={"mediatype":"video","label":name,"title":name})
- else:
- liz.setInfo(type="Video", infoLabels=infoList)
- if infoArt == False:
- liz.setArt({'thumb':ICON,'fanart':FANART})
- else:
- liz.setArt(infoArt)
- u=sys.argv[0]+"?url="+urllib.quote_plus(u)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
- xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
-
-params=getParams()
-try:
- url=urllib.unquote_plus(params["url"])
-except:
- url=None
-try:
- name=urllib.unquote_plus(params["name"])
-except:
- name=None
-try:
- mode=int(params["mode"])
-except:
- mode=None
-
-log("Mode: "+str(mode))
-log("URL : "+str(url))
-log("Name: "+str(name))
-
-if mode==None: NewsOn().mainMenu()
-elif mode == 0: NewsOn().browseMenu(1)
-elif mode == 1: NewsOn().newsCasts(url)
-elif mode == 2: NewsOn().browseMenu(3)
-elif mode == 3: NewsOn().videoclips(url)
-elif mode == 4: NewsOn().parseclips(url)
-elif mode == 9: NewsOn().playVideo(name, url)
-
-xbmcplugin.addSortMethod(int(sys.argv[1]) , xbmcplugin.SORT_METHOD_NONE )
-xbmcplugin.addSortMethod(int(sys.argv[1]) , xbmcplugin.SORT_METHOD_LABEL )
-xbmcplugin.endOfDirectory(int(sys.argv[1]),cacheToDisc=True) \ No newline at end of file
+#entrypoint
+if __name__ == '__main__':
+ from resources.lib import newson \ No newline at end of file
diff --git a/plugin.video.newson/fanart.jpg b/plugin.video.newson/fanart.jpg
deleted file mode 100644
index b6629a3..0000000
--- a/plugin.video.newson/fanart.jpg
+++ /dev/null
Binary files differ
diff --git a/plugin.video.newson/resources/__init__.py b/plugin.video.newson/resources/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugin.video.newson/resources/__init__.py
diff --git a/plugin.video.newson/resources/images/fanart.jpg b/plugin.video.newson/resources/images/fanart.jpg
new file mode 100644
index 0000000..bcc3c04
--- /dev/null
+++ b/plugin.video.newson/resources/images/fanart.jpg
Binary files differ
diff --git a/plugin.video.newson/icon.png b/plugin.video.newson/resources/images/icon.png
index 579e696..579e696 100644
--- a/plugin.video.newson/icon.png
+++ b/plugin.video.newson/resources/images/icon.png
Binary files differ
diff --git a/plugin.video.newson/resources/images/newscast.jpg b/plugin.video.newson/resources/images/newscast.jpg
index 6bed258..11673f1 100644
--- a/plugin.video.newson/resources/images/newscast.jpg
+++ b/plugin.video.newson/resources/images/newscast.jpg
Binary files differ
diff --git a/plugin.video.newson/resources/images/videoclips.jpg b/plugin.video.newson/resources/images/videoclips.jpg
index 6120aa3..7e3217c 100644
--- a/plugin.video.newson/resources/images/videoclips.jpg
+++ b/plugin.video.newson/resources/images/videoclips.jpg
Binary files differ
diff --git a/plugin.video.newson/resources/lib/__init__.py b/plugin.video.newson/resources/lib/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugin.video.newson/resources/lib/__init__.py
diff --git a/plugin.video.newson/resources/lib/newson.py b/plugin.video.newson/resources/lib/newson.py
new file mode 100644
index 0000000..5999d4a
--- /dev/null
+++ b/plugin.video.newson/resources/lib/newson.py
@@ -0,0 +1,271 @@
+# Copyright (C) 2017 Lunatixz
+#
+#
+# This file is part of NewsOn.
+#
+# NewsOn 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.
+#
+# NewsOn 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 NewsOn. If not, see <http://www.gnu.org/licenses/>.
+
+# -*- coding: utf-8 -*-
+import os, sys, time, datetime, re, traceback, feedparser, random
+import urllib, urllib2, socket, json, collections, gzip
+import xbmc, xbmcgui, xbmcplugin, xbmcvfs, xbmcaddon
+
+from StringIO import StringIO
+from simplecache import SimpleCache
+# Plugin Info
+ADDON_ID = 'plugin.video.newson'
+REAL_SETTINGS = xbmcaddon.Addon(id=ADDON_ID)
+ADDON_NAME = REAL_SETTINGS.getAddonInfo('name')
+SETTINGS_LOC = REAL_SETTINGS.getAddonInfo('profile')
+ADDON_PATH = REAL_SETTINGS.getAddonInfo('path').decode('utf-8')
+ADDON_VERSION = REAL_SETTINGS.getAddonInfo('version')
+ICON = REAL_SETTINGS.getAddonInfo('icon')
+FANART = REAL_SETTINGS.getAddonInfo('fanart')
+LANGUAGE = REAL_SETTINGS.getLocalizedString
+NEWSART = os.path.join(ADDON_PATH,'resources','images','newscast.jpg')
+CLIPART = os.path.join(ADDON_PATH,'resources','images','videoclips.jpg')
+
+## GLOBALS ##
+TIMEOUT = 30
+DEBUG = REAL_SETTINGS.getSetting('Enable_Debugging') == 'true'
+BASE_API = 'http://watchnewson.com/api/linear/channels'
+MENU = [("Newscasts" , '0', 0, False, {"thumb":NEWSART,"poster":NEWSART,"fanart":FANART,"icon":ICON,"logo":ICON}),
+ ("Video Clips", '2', 2, False, {"thumb":CLIPART,"poster":CLIPART,"fanart":FANART,"icon":ICON,"logo":ICON})]
+
+def log(msg, level=xbmc.LOGDEBUG):
+ if DEBUG == True:
+ if level == xbmc.LOGERROR:
+ msg += ' ,' + traceback.format_exc()
+ xbmc.log(ADDON_ID + '-' + ADDON_VERSION + '-' + (msg), level)
+
+def getParams():
+ param=[]
+ if len(sys.argv[2])>=2:
+ params=sys.argv[2]
+ cleanedparams=params.replace('?','')
+ if (params[len(params)-1]=='/'):
+ params=params[0:len(params)-2]
+ pairsofparams=cleanedparams.split('&')
+ param={}
+ for i in range(len(pairsofparams)):
+ splitparams={}
+ splitparams=pairsofparams[i].split('=')
+ if (len(splitparams))==2:
+ param[splitparams[0]]=splitparams[1]
+ return param
+
+socket.setdefaulttimeout(TIMEOUT)
+class NewsOn(object):
+ def __init__(self):
+ log('__init__')
+ self.cache = SimpleCache()
+ self.stateMenu = self.getStates()
+
+
+ def openURL(self, url):
+ try:
+ cacheResponce = self.cache.get(ADDON_NAME + '.openURL, url = %s'%url)
+ if not cacheResponce:
+ request = urllib2.Request(url)
+ request.add_header('Accept-encoding', 'gzip')
+ request.add_header('User-Agent','Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)')
+ responce = urllib2.urlopen(request, timeout = TIMEOUT)
+ log(responce.headers['content-type'])
+ log(responce.headers['content-encoding'])
+ if responce.info().get('content-encoding') == 'gzip':
+ buf = StringIO(responce.read())
+ f = gzip.GzipFile(fileobj=buf)
+ results = json.loads(f.read())
+ else:
+ results = json.load(responce)
+ responce.close()
+ self.cache.set(ADDON_NAME + '.openURL, url = %s'%url, results, expiration=datetime.timedelta(hours=1))
+ return self.cache.get(ADDON_NAME + '.openURL, url = %s'%url)
+ except urllib2.URLError, e:
+ log("openURL Failed! " + str(e), xbmc.LOGERROR)
+ except socket.timeout, e:
+ log("openURL Failed! " + str(e), xbmc.LOGERROR)
+ except:
+ xbmcgui.Dialog().notification(ADDON_NAME, LANGUAGE(30001), ICON, 4000)
+
+
+ def mainMenu(self):
+ log('mainMenu')
+ for item in MENU:
+ self.addDir(*item)
+
+
+ def browseMenu(self, id=1):
+ log('browseMenu, id = ' + str(id))
+ self.stateMenu = [tuple(s.format(id) for s in tup) for tup in self.stateMenu]
+ for item in self.stateMenu:
+ self.addDir(*item)
+
+
+ def getStates(self):
+ log('getStates')
+ state = []
+ stateLST = []
+ data = self.openURL(BASE_API)
+ if data:
+ for channel in data:
+ state.append(channel['config']['state'])
+ states = collections.Counter(state)
+ for key, value in sorted(states.iteritems()):
+ stateLST.append(("%s"%(key), key , '{}'))
+ return stateLST
+
+
+ def newsCasts(self, state):
+ log('newsCasts, state = ' + state)
+ urls = []
+ data = self.openURL(BASE_API)
+ if data:
+ for channel in data:
+ if state in channel['config']['state']:
+ chid = channel['identifier']
+ title = channel['title']
+ icon = (channel['icon'] or ICON)
+ for idx, stream in enumerate(channel['streams']):
+ streamType = stream['StreamType']
+ if streamType == 'website':#random.choice(['website','roku']):
+ continue
+ #multiple urls, only add unique.
+ url = stream['Url']
+ offset = stream['OffsetFromNow']
+ delay = url+'&delay=%d'
+ #todo do something with delay option?
+ if url not in urls:
+ urls.append(url)
+ chid = chid+'.%d'%idx if idx > 0 else chid
+ label = "%s - %s" % (chid, title)
+ infoLabels ={"mediatype":"video","label":label ,"title":label}
+ infoArt ={"thumb":icon,"poster":icon,"fanart":FANART,"icon":icon,"logo":icon}
+ self.addLink(title, url, 9, infoLabels, infoArt)
+
+
+ def videoclips(self, state):
+ log('videoclips, state = ' + state)
+ data = self.openURL(BASE_API)
+ if data:
+ for channel in data:
+ if state in channel['config']['state']:
+ chid = channel['identifier']
+ title = channel['title']
+ icon = (channel['icon'] or ICON)
+ vidURL = channel['config']['localvodfeed']
+ if vidURL:
+ label = "%s - %s" % (chid, title)
+ infoLabels ={"mediatype":"video","label":label,"title":label}
+ infoArt ={"thumb":icon,"poster":icon,"fanart":FANART,"icon":ICON,"logo":ICON}
+ self.addDir(label, vidURL, 4, infoLabels, infoArt)
+
+
+ def parseclips(self, url):
+ log('parseclips, url = ' + url)
+ feed = feedparser.parse(url)
+ for item in feed['entries']:
+ if item and 'summary_detail' in item:
+ for vids in item['media_content']:
+ title = item['title']
+ url = vids['url']
+ plot = item['summary']
+ try:
+ aired = (datetime.datetime.strptime(item.get('published',''), '%a, %d %b %Y %H:%M:%S UTC'))
+ except:
+ aired = datetime.datetime.now()
+ aired = aired.strftime("%Y-%m-%d")
+ thumb = item['media_thumbnail'][0]['url']
+ tagLST = []
+ if 'tags' in item:
+ for tag in item['tags']:
+ print tag
+ tagLST.append(((tag['term']).split('/')[0]).title())
+ if len(tagLST) > 0:
+ genre = (tagLST[0] or '')
+ infoLabels ={"mediatype":"video","label":title,"title":title,"plot":plot,"aired":aired,'genre':genre,'tags':tagLST}
+ infoArt ={"thumb":thumb,"poster":thumb,"fanart":FANART,"icon":ICON,"logo":ICON}
+ self.addLink(title, url, 9, infoLabels, infoArt)
+
+
+ def playVideo(self, name, url, list=None):
+ log('playVideo')
+ if not list:
+ list = xbmcgui.ListItem(name, path=url)
+ xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, list)
+
+
+ def addLink(self, name, u, mode, infoList=False, infoArt=False, total=0):
+ name = name.encode("utf-8")
+ log('addLink, name = ' + name)
+ liz=xbmcgui.ListItem(name)
+ liz.setProperty('IsPlayable', 'true')
+ if infoList == False:
+ liz.setInfo( type="Video", infoLabels={"mediatype":"video","label":name,"title":name})
+ else:
+ liz.setInfo(type="Video", infoLabels=infoList)
+
+ if infoArt == False:
+ liz.setArt({'thumb':ICON,'fanart':FANART})
+ else:
+ liz.setArt(infoArt)
+ u=sys.argv[0]+"?url="+urllib.quote_plus(u)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
+ xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,totalItems=total)
+
+
+ def addDir(self, name, u, mode, infoList=False, infoArt=False):
+ name = name.encode("utf-8")
+ log('addDir, name = ' + name)
+ liz=xbmcgui.ListItem(name)
+ liz.setProperty('IsPlayable', 'false')
+ if infoList == False:
+ liz.setInfo(type="Video", infoLabels={"mediatype":"video","label":name,"title":name})
+ else:
+ liz.setInfo(type="Video", infoLabels=infoList)
+ if infoArt == False:
+ liz.setArt({'thumb':ICON,'fanart':FANART})
+ else:
+ liz.setArt(infoArt)
+ u=sys.argv[0]+"?url="+urllib.quote_plus(u)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
+ xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
+
+params=getParams()
+try:
+ url=urllib.unquote_plus(params["url"])
+except:
+ url=None
+try:
+ name=urllib.unquote_plus(params["name"])
+except:
+ name=None
+try:
+ mode=int(params["mode"])
+except:
+ mode=None
+
+log("Mode: "+str(mode))
+log("URL : "+str(url))
+log("Name: "+str(name))
+
+if mode==None: NewsOn().mainMenu()
+elif mode == 0: NewsOn().browseMenu(1)
+elif mode == 1: NewsOn().newsCasts(url)
+elif mode == 2: NewsOn().browseMenu(3)
+elif mode == 3: NewsOn().videoclips(url)
+elif mode == 4: NewsOn().parseclips(url)
+elif mode == 9: NewsOn().playVideo(name, url)
+
+xbmcplugin.addSortMethod(int(sys.argv[1]) , xbmcplugin.SORT_METHOD_NONE )
+xbmcplugin.addSortMethod(int(sys.argv[1]) , xbmcplugin.SORT_METHOD_LABEL )
+xbmcplugin.endOfDirectory(int(sys.argv[1]),cacheToDisc=True) \ No newline at end of file