summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLunatixz <128316+Lunatixz@users.noreply.github.com>2018-01-15 19:39:10 -0500
committerenen92 <enen92@users.noreply.github.com>2018-01-16 00:39:10 +0000
commitc0d1b9cc0899fa7c9a09eef24bc9a3b337131971 (patch)
tree6c8f3d39388235e073de147de9d8ce7b5f92007f
parent144c832baedd948102c2ee0ef0c9ac5b118f8b6e (diff)
[plugin.video.cheddar] 1.0.2 (#1606)
copyright update
-rw-r--r--plugin.video.cheddar/addon.xml7
-rw-r--r--plugin.video.cheddar/default.py2
-rw-r--r--plugin.video.cheddar/resources/language/resource.language.en_gb/strings.po10
-rw-r--r--plugin.video.cheddar/resources/lib/cheddar.py181
-rw-r--r--plugin.video.cheddar/resources/settings.xml3
5 files changed, 91 insertions, 112 deletions
diff --git a/plugin.video.cheddar/addon.xml b/plugin.video.cheddar/addon.xml
index 66e244b..58dbb0d 100644
--- a/plugin.video.cheddar/addon.xml
+++ b/plugin.video.cheddar/addon.xml
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
-<addon id="plugin.video.cheddar" name="Cheddar" provider-name="Lunatixz" version="1.0.1">
+<addon id="plugin.video.cheddar" name="Cheddar" provider-name="Lunatixz" version="1.0.2">
<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"/>
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
@@ -13,10 +14,10 @@
<description lang="en_GB">Cheddar is a live Post-Cable Network focused on covering the most innovative products, technologies, and services transforming our lives. The network covers this news through the lens of the companies and executives driving these changes. Cheddar broadcasts from Post 10 on the floor of the New York Stock Exchange and the Sprint Flatiron Building Store.</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.cheddar</source>
+ <source>https://github.com/Lunatixz/Kodi_Addons/tree/master/plugin.video.cheddar</source>
<website>https://cheddar.com/</website>
<forum>http://forum.kodi.tv/showthread.php?tid=319217</forum>
- <news>>v.1.0.1[CR]-Leia Compatibility</news>
+ <news>>v.1.0.1[CR]-Leia Compatibility[CR]v.1.0.2[CR]-Updated web-parser[CR]-Miscellaneous Improvements</news>
<assets>
<icon>resources/images/icon.png</icon>
<fanart>resources/images/fanart.jpg</fanart>
diff --git a/plugin.video.cheddar/default.py b/plugin.video.cheddar/default.py
index 34a29ae..3748228 100644
--- a/plugin.video.cheddar/default.py
+++ b/plugin.video.cheddar/default.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2017 Lunatixz
+# Copyright (C) 2018 Lunatixz
#
#
# This file is part of Cheddar
diff --git a/plugin.video.cheddar/resources/language/resource.language.en_gb/strings.po b/plugin.video.cheddar/resources/language/resource.language.en_gb/strings.po
index f92a5d1..94d27ba 100644
--- a/plugin.video.cheddar/resources/language/resource.language.en_gb/strings.po
+++ b/plugin.video.cheddar/resources/language/resource.language.en_gb/strings.po
@@ -18,4 +18,12 @@ msgstr ""
msgctxt "#30000"
msgid "Enable Debugging [Log errors]"
-msgstr "" \ No newline at end of file
+msgstr ""
+
+msgctxt "#30001"
+msgid "Something went wrong, Try again..."
+msgstr ""
+
+msgctxt "#30002"
+msgid "Select Preferred Quality"
+msgstr ""
diff --git a/plugin.video.cheddar/resources/lib/cheddar.py b/plugin.video.cheddar/resources/lib/cheddar.py
index 7e2e634..5e5f531 100644
--- a/plugin.video.cheddar/resources/lib/cheddar.py
+++ b/plugin.video.cheddar/resources/lib/cheddar.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2017 Lunatixz
+# Copyright (C) 2018 Lunatixz
#
#
# This file is part of Cheddar
@@ -17,10 +17,12 @@
# along with Cheddar. If not, see <http://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
-import os, sys, datetime, re, traceback, urllib, urllib2, socket
+import os, sys, datetime, re, traceback
+import urlparse, urllib, urllib2, socket
import xbmc, xbmcvfs, xbmcgui, xbmcplugin, xbmcaddon
-from simplecache import SimpleCache
+from YDStreamExtractor import getVideoInfo
+from simplecache import SimpleCache, use_cache
from bs4 import BeautifulSoup
# Plugin Info
@@ -35,38 +37,25 @@ FANART = REAL_SETTINGS.getAddonInfo('fanart')
LANGUAGE = REAL_SETTINGS.getLocalizedString
## GLOBALS ##
-TIMEOUT = 30
-BASEURL = 'http://cheddar.com/'
-DEBUG = REAL_SETTINGS.getSetting('Enable_Debugging') == 'true'
-CONTENT_TYPE = 'files'
-
-Cheddar_MENU = [("Latest" , 'collections/latest', 1),
- ("Browse" , 'collections' , 1)]
+TIMEOUT = 30
+BASEURL = 'http://cheddar.com/'
+DEBUG = REAL_SETTINGS.getSetting('Enable_Debugging') == 'true'
+QUALITY = int(REAL_SETTINGS.getSetting('Quality'))
+CONTENT_TYPE = 'episodes'
+Cheddar_MENU = [("Latest" , 'collections/latest', 1),
+ ("Browse" , 'collections' , 1)]
+
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)
-
+ 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
-
+ return dict(urlparse.parse_qsl(sys.argv[2][1:]))
+
socket.setdefaulttimeout(TIMEOUT)
-class Cheddar():
+class Cheddar(object):
def __init__(self):
log('__init__')
self.cache = SimpleCache()
@@ -83,84 +72,75 @@ class Cheddar():
response.close()
self.cache.set(ADDON_NAME + '.openURL, url = %s'%url, results, expiration=datetime.timedelta(hours=12))
return self.cache.get(ADDON_NAME + '.openURL, url = %s'%url)
- except urllib2.URLError as e:
- log("openURL Failed! " + str(e), xbmc.LOGERROR)
- except socket.timeout as e:
- log("openURL Failed! " + str(e), xbmc.LOGERROR)
- except:
- xbmcgui.Dialog().notification(ADDON_NAME, LANGUAGE(30001), ICON, 4000)
-
+ except urllib2.URLError as e: log("openURL Failed! " + str(e), xbmc.LOGERROR)
+ except socket.timeout as e: log("openURL Failed! " + str(e), xbmc.LOGERROR)
+ xbmcgui.Dialog().notification(ADDON_NAME, LANGUAGE(30001), ICON, 4000)
+ return ''
+
def mainMenu(self):
log('mainMenu')
self.addLink('Live', '', 0)
- for item in Cheddar_MENU:
- self.addDir(*item)
+ for item in Cheddar_MENU: self.addDir(*item)
+ self.addYoutube("Browse Youtube" , 'plugin://plugin.video.youtube/channel/UC04KsGq3npibMCE9Td3mVDg/')
def browseLive(self):
log('browseLive')
soup = BeautifulSoup(self.openURL(BASEURL), "html.parser")
- liveLink = 'http:' + soup('div', {'class': 'hero_video'})[0].find('source').get('src')
+ liveLink = soup('div', {'class': 'hero_video'})[0].find('source').get('src')
self.playVideo('Live', liveLink)
def browse(self, link):
log('browse')
- soup = BeautifulSoup(self.openURL(BASEURL+link), "html.parser")
+ soup = BeautifulSoup(self.openURL(BASEURL + link), "html.parser")
latestLink = (soup('div', {'class': 'video_thumb'}))
for item in latestLink:
- try:
- uriLink = item('a', {'class': 'cf'})[0]
- uri = BASEURL + uriLink['href']
- thumb = uriLink('div', {'class': 'vid_img'})[0].find_all('img')[0].get('src')
- airdate, title = uriLink.text.strip().replace('\r','').replace('\t','').split('\n')
- plot = 'Aired: %s'%airdate
- label = title.strip()
- airdate = datetime.datetime.strptime(airdate, "%B %d, %Y")
- infoList = {"mediatype":'video',"label":label,"title":label,"plot":plot,'genre':'News',"studio":"cheddar","aired":airdate.strftime('%Y-%m-%d'),"date":airdate.strftime('%d/%m/%Y')}
- infoArt = {"thumb":thumb,"poster":thumb,"fanart":FANART}
- self.addLink(label, uri, 9, infoList, infoArt)
- except:
- xbmc.executebuiltin("Container.Refresh")
-
-
- def playVideo(self, name, uri):
- log('playVideo, uri = ' + uri)
- try:
- metaLink = BeautifulSoup(self.openURL(uri), "html.parser")
- meta = metaLink('div', {'class': 'wrap video_details'})[0]('div', {'class': 'video_details_content'})[0]
- title = meta.find('h4').text
- plot = meta.find('article').text
- airdate = meta.find('p').text
- plotout = 'Aired: %s'%airdate
- airdate = datetime.datetime.strptime(airdate, "%B %d, %Y")
- url = metaLink('div', {'class': 'hero_video'})[0].find('source').get('src')+'.mp4'
- thumb = metaLink('div', {'class': 'hero_video'})[0].find('video').get('poster')
- infoList = {"mediatype":'video',"label":title,"title":title,"plot":plot,'genre':'News',"plotoutline":plotout,"studio":"cheddar","aired":airdate.strftime('%Y-%m-%d')}
+ uriLink = item('a', {'class': 'cf'})[0]
+ uri = BASEURL + uriLink['href']
+ thumb = uriLink('div', {'class': 'vid_img'})[0].find_all('img')[0].get('src')
+ airdate, title = uriLink.text.strip().replace('\r','').replace('\t','').split('\n')
+ label = title.strip()
+ plot = '%s [CR]Aired: %s'%(label, airdate)
+ try: airdate = datetime.datetime.strptime(airdate, "%B %d, %Y")
+ except: airdate = datetime.datetime.now()
+ airdate = airdate.strftime('%Y-%m-%d')
+ infoList = {"mediatype":"episode","label":label,"title":label,"plot":plot,'genre':'News',"studio":"cheddar","aired":airdate}
infoArt = {"thumb":thumb,"poster":thumb,"fanart":FANART}
- liz = xbmcgui.ListItem(title, path=url)
- liz.setInfo(type="Video", infoLabels=infoList)
- liz.setArt(infoArt)
- except:
- liz = xbmcgui.ListItem(name, path=uri)
- xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
+ self.addLink(label, uri, 9, infoList, infoArt)
+
+ def playVideo(self, name, url):
+ log('playVideo, name = ' + name)
+ if name == 'Live': liz = xbmcgui.ListItem(name, path=url)
+ else:
+ 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)
+ 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)
@@ -170,31 +150,20 @@ class Cheddar():
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)
+ 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
-
+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))
diff --git a/plugin.video.cheddar/resources/settings.xml b/plugin.video.cheddar/resources/settings.xml
index d45420c..fbc5978 100644
--- a/plugin.video.cheddar/resources/settings.xml
+++ b/plugin.video.cheddar/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>