2019-10-30, 23:48
You da man! Works great.
(2019-10-31, 23:08)kodaksmith Wrote: I found the "Windsor" local news site and a source for all the local news sites. This patch adds all the local news locations.
How to Patch CBC News Add-on:
The following steps assume that you have the CBC News 3.0.2 video add-on already installed on your Kodi computer.
- Create a replacement plugin.video.cbcnews/resources/lib/scraper.py file using the file contents listed lower in this post.
IMPORTANT: Use pop-up COPY button. When copying the code below be sure to move the mouse pointer over the code and click the pop-up COPY button in the upper right-hand corner of the code section. This will ensure that invisible URL encoded space characters (percent-two-zero, or %20) are copied to the clipboard.
For example, open a text editor, copy the scraper.py file contents listed below (hover mouse over code and click the pop-up Copy button), paste into text editor, save the file with name scraper.py, and exit the text editor.
- Determine the location of the Kodi addons folder where plugin.video.cbcnews is installed on your Kodi computer.
For example:
- /storage/.kodi/addons/plugin.video.cbcnews/ for LibreELEC on Raspberry Pi.
- ~/.kodi/addons/plugin.video.cbcnews/ for Kodi on Ubuntu where ~ is your home directory.
Note that the location of the addons folder should be similar to the userdata folder.
- Copy the new scraper.py file over top of the existing plugin.video.cbcnews/resources/lib/scraper.py file.
For example on a Raspberry Pi with LibreELEC 8.2.5 installed I used the following command:
scp -p scraper.py [email protected]:/storage/.kodi/addons/plugin.video.cbcnews/resources/lib/
Note that you would need to substitute the IP address for your Raspberry Pi (see System -> System Info).
'Hope that helps. :-)
----- Beginning of file ---------- End of file -----python:
# -*- coding: utf-8 -*-
# KodiAddon (CBC News)
#
from t1mlib import t1mAddon
import datetime
import json
import re
import urllib
import urllib2
import xbmcplugin
import xbmcgui
import HTMLParser
import sys
import xbmc
h = HTMLParser.HTMLParser()
UTF8 = 'utf-8'
class myAddon(t1mAddon):
def getAddonMenu(self,url,ilist):
html = self.getRequest('http://www.cbc.ca/player')
shows = re.compile('<h2 class="section-title"><a href="(.+?)"> <!-- -->(.+?)<!--', re.DOTALL).findall(html)
shows.append(('/player/news/TV%20Shows/MarketPlace', 'Marketplace'))
shows.append(('/player/news/TV%20Shows/Power%20&%20Politics', 'Power & Politics'))
shows.append(('/player/news/TV%20Shows/The%20Fifth%20Estate', 'The Fifth Estate'))
shows.append(('/player/news/TV%20Shows/The%20National/Latest%20Broadcast', 'The National'))
shows.append(('/player/news/TV%20Shows/The%20Weekly', 'The Weekly'))
for url, name in shows:
infoList = {}
infoList['mediatype'] = 'tvshow'
infoList['Title'] = name
infoList['TVShowTitle'] = name
ilist = self.addMenuItem(name, 'GS', ilist, url, self.addonIcon, self.addonFanart, infoList, isFolder=True)
return(ilist)
def getAddonCats(self,url,ilist):
html = self.getRequest('http://www.cbc.ca')
html = re.compile('<!-- -->My Local Settings(.+?)href="/news">Top Stories', re.DOTALL).search(html).group(1)
shows = re.compile('<li class="regionsListItem"><.+?data-acronym="(.+?)".+?value="(.+?)".+?</li>', re.DOTALL).findall(html)
for url, name in shows:
infoList = {}
infoList['mediatype'] = 'tvshow'
infoList['Title'] = name
infoList['TVShowTitle'] = name
lurl = "/player/news/Canada/"+url
ilist = self.addMenuItem(name, 'GE', ilist, lurl, self.addonIcon, self.addonFanart, infoList, isFolder=True)
if lurl == '/player/news/Canada/Toronto':
ilist = self.addMenuItem('Ottawa', 'GE', ilist, '/player/news/Canada/Ottawa', self.addonIcon, self.addonFanart, infoList, isFolder=True)
return(ilist)
def getAddonShows(self,url,ilist):
html = self.getRequest('http://www.cbc.ca%s' % url)
shows = re.compile('<h2 class="section-title"><a href="(.+?)"> <!-- -->(.+?)<!--', re.DOTALL).findall(html)
count = 0
for lurl, name in shows:
count+=1
if (count <= 0) or (url.find('TV%20Shows') > 0):
self.getAddonEpisodes(url, ilist)
else:
for lurl, name in shows:
infoList = {}
infoList['mediatype'] = 'tvshow'
infoList['Title'] = name
infoList['TVShowTitle'] = name
if lurl == '/player/news/canada':
ilist = self.addMenuItem(name, 'GC', ilist, lurl, self.addonIcon, self.addonFanart, infoList, isFolder=True)
else:
ilist = self.addMenuItem(name, 'GS', ilist, lurl, self.addonIcon, self.addonFanart, infoList, isFolder=True)
return(ilist)
def getAddonEpisodes(self,url,ilist):
self.defaultVidStream['width'] = 1280
self.defaultVidStream['height'] = 720
cat = re.compile('/([^/]+?)$', re.DOTALL).search(url).group(1).replace('%20', ' ')
html = self.getRequest('http://www.cbc.ca%s' % url)
html = re.compile('window.__PRELOADED_STATE__ = (.+?)\s+?</script>', re.DOTALL).search(html).group(1)
a = json.loads(html)
# Locate exact category name
for b in a['categoryClips']:
if re.search(cat+"$", b, re.IGNORECASE): # category must be at end of string
idxcat = b
for b in a['categoryClips'][idxcat]:
name = b['title'].replace(u"\u2018", "'").replace(u"\u2019", "'").encode('ascii', 'xmlcharrefreplace')
plot = b['description'].replace(u"\u2018", "'").replace(u"\u2019", "'").encode('ascii', 'xmlcharrefreplace')
vurl = b['assetDescriptors'][0]['key']
thumb = b['thumbnail']
fanart = thumb
if b['captions']:
captions = b['captions']['src']
else:
captions = 'N0NE'
infoList = {}
infoList['mediatype'] = 'tvshow'
infoList['Title'] = name
infoList['TVShowTitle'] = name
infoList['Plot'] = plot
infoList['Duration'] = b['duration']
infoList['Aired'] = datetime.datetime.fromtimestamp(b['airDate']/1000).strftime('%Y-%m-%d')
infoList['Date'] = datetime.datetime.fromtimestamp(b['addedDate']/1000).strftime('%Y-%m-%d')
infoList['MPAA'] = captions # Hack to store closed captions
ilist = self.addMenuItem(name, 'GV', ilist, vurl, thumb, fanart, infoList, isFolder=False)
return(ilist)
def getAddonVideo(self,url):
u = url.split('/meta.smil',1)[0]
u = u + '?mbr=true&manifest=m3u&feed=Player%20Selector%20-%20Prod'
#html = self.getRequest(u)
#xbmc.log("gAV html: "+html, xbmc.LOGNOTICE)
#u = re.compile('RESOLUTION=1280x720.+?\n(http.+?)\?', re.DOTALL).search(html).group(1)
#if u is None:
# return
#xbmc.log(" u2: "+u, xbmc.LOGNOTICE)
liz = xbmcgui.ListItem(path = u.strip())
captions = xbmc.getInfoLabel('ListItem.MPAA')
#xbmc.log("gAV captions: "+captions, xbmc.LOGNOTICE)
if captions.find('.srt') > 0:
liz.setSubtitles([captions])
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
(2019-11-20, 22:41)kodaksmith Wrote: No problems playing CBC Windsor News from Nov 19th using LibreELEC 8.2.5 and this add-on installed on a Raspberry Pi 3 with 5 Mbps Internet connection.Ok Thank you I have no problem watching other tv shows either live or after they have aired. I will try some other sources and see what happens. My Internet speed is 360 mbps ultra fibre and the box runs through an Ethernet cable directly into the router.
You might check to see if other videos play correctly from other sources. If other sources also experience problems playing then there might be an issue with your hardware or your Internet connection.