Kodi Community Forum

Full Version: [Release] CBC.ca News
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9
You da man!  Works great.
Any chance you could ad Windsor to the local news nder "News" "Canada" so I can get our local news. It was in the original addon and we miss it here.
@zootz62 can you find the missing "Windsor" section on the CBC web site?  If so let me know where this is and I might be able to include it.

When I navigate to News then Canada I did not observe "Windsor" as one of the local news sites.
I found the "Windsor" local news site and a source for all the local news sites.  This patch adds all the local news locations.

NOTE:  This post has been edited to remove content that is no longer valid.
(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.
 
  1. 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.

  2. 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.

  3. 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 -----
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)


----- End of file ----- 

Thank you very much, 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.
...
Thanks for all your work. This fix works great!
Seems like the addon is broke again.. it was working with the patch, but not anymore
@DarrenHill would you please move posts 52 through 55 to the correct forum:  CBC TV (Canadian Broadcasting Corportation)  Thanks.  Done.

@[email protected] to improve your chances for support, please post in the correct forum listed above in this post.  Also be sure to provide detailed information such as the steps that reproduce the problem, in addition to details about your computer and kodi.  Be sure to include a full debug log as requested in the CBC TV (Canadian Broadcasting Corportation) forum.  Placed question in correct forum.

@maddskillz20 be sure to check which CBC add-on you are using and then post the steps on how to reproduce the problem in the associated forum.  I just tried this CBC.ca News add-on with the patch and it correctly played pre-recorded news from BC, and also Marketplace.
@kodaksmith - Done, they're now in that thread (minus my previous post, which is then irrelevant so binned).
I'm getting the following error when launching the addon
2019-11-05 12:09:23.647 T:1496   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.SyntaxError'>
                                            Error Contents: invalid syntax (scraper.py, line 21)
                                            Traceback (most recent call last):
                                              File "C:\Users\topher\AppData\Roaming\Kodi\addons\plugin.video.cbcnews\default.py", line 4, in <module>
                                                from resources.lib.scraper import myAddon
                                              File "C:\Users\topher\AppData\Roaming\Kodi\addons\plugin.video.cbcnews\resources\lib\scraper.py", line 21
                                                �def getAddonMenu(self,url,ilist):
                                                ^
                                            SyntaxError: invalid syntax
                                            -->End of Python script error report<--
2019-11-05 12:09:23.649 T:2444   ERROR: XFILE::CDirectory::GetDirectory - Error getting plugin://plugin.video.cbcnews/
2019-11-05 12:09:23.649 T:10420   ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.cbcnews/) failed
@maddskillz20 from the log it appears that an invalid character has appeared in the scraper.py file (perhaps an accidental typo when copying and pasting?).  I suggest you try replacing the scraper.py file again using the steps in post #49.
Thank you @DarrenHill for moving the relevant posts and deleting the ones that no longer applied.  :-)
Just wondering if you are getting continuous buffering. The Windsor News plays for about 5 minutes then every 30 - 40 seconds after that it buffers. One takes about 30 seconds to load then the next take 3 seconds to load, then back to 30 seconds to load. Been doing this for a couple of days now. Any help would be greatly appreciated. It does it in the live newcast and in the replay of the newscast
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.

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.
(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.

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.
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.
Pages: 1 2 3 4 5 6 7 8 9