summaryrefslogtreecommitdiff
path: root/plugin.video.skynews/resources
diff options
context:
space:
mode:
authorLunatixz <Lunatixz@users.noreply.github.com>2017-09-03 12:31:49 -0400
committerenen92 <enen92@users.noreply.github.com>2017-09-03 17:31:49 +0100
commit4b45a2ea025f7b91a8c0d6df47eff23329869088 (patch)
tree8213ee8b7d27ae41dc879c0a565f3c0d980bb608 /plugin.video.skynews/resources
parent16143b1eed2b3e60d8bd1ce86f79966c09ae9059 (diff)
[plugin.video.skynews] 1.0.1 (#1392)
[plugin.video.skynews] 1.0.1
Diffstat (limited to 'plugin.video.skynews/resources')
-rw-r--r--plugin.video.skynews/resources/__init__.py0
-rw-r--r--plugin.video.skynews/resources/images/fanart.jpgbin0 -> 125067 bytes
-rw-r--r--plugin.video.skynews/resources/images/icon.pngbin0 -> 79615 bytes
-rw-r--r--plugin.video.skynews/resources/images/screenshot01.pngbin0 -> 589143 bytes
-rw-r--r--plugin.video.skynews/resources/images/screenshot02.pngbin0 -> 739755 bytes
-rw-r--r--plugin.video.skynews/resources/language/resource.language.en_gb/strings.po25
-rw-r--r--plugin.video.skynews/resources/lib/__init__.py0
-rw-r--r--plugin.video.skynews/resources/lib/skynews.py171
-rw-r--r--plugin.video.skynews/resources/settings.xml4
9 files changed, 200 insertions, 0 deletions
diff --git a/plugin.video.skynews/resources/__init__.py b/plugin.video.skynews/resources/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugin.video.skynews/resources/__init__.py
diff --git a/plugin.video.skynews/resources/images/fanart.jpg b/plugin.video.skynews/resources/images/fanart.jpg
new file mode 100644
index 0000000..d439e8d
--- /dev/null
+++ b/plugin.video.skynews/resources/images/fanart.jpg
Binary files differ
diff --git a/plugin.video.skynews/resources/images/icon.png b/plugin.video.skynews/resources/images/icon.png
new file mode 100644
index 0000000..7513b52
--- /dev/null
+++ b/plugin.video.skynews/resources/images/icon.png
Binary files differ
diff --git a/plugin.video.skynews/resources/images/screenshot01.png b/plugin.video.skynews/resources/images/screenshot01.png
new file mode 100644
index 0000000..92f57d5
--- /dev/null
+++ b/plugin.video.skynews/resources/images/screenshot01.png
Binary files differ
diff --git a/plugin.video.skynews/resources/images/screenshot02.png b/plugin.video.skynews/resources/images/screenshot02.png
new file mode 100644
index 0000000..552b95b
--- /dev/null
+++ b/plugin.video.skynews/resources/images/screenshot02.png
Binary files differ
diff --git a/plugin.video.skynews/resources/language/resource.language.en_gb/strings.po b/plugin.video.skynews/resources/language/resource.language.en_gb/strings.po
new file mode 100644
index 0000000..e9ea2eb
--- /dev/null
+++ b/plugin.video.skynews/resources/language/resource.language.en_gb/strings.po
@@ -0,0 +1,25 @@
+# Kodi Media Center language file
+# Addon Name: Sky News
+# Addon id: plugin.video.skynews
+# Addon Provider: Lunatixz
+msgid ""
+msgstr ""
+"Project-Id-Version: plugin.video.skynews\n"
+"Report-Msgid-Bugs-To: https://forum.kodi.tv/showthread.php?tid=320938\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: Lunatixz Translation Team\n"
+"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: en\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+msgctxt "#30000"
+msgid "Enable Debugging [Log errors]"
+msgstr ""
+
+msgctxt "#30001"
+msgid "Something went wrong, Try again..."
+msgstr "" \ No newline at end of file
diff --git a/plugin.video.skynews/resources/lib/__init__.py b/plugin.video.skynews/resources/lib/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugin.video.skynews/resources/lib/__init__.py
diff --git a/plugin.video.skynews/resources/lib/skynews.py b/plugin.video.skynews/resources/lib/skynews.py
new file mode 100644
index 0000000..eb7066a
--- /dev/null
+++ b/plugin.video.skynews/resources/lib/skynews.py
@@ -0,0 +1,171 @@
+# Copyright (C) 2017 Lunatixz
+#
+#
+# This file is part of Sky News.
+#
+# Sky News 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.
+#
+# Sky News 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 Sky News. If not, see <http://www.gnu.org/licenses/>.
+
+# -*- coding: utf-8 -*-
+import os, re, sys, time, datetime, traceback
+import urllib, urllib2, socket, json
+import xbmc, xbmcgui, xbmcplugin, xbmcaddon
+
+from simplecache import SimpleCache
+from bs4 import BeautifulSoup
+
+# Plugin Info
+ADDON_ID = 'plugin.video.skynews'
+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
+
+## GLOBALS ##
+TIMEOUT = 15
+DEBUG = REAL_SETTINGS.getSetting('Enable_Debugging') == 'true'
+LIVEURL = 'http://news.sky.com/watch-live'
+YTURL = 'plugin://plugin.video.youtube/play/?video_id='
+
+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 Sky(object):
+ def __init__(self):
+ log('__init__')
+ self.cache = SimpleCache()
+
+
+ def openURL(self, url):
+ log('openURL, url = ' + str(url))
+ try:
+ cacheResponse = self.cache.get(ADDON_NAME + '.openURL, url = %s'%url)
+ if not cacheResponse:
+ request = urllib2.Request(url)
+ request.add_header('User-Agent','Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)')
+ response = urllib2.urlopen(request, timeout=TIMEOUT).read()
+ self.cache.set(ADDON_NAME + '.openURL, url = %s'%url, response, expiration=datetime.timedelta(hours=6))
+ 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 Exception, e:
+ log("openURL Failed! " + str(e), xbmc.LOGERROR)
+ xbmcgui.Dialog().notification(ADDON_NAME, LANGUAGE(30001), ICON, 4000)
+ return ''
+
+
+ def buildMainMenu(self):
+ self.addLink('Live' ,'',0)
+ self.addYoutube('Browse','plugin://plugin.video.youtube/user/skynews/')
+
+
+ def buildLiveLink(self):
+ #parse for youtube live feed, may not be necessary. However its useful if the site changes feeds.
+ soup = BeautifulSoup(self.openURL(LIVEURL), "html.parser")
+ link = 'http:' + soup('div' , {'class': 'sdc-news-story-article__body'})[0].find('iframe').get('src')
+ self.playVideo('Sky News Live',self.resolveYoutube(link))
+
+
+ def resolveYoutube(self, link):
+ if len(re.findall('http[s]?://www.youtube.com/watch', link)) > 0:
+ return YTURL + link.split('/watch?v=')[1]
+ elif len(re.findall('http[s]?://www.youtube.com/embed', link)) > 0:
+ return YTURL + link.split('/embed/')[1].split('?autoplay=1')[0]
+ elif len(re.findall('http[s]?://youtu.be/', link)) > 0:
+ return YTURL + link.split('/youtu.be/')[1]
+
+
+ def playVideo(self, name, url, liz=None):
+ log('playVideo')
+ if not liz:
+ liz = xbmcgui.ListItem(name, path=url)
+ xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
+
+
+ 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,"genre":"News"})
+ 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 addYoutube(self, title, url):
+ liz=xbmcgui.ListItem(title)
+ liz.setProperty('IsPlayable', 'false')
+ liz.setInfo(type="Video", infoLabels={"label":title,"title":title} )
+ liz.setArt({'thumb':ICON,'fanart':FANART})
+ xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,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: Sky().buildMainMenu()
+elif mode == 0: Sky().buildLiveLink()
+elif mode == 9: Sky().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
diff --git a/plugin.video.skynews/resources/settings.xml b/plugin.video.skynews/resources/settings.xml
new file mode 100644
index 0000000..afdf009
--- /dev/null
+++ b/plugin.video.skynews/resources/settings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings>
+ <setting id="Enable_Debugging" type="bool" label="30000" default="false" />
+</settings>