summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLunatixz <128316+Lunatixz@users.noreply.github.com>2018-01-05 16:50:27 -0500
committerenen92 <enen92@users.noreply.github.com>2018-01-05 21:50:27 +0000
commit0b7ffec3a5807df9ca57a0d4c67d5104199fc666 (patch)
treeed53f4ad4f527f1335cf77c6070ff8d2cf235aee
parent870b3c819900bdcce4dae7710ee28432f1a0ee53 (diff)
[plugin.video.haystacktv] 1.0.1 (#1586)
[plugin.video.haystacktv] 1.0.1
-rw-r--r--plugin.video.haystacktv/LICENSE (renamed from plugin.video.haystacktv/LICENSE.md)0
-rw-r--r--plugin.video.haystacktv/addon.xml8
-rw-r--r--plugin.video.haystacktv/default.py247
-rw-r--r--plugin.video.haystacktv/resources/__init__.py0
-rw-r--r--plugin.video.haystacktv/resources/images/icon.pngbin396259 -> 413576 bytes
-rw-r--r--plugin.video.haystacktv/resources/language/resource.language.en_gb/strings.po6
-rw-r--r--plugin.video.haystacktv/resources/language/resource.language.he_il/strings.po29
-rw-r--r--plugin.video.haystacktv/resources/lib/__init__.py0
-rw-r--r--plugin.video.haystacktv/resources/lib/haystack.py238
-rw-r--r--plugin.video.haystacktv/resources/settings.xml3
10 files changed, 281 insertions, 250 deletions
diff --git a/plugin.video.haystacktv/LICENSE.md b/plugin.video.haystacktv/LICENSE
index 733c072..733c072 100644
--- a/plugin.video.haystacktv/LICENSE.md
+++ b/plugin.video.haystacktv/LICENSE
diff --git a/plugin.video.haystacktv/addon.xml b/plugin.video.haystacktv/addon.xml
index f5b006b..82af46d 100644
--- a/plugin.video.haystacktv/addon.xml
+++ b/plugin.video.haystacktv/addon.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
-<addon id="plugin.video.haystacktv" version="1.0.0" name="Haystack.TV" provider-name="Lunatixz">
+<addon id="plugin.video.haystacktv" version="1.0.1" name="Haystack.TV" provider-name="Lunatixz">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.simplecache" version="1.0.0"/>
+ <import addon="script.module.youtube.dl" version="17.0.0"/>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
- <import addon="script.module.urlresolver" version="0.0.1"/>
<import addon="plugin.video.youtube" version="5.1.8" optional="true"/>
<import addon="plugin.video.vimeo" version="4.1.4" optional="true"/>
</requires>
@@ -16,10 +16,10 @@
<description lang="en_GB">Haystack TV is your personal headline news channel. We learn about your interests in order to surface the news that matters to you! Watch it on Kodi today...</description>
<platform>all</platform>
<license>GNU GENERAL PUBLIC LICENSE. Version 3, June 2007</license>
- <source>https://github.com/Lunatixz/XBMC_Addons/tree/master/plugin.video.haystacktv</source>
+ <source>https://github.com/Lunatixz/KODI_Addons/tree/master/plugin.video.haystacktv</source>
<website>http://www.haystack.tv/</website>
<forum>https://forum.kodi.tv/showthread.php?tid=316485</forum>
- <news></news>
+ <news>>v.1.0.1[CR]-Leia Compatibility[CR]-Improved Video Parsing.</news>
<assets>
<icon>resources/images/icon.png</icon>
<fanart>resources/images/fanart.jpg</fanart>
diff --git a/plugin.video.haystacktv/default.py b/plugin.video.haystacktv/default.py
index 5bae97d..69ee10c 100644
--- a/plugin.video.haystacktv/default.py
+++ b/plugin.video.haystacktv/default.py
@@ -17,248 +17,7 @@
# along with Haystack.TV. If not, see <http://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
-import os, sys, datetime, re, traceback, urlresolver
-import urllib, urllib2, socket, json
-import xbmc, xbmcgui, xbmcplugin, xbmcaddon
-from simplecache import SimpleCache
-from bs4 import BeautifulSoup
-
-# Plugin Info
-ADDON_ID = 'plugin.video.haystacktv'
-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 = 30
-DEBUG = REAL_SETTINGS.getSetting('Enable_Debugging') == 'true'
-BASEURL = 'http://www.haystack.tv'
-YTURL = 'plugin://plugin.video.youtube/play/?video_id='
-VMURL = 'plugin://plugin.video.vimeo/play/?video_id='
-IGNORE = ', watch it on the web, Android, iPad and Chromecast.'
-
-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 Haystack():
- def __init__(self):
- log('__init__')
- self.cache = SimpleCache()
- self.getCategories()
-
-
- def openURL(self, 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)
- soup = BeautifulSoup(response.read())
- data = (soup.find('script').text).rstrip()
- data = (data.split('window.__INITIAL_STATE__ = ')[1]).replace(';','')
- results = json.loads(data)
- response.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 self.catMenu:
- self.addDir(*item)
-
-
- def resolveHAY(self, url):
- log('resolveHAY')
- responce = self.openURL(url)
- if responce and 'videos' in responce and 'videoList' in responce['videos']:
- for item in responce['videos']['videoList']:
- if item and 'mediaFiles' in item and 'adaptive' in item['mediaFiles']:
- if item['mediaFiles']['adaptive']['type'] == 'm3u8':
- return item['mediaFiles']['adaptive']['url']
- return url
-
-
- def resolveURL(self, provider, url):
- log('resolveURL, provider = ' + provider + ', url = ' + url)
- if provider.lower() == 'youtube':
- if len(re.findall('http[s]?://www.youtube.com/watch', url)) > 0:
- return YTURL + url.split('/watch?v=')[1]
- elif len(re.findall('http[s]?://youtu.be/', url)) > 0:
- return YTURL + url.split('/youtu.be/')[1]
- elif provider.lower() == 'vimeo':
- if len(re.findall('http[s]?://vimeo.com/', url)) > 0:
- return VMURL + url.split('/vimeo.com/')[1]
- elif provider.lower() == 'haystack':
- return self.resolveHAY(url)
- return (urlresolver.resolve(url) or url)
-
-
- def getCategories(self):
- log('getCategories')
- responce = self.openURL(BASEURL)
- if responce and 'videos' in responce and 'playlistHeader' in responce['videos']:
- self.catMenu = [(responce['videos']['playlistHeader'],'',0)]
- if responce and 'categories' in responce and 'categoryPlaylists' in responce['categories']:
- for item in responce['categories']['categoryPlaylists']:
- infoLabel = {}
- title = responce['environment']['sitemap'][item['relativeUrl']]['sectionTitle']
- infoLabel['label'] = title
- infoLabel['title'] = title
- infoLabel['plot'] = responce['environment']['sitemap'][item['relativeUrl']]['description'].replace(IGNORE,'.')
- infoLabel['plotoutline'] = responce['environment']['sitemap'][item['relativeUrl']]['pageTitle'].replace(IGNORE,'.')
- infoLabel['genre'] = responce['environment']['sitemap'][item['relativeUrl']]['alias']
- self.catMenu.append((title,title,1,infoLabel))
-
-
- def getVideos(self, cat, today=True):
- log('getVideos')
- responce = self.openURL(BASEURL)
- if today == False and responce and 'categories' in responce and 'categoryPlaylists' in responce['categories']:
- results = responce['categories']['categoryPlaylists']
- for items in results:
- if cat.lower() == items['sectionTitle'].lower():
- self.getLinks(items['streams'])
- elif today == True and responce and 'videos' in responce and 'videoList' in responce['videos']:
- self.getLinks(responce['videos']['videoList'])
-
-
- def getLinks(self, items):
- log('getLinks')
- for item in items:
- tagLST = []
- infoLabel = {}
- infoArt = {}
- title = item['title']
- path = self.resolveURL(item['site'],item['streamUrl'])
- for tag in item['topics']:
- tagLST.append(tag['tag'])
- infoLabel['tag'] = tagLST
- infoLabel['mediatype']= 'video'
- infoLabel['duration'] = item['duration']
- infoLabel['label'] = item['title']
- infoLabel['title'] = title
- infoLabel['plot'] = title
- infoLabel['studio'] = item['author']
- infoLabel['genre'] = item['category'].title()
- infoLabel['rating'] = item['popularityScore']
- infoLabel['aired'] = item['publishedDate'].split('T')[0]
- thumb = (item.get('snapshotHighUrl','') or item.get('snapshotUrl','') or ICON)
- infoArt ={"thumb":thumb,"poster":thumb,"fanart":FANART,"icon":ICON,"logo":ICON}
- self.addLink(title, path, 9, infoLabel, infoArt)
-
-
- def playVideo(self, name, url):
- log('playVideo')
- 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: Haystack().mainMenu()
-elif mode == 0: Haystack().getVideos(name)
-elif mode == 1: Haystack().getVideos(name, False)
-elif mode == 9: Haystack().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 haystack \ No newline at end of file
diff --git a/plugin.video.haystacktv/resources/__init__.py b/plugin.video.haystacktv/resources/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugin.video.haystacktv/resources/__init__.py
diff --git a/plugin.video.haystacktv/resources/images/icon.png b/plugin.video.haystacktv/resources/images/icon.png
index 71b0b33..9a105e9 100644
--- a/plugin.video.haystacktv/resources/images/icon.png
+++ b/plugin.video.haystacktv/resources/images/icon.png
Binary files differ
diff --git a/plugin.video.haystacktv/resources/language/resource.language.en_gb/strings.po b/plugin.video.haystacktv/resources/language/resource.language.en_gb/strings.po
index 1c29c5d..05e4f26 100644
--- a/plugin.video.haystacktv/resources/language/resource.language.en_gb/strings.po
+++ b/plugin.video.haystacktv/resources/language/resource.language.en_gb/strings.po
@@ -21,5 +21,9 @@ msgid "Enable Debugging [Log errors]"
msgstr ""
msgctxt "#30001"
-msgid "Site unreachable, try again later..."
+msgid "Something went wrong, Try again..."
+msgstr ""
+
+msgctxt "#30002"
+msgid "Select Preferred Quality"
msgstr ""
diff --git a/plugin.video.haystacktv/resources/language/resource.language.he_il/strings.po b/plugin.video.haystacktv/resources/language/resource.language.he_il/strings.po
new file mode 100644
index 0000000..d686587
--- /dev/null
+++ b/plugin.video.haystacktv/resources/language/resource.language.he_il/strings.po
@@ -0,0 +1,29 @@
+# Kodi Media Center language file
+# Addon Name: Haystack.TV
+# Addon id: plugin.video.haystacktv
+# Addon Provider: Lunatixz
+msgid ""
+msgstr ""
+"Project-Id-Version: plugin.video.haystacktv\n"
+"Report-Msgid-Bugs-To: http://forum.kodi.tv/showthread.php?tid=316485\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: 2017-10-30 07:58+0200\n"
+"Last-Translator: A. Dambledore\n"
+"Language-Team: Eng2Heb\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: he_IL\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 "האתר לא זמין. נסה שנית מאוחר יותר..."
+
+msgctxt "#30002"
+msgid "Select Preferred Quality"
+msgstr ""
diff --git a/plugin.video.haystacktv/resources/lib/__init__.py b/plugin.video.haystacktv/resources/lib/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugin.video.haystacktv/resources/lib/__init__.py
diff --git a/plugin.video.haystacktv/resources/lib/haystack.py b/plugin.video.haystacktv/resources/lib/haystack.py
new file mode 100644
index 0000000..1debbfb
--- /dev/null
+++ b/plugin.video.haystacktv/resources/lib/haystack.py
@@ -0,0 +1,238 @@
+# Copyright (C) 2017 Lunatixz
+#
+#
+# This file is part of Haystack.TV.
+#
+# Haystack.TV 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.
+#
+# Haystack.TV 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 Haystack.TV. If not, see <http://www.gnu.org/licenses/>.
+
+# -*- coding: utf-8 -*-
+import os, sys, datetime, re, traceback
+import urllib, urllib2, socket, json
+import xbmc, xbmcgui, xbmcplugin, xbmcaddon
+
+from simplecache import SimpleCache
+from bs4 import BeautifulSoup
+from YDStreamExtractor import getVideoInfo
+
+# Plugin Info
+ADDON_ID = 'plugin.video.haystacktv'
+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
+CONTENT_TYPE = 'files'
+DEBUG = REAL_SETTINGS.getSetting('Enable_Debugging') == 'true'
+BASEURL = 'http://www.haystack.tv'
+YTURL = 'plugin://plugin.video.youtube/play/?video_id='
+VMURL = 'plugin://plugin.video.vimeo/play/?video_id='
+IGNORE = ', watch it on the web, Android, iPad and Chromecast.'
+# MY HEADLINES,EDITOR'S PICKS,NEWS,SCITECH,ENTERTAINMENT,BUSINESS,U.S.POLITICS,SPORTS,GAMING,LATE NIGHT,MOVIES,POPULAR
+
+def log(msg, level=xbmc.LOGDEBUG):
+ if DEBUG == False and level != xbmc.LOGERROR: return
+ 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 Haystack():
+ def __init__(self):
+ log('__init__')
+ self.cache = SimpleCache()
+ self.getCategories()
+
+
+ def openURL(self, 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)
+ soup = BeautifulSoup(response.read(), "html.parser")
+ data = (soup.find('script').text).rstrip()
+ data = (data.split('window.__INITIAL_STATE__ = ')[1]).replace(';','')
+ response.close()
+ self.cache.set(ADDON_NAME + '.openURL, url = %s'%url, data, expiration=datetime.timedelta(hours=1))
+ return json.loads(self.cache.get(ADDON_NAME + '.openURL, url = %s'%url))
+ except Exception as e:
+ log("openURL Failed! " + str(e), xbmc.LOGERROR)
+ xbmcgui.Dialog().notification(ADDON_NAME, LANGUAGE(30001), ICON, 4000)
+ return ''
+
+
+ def mainMenu(self):
+ log('mainMenu')
+ for item in self.catMenu: self.addDir(*item)
+
+
+ def resolveHAY(self, url, all=False):
+ log('resolveHAY')
+ responce = self.openURL(url)
+ if responce and 'videos' in responce and 'videoList' in responce['videos']:
+ for item in responce['videos']['videoList']:
+ if item and 'mediaFiles' in item and 'adaptive' in item['mediaFiles'] and not all:
+ if item['mediaFiles']['adaptive']['type'] == 'm3u8': return item['mediaFiles']['adaptive']['url']
+ else:
+ info = self.getVideo(url)
+ if info is not None: return info[0]['xbmc_url']
+ return None
+
+
+ def resolveURL(self, provider, url):
+ log('resolveURL, provider = ' + provider + ', url = ' + url)
+ if provider.lower() == 'youtube':
+ if len(re.findall('http[s]?://www.youtube.com/watch', url)) > 0: return YTURL + url.split('/watch?v=')[1]
+ elif len(re.findall('http[s]?://youtu.be/', url)) > 0: return YTURL + url.split('/youtu.be/')[1]
+ elif provider.lower() == 'vimeo':
+ if len(re.findall('http[s]?://vimeo.com/', url)) > 0: return VMURL + url.split('/vimeo.com/')[1]
+ elif provider.lower() == 'haystack': return self.resolveHAY(url)
+ return None
+
+
+ def getVideo(self, url):
+ cacheresponse = self.cache.get(ADDON_NAME + '.getVideo, url = %s'%url)
+ if not cacheresponse:
+ info = getVideoInfo(url,QUALITY,True)
+ if info is not None: info = info.streams()
+ self.cache.set(ADDON_NAME + '.getVideo, url = %s'%url, json.dumps(info), expiration=datetime.timedelta(days=14))
+ return json.loads(self.cache.get(ADDON_NAME + '.getVideo, url = %s'%url))
+
+
+ def getVideos(self, cat, today=True):
+ log('getVideos')
+ responce = self.openURL(BASEURL)
+ if today == False and responce and 'categories' in responce and 'categoryPlaylists' in responce['categories']:
+ results = responce['categories']['categoryPlaylists']
+ for items in results:
+ if cat.lower() == items['sectionTitle'].lower(): self.getLinks(items['streams'])
+ elif today == True and responce and 'videos' in responce and 'videoList' in responce['videos']: self.getLinks(responce['videos']['videoList'])
+
+
+ def getCategories(self):
+ log('getCategories')
+ responce = self.openURL(BASEURL)
+ if responce and 'videos' in responce and 'playlistHeader' in responce['videos']:
+ self.catMenu = [(responce['videos']['playlistHeader'],'',0)]
+ if responce and 'categories' in responce and 'categoryPlaylists' in responce['categories']:
+ for item in responce['categories']['categoryPlaylists']:
+ infoLabel = {}
+ title = responce['environment']['sitemap'][item['relativeUrl']]['sectionTitle']
+ infoLabel['label'] = title
+ infoLabel['title'] = title
+ infoLabel['plot'] = responce['environment']['sitemap'][item['relativeUrl']]['description'].replace(IGNORE,'.')
+ infoLabel['plotoutline'] = responce['environment']['sitemap'][item['relativeUrl']]['pageTitle'].replace(IGNORE,'.')
+ infoLabel['genre'] = responce['environment']['sitemap'][item['relativeUrl']]['alias']
+ self.catMenu.append((title,title,1,infoLabel))
+
+
+ def getLinks(self, items):
+ log('getLinks')
+ for item in items:
+ tagLST = []
+ infoLabel = {}
+ infoArt = {}
+ title = item['title']
+ path = self.resolveURL(item['site'],item['streamUrl'])
+ if path is None: continue
+ for tag in item['topics']:
+ tagLST.append(tag['tag'])
+ infoLabel['tag'] = tagLST
+ infoLabel['mediatype']= 'video'
+ infoLabel['duration'] = item['duration']
+ infoLabel['label'] = item['title']
+ infoLabel['title'] = title
+ infoLabel['plot'] = title
+ infoLabel['studio'] = item['author']
+ infoLabel['genre'] = item['category'].title()
+ infoLabel['rating'] = item['popularityScore']
+ infoLabel['aired'] = item['publishedDate'].split('T')[0]
+ thumb = (item.get('snapshotHighUrl','') or item.get('snapshotUrl','') or ICON)
+ infoArt ={"thumb":thumb,"poster":thumb,"fanart":FANART,"icon":ICON,"logo":ICON}
+ self.addLink(title, path, 9, infoLabel, infoArt)
+
+
+ def playVideo(self, name, url, liz=None):
+ log('playVideo')
+ if liz is None: 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})
+ else: liz.setInfo(type="Video", infoLabels=infoList)
+ if infoArt == False: liz.setArt({'thumb':LOGO_URL%urllib.quote_plus(name),'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}) #LOGO_URL%urllib.quote_plus(name)
+ 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: Haystack().mainMenu()
+elif mode == 0: Haystack().getVideos(name)
+elif mode == 1: Haystack().getVideos(name, False)
+elif mode == 9: Haystack().playVideo(name, url)
+
+xbmcplugin.setContent(int(sys.argv[1]) , CONTENT_TYPE)
+xbmcplugin.addSortMethod(int(sys.argv[1]) , xbmcplugin.SORT_METHOD_UNSORTED)
+xbmcplugin.addSortMethod(int(sys.argv[1]) , xbmcplugin.SORT_METHOD_NONE)
+xbmcplugin.addSortMethod(int(sys.argv[1]) , xbmcplugin.SORT_METHOD_LABEL)
+xbmcplugin.addSortMethod(int(sys.argv[1]) , xbmcplugin.SORT_METHOD_TITLE)
+xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=True) \ No newline at end of file
diff --git a/plugin.video.haystacktv/resources/settings.xml b/plugin.video.haystacktv/resources/settings.xml
index 65b7d95..fbc5978 100644
--- a/plugin.video.haystacktv/resources/settings.xml
+++ b/plugin.video.haystacktv/resources/settings.xml
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
- <setting id="Enable_Debugging" type="bool" label="30000" default="false" />
+ <setting id="Enable_Debugging" type="bool" label="30000" default="false" />
+ <setting id="Quality" type="enum" label="30002" default="3" values="SD|720p|1080p|Highest Available"/>
</settings>