From aa2b4c5874873569531b8bd6060498554e5049c1 Mon Sep 17 00:00:00 2001 From: Lunatixz <128316+Lunatixz@users.noreply.github.com> Date: Fri, 22 Dec 2017 09:32:18 -0500 Subject: [plugin.video.disclosetv] 1.0.0 (#1564) --- plugin.video.disclosetv/resources/__init__.py | 0 .../resources/images/fanart.jpg | Bin 0 -> 104590 bytes plugin.video.disclosetv/resources/images/icon.png | Bin 0 -> 24557 bytes .../resources/images/screenshot01.png | Bin 0 -> 511182 bytes .../resources/images/screenshot02.png | Bin 0 -> 802901 bytes .../resources/images/screenshot03.png | Bin 0 -> 731163 bytes .../language/resource.language.en_gb/strings.po | 29 ++++ plugin.video.disclosetv/resources/lib/__init__.py | 0 .../resources/lib/disclosetv.py | 189 +++++++++++++++++++++ plugin.video.disclosetv/resources/settings.xml | 5 + 10 files changed, 223 insertions(+) create mode 100644 plugin.video.disclosetv/resources/__init__.py create mode 100644 plugin.video.disclosetv/resources/images/fanart.jpg create mode 100644 plugin.video.disclosetv/resources/images/icon.png create mode 100644 plugin.video.disclosetv/resources/images/screenshot01.png create mode 100644 plugin.video.disclosetv/resources/images/screenshot02.png create mode 100644 plugin.video.disclosetv/resources/images/screenshot03.png create mode 100644 plugin.video.disclosetv/resources/language/resource.language.en_gb/strings.po create mode 100644 plugin.video.disclosetv/resources/lib/__init__.py create mode 100644 plugin.video.disclosetv/resources/lib/disclosetv.py create mode 100644 plugin.video.disclosetv/resources/settings.xml (limited to 'plugin.video.disclosetv/resources') diff --git a/plugin.video.disclosetv/resources/__init__.py b/plugin.video.disclosetv/resources/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugin.video.disclosetv/resources/images/fanart.jpg b/plugin.video.disclosetv/resources/images/fanart.jpg new file mode 100644 index 0000000..1747ad6 Binary files /dev/null and b/plugin.video.disclosetv/resources/images/fanart.jpg differ diff --git a/plugin.video.disclosetv/resources/images/icon.png b/plugin.video.disclosetv/resources/images/icon.png new file mode 100644 index 0000000..7ef2db3 Binary files /dev/null and b/plugin.video.disclosetv/resources/images/icon.png differ diff --git a/plugin.video.disclosetv/resources/images/screenshot01.png b/plugin.video.disclosetv/resources/images/screenshot01.png new file mode 100644 index 0000000..9e526f4 Binary files /dev/null and b/plugin.video.disclosetv/resources/images/screenshot01.png differ diff --git a/plugin.video.disclosetv/resources/images/screenshot02.png b/plugin.video.disclosetv/resources/images/screenshot02.png new file mode 100644 index 0000000..4ad6ab8 Binary files /dev/null and b/plugin.video.disclosetv/resources/images/screenshot02.png differ diff --git a/plugin.video.disclosetv/resources/images/screenshot03.png b/plugin.video.disclosetv/resources/images/screenshot03.png new file mode 100644 index 0000000..97deeb0 Binary files /dev/null and b/plugin.video.disclosetv/resources/images/screenshot03.png differ diff --git a/plugin.video.disclosetv/resources/language/resource.language.en_gb/strings.po b/plugin.video.disclosetv/resources/language/resource.language.en_gb/strings.po new file mode 100644 index 0000000..89eabc0 --- /dev/null +++ b/plugin.video.disclosetv/resources/language/resource.language.en_gb/strings.po @@ -0,0 +1,29 @@ +# Kodi Media Center language file +# Addon Name: "Disclose.tv +# Addon id: plugin.video.disclosetv +# Addon Provider: Lunatixz +msgid "" +msgstr "" +"Project-Id-Version: plugin.video.disclosetv\n" +"Report-Msgid-Bugs-To: \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 "" + +msgctxt "#30002" +msgid "Select Preferred Quality" +msgstr "" diff --git a/plugin.video.disclosetv/resources/lib/__init__.py b/plugin.video.disclosetv/resources/lib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plugin.video.disclosetv/resources/lib/disclosetv.py b/plugin.video.disclosetv/resources/lib/disclosetv.py new file mode 100644 index 0000000..72e26b5 --- /dev/null +++ b/plugin.video.disclosetv/resources/lib/disclosetv.py @@ -0,0 +1,189 @@ +# Copyright (C) 2017 Lunatixz +# +# +# This file is part of disclosetv. +# +# disclosetv 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. +# +# disclosetv 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 disclosetv. If not, see . + +# -*- coding: utf-8 -*- +import sys, time, datetime, re, traceback +import urllib, urllib2, socket, json +import xbmc, xbmcgui, xbmcplugin, xbmcaddon + +from bs4 import BeautifulSoup +from YDStreamExtractor import getVideoInfo +from simplecache import SimpleCache, use_cache + +# Plugin Info +ADDON_ID = 'plugin.video.disclosetv' +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' +QUALITY = int(REAL_SETTINGS.getSetting('Quality')) +BASE_URL = 'http://www.disclose.tv/' +BASE_VID = BASE_URL + 'videos' + +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 Disclose(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=1)) + return 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 buildMenu(self): + self.addDir('Browse', BASE_VID, 1) + self.addYoutube("Browse Youtube" , 'plugin://plugin.video.youtube/channel/UCA-Ls4dkRBXHMjRjeTDTdjg/') + + + def browse(self, url): + log('browse') + soup = BeautifulSoup(self.openURL(url), "html.parser") + videos = soup('div', {'class': 'teaser teaser--third'}) + for video in videos: + try: thumb = 'http:%s'%(video('div', {'class': 'ratio-container ratio16_9'})[0].find('img').attrs['data-src']) + except: thumb = FANART + items = video('div', {'class': 'teaser__caption'}) + vid_url = BASE_URL + (items[0]('a', {'class': 'article-link'})[0].attrs['href']) + label = items[0]('a', {'class': 'article-link'})[0].get_text() + timeago = items[0]('span', {'class': 'meta-timeago'})[0].get_text() + plot = '%s - %s'%(timeago, label) + try: genre = video('span', {'class': 'teaser-figure__cat'})[0].get_text() + except: genre = 'Unknown' + runtime = (video('span', {'class': 'teaser-figure__len'})[0].get_text()).split(':') + if len(runtime) == 3: + h, m, s = runtime + duration = int(h) * 3600 + int(m) * 60 + int(s) + else: + m, s = runtime + duration = (int(m) * 60) + int(s) + infoLabels = {"mediatype":"episode","label":label ,"title":label,"duration":duration,"plot":plot} + infoArt = {"thumb":thumb,"poster":thumb,"fanart":FANART,"icon":ICON,"logo":ICON} + self.addLink(label, vid_url, 9, infoLabels, infoArt, len(videos)) + next = soup('li', {'class': 'more-container__button m-auto'}) + if len(next) == 0: return + next_url = BASE_URL + next[0].find('a').attrs['href'] + next_label = (next[0].find('a').attrs['title'] or next[0].get_text()) + self.addDir(next_label, next_url, 1) + + + def playVideo(self, name, url, liz=None): + log('playVideo') + info = getVideoInfo(url,QUALITY,True) + if info is None: return + info = info.streams() + url = info[0]['xbmc_url'] + liz = xbmcgui.ListItem(name, path=url) + if 'subtitles' in info[0]['ytdl_format']: liz.setSubtitles([x['url'] for x in info[0]['ytdl_format']['subtitles'].get('en','') if 'url' in x]) + xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz) + + + def addYoutube(self, name, url): + liz=xbmcgui.ListItem(name) + liz.setProperty('IsPlayable', 'false') + liz.setInfo(type="Video", infoLabels={"label":name,"title":name} ) + liz.setArt({'thumb':ICON,'fanart':FANART}) + xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz,isFolder=True) + + + 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: Disclose().buildMenu() +elif mode == 1: Disclose().browse(url) +elif mode == 9: Disclose().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.disclosetv/resources/settings.xml b/plugin.video.disclosetv/resources/settings.xml new file mode 100644 index 0000000..fbc5978 --- /dev/null +++ b/plugin.video.disclosetv/resources/settings.xml @@ -0,0 +1,5 @@ + + + + + -- cgit v1.2.3