Steps to Update HGTV Canada video add-on
The following steps assume that you have the
HGTV Canada 3.0.3 video add-on already installed on your Kodi computer.
- Create a replacement plugin.video.hgtv.canada/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, 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.hgtv.canada is installed on your Kodi computer.
For example:
- /storage/.kodi/addons/plugin.video.hgtv.canada/ for LibreELEC on Raspberry Pi.
- ~/.kodi/addons/plugin.video.hgtv.canada/ 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.hgtv.canada/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.hgtv.canada/resources/lib/
Note that you would need to substitute the IP address for your Raspberry Pi (see System -> System Info).
'Hope that helps.
The credit for this improvement belongs to @
Veers01.
----- Beginning of file -----
# -*- coding: utf-8 -*-
# HGTV Canada Kodi Video Addon
#
from t1mlib import t1mAddon
import json
import re
import os
import datetime
import urllib
import urllib2
import xbmc
import xbmcplugin
import xbmcgui
import HTMLParser
import sys
h = HTMLParser.HTMLParser()
qp = urllib.quote_plus
uqp = urllib.unquote_plus
UTF8 = 'utf-8'
class myAddon(t1mAddon):
def getAddonMenu(self,url,ilist):
url = 'http://common.farm1.smdg.ca/Forms/PlatformVideoFeed?platformUrl=http%3A//feed.theplatform.com/f/dtjsEC/EAlt6FfQ_kCX/categories%3Fpretty%3Dtrue%26byHasReleases%3Dtrue%26range%3D1-1000%26sort%3DfullTitle&callback='
html = self.getRequest(url)
a = json.loads(html[1:len(html)-1])['items']
wewait = True
for b in a:
if b['title'] == 'Shows' and wewait == True:
wewait = False
continue
if wewait == False:
if b['depth'] == 2:
name = b['title']
url = b['id'].rsplit('/',1)[1]
ilist = self.addMenuItem(name,'GC', ilist, url, self.addonIcon, self.addonFanart, {}, isFolder=True)
return(ilist)
def getAddonCats(self,url,ilist):
self.defaultVidStream['width'] = 640
self.defaultVidStream['height'] = 360
geurl = uqp(url)
url = 'http://common.farm1.smdg.ca/Forms/PlatformVideoFeed?platformUrl=http%3A//feed.theplatform.com/f/dtjsEC/EAlt6FfQ_kCX/categories%3Fpretty%3Dtrue%26byHasReleases%3Dtrue%26range%3D1-1000%26sort%3DfullTitle&callback='
html = self.getRequest(url)
a = json.loads(html[1:len(html)-1])['items']
pid = 'http://data.media.theplatform.com/media/data/Category/%s' % geurl
wewait = True
for b in a:
if b['parentId'] == pid:
if wewait == True:
if b['title'] == 'Full Episodes':
wewait = False
pid = b['id']
if b['hasReleases'] == False: continue
if wewait == False and b['hasReleases'] == True:
name = b['title']
url = b['id'].rsplit('/',1)[1]
ilist = self.addMenuItem(name,'GE', ilist, url, self.addonIcon, self.addonFanart, {}, isFolder=True)
return(ilist)
def getAddonEpisodes(self,url,ilist):
self.defaultVidStream['width'] = 640
self.defaultVidStream['height'] = 360
geurl = uqp(url)
url = 'http://feed.theplatform.com/f/dtjsEC/EAlt6FfQ_kCX?count=true&byCategoryIDs=%s&startIndex=1&endIndex=100&sort=pubDate|desc&callback=' % geurl
html = self.getRequest(url)
a = json.loads(html)['entries']
if len(a) == 0:
url = 'http://common.farm1.smdg.ca/Forms/PlatformVideoFeed?platformUrl=http%3A//feed.theplatform.com/f/dtjsEC/EAlt6FfQ_kCX/categories%3Fpretty%3Dtrue%26byHasReleases%3Dtrue%26range%3D1-1000%26sort%3DfullTitle&callback='
html = self.getRequest(url)
a = json.loads(html[1:len(html)-1])['items']
pid = 'http://data.media.theplatform.com/media/data/Category/%s' % geurl
wewait = True
for b in a:
if b['parentId'] == pid:
if wewait == True:
if b['title'] == 'Full Episodes':
wewait = False
pid = b['id']
if b['hasReleases'] == False: continue
if wewait == False and b['hasReleases'] == True:
name = b['title']
url = b['id'].rsplit('/',1)[1]
ilist = self.addMenuItem(name,'GE', ilist, url, self.addonIcon, self.addonFanart, {}, isFolder=True)
else:
for b in a:
url = b['content'][0]['url'].replace('manifest=f4m','manifest=m3u')
name = h.unescape(b['title'])
thumb = b.get('defaultThumbnailUrl')
fanart = self.addonFanart
infoList = {}
infoList['Duration'] = int(b['content'][0]['duration'])
infoList['Title'] = name
infoList['Studio'] = b.get('pl1$network')
infoList['Date'] = datetime.datetime.fromtimestamp(b['pubDate']/1000).strftime('%Y-%m-%d')
infoList['Aired'] = infoList['Date']
infoList['Year'] = int(infoList['Date'].split('-',1)[0])
mpaa = re.compile('ratings="(.+?)"',re.DOTALL).search(html)
if mpaa is not None: infoList['MPAA'] = mpaa.group(1).split(':',1)[1]
episode = b.get('pl1$episode')
if episode is not None: infoList['Episode'] = int(episode)
season = b.get('pl1$season')
if season is not None: infoList['Season'] = int(season)
else: infoList['Season'] = 1
infoList['Plot'] = h.unescape(b["description"])
infoList['TVShowTitle'] = b['pl1$show']
infoList['mediatype'] = 'episode'
ilist = self.addMenuItem(name,'GV', ilist, url, thumb, fanart, infoList, isFolder=False)
return(ilist)
def getAddonVideo(self,url):
# durl = url
# html = self.getRequest(url) #needs proxy
# url = re.compile('video src="(.+?)"', re.DOTALL).search(html)
# if url is None:
# url = durl
# suburl = None
# else:
# url = url.group(1)
# suburl = re.compile('textstream src="(.+?)"', re.DOTALL).search(html)
# html = self.getRequest(url) #needs proxy
# url = re.compile('http(.+?)\n', re.DOTALL).search(html).group(0).strip()
liz = xbmcgui.ListItem(path = url)
# if suburl is not None:
# suburl=suburl.group(1).replace('.ttml','.vtt')
# liz.setSubtitles([suburl])
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
----- End of file -----