The Netflix website is obviously undergoing some pretty constant changes. The regex I wrote a couple weeks ago to scrape genres might no longer be sufficient and their own genre links at the top of their website are defunct (I'm not sure how they've gone on so long without noticing that). The good news is they have alternative links for those genres that do work and I've added a new regex for scraping that I'll share with you guys now.
You can either download
my copy of default.py which has the below changes and more (for convenience) or implement the basic work-arounds below on your own file.
Open up your
default.py and find
def index, then paste this in its place (without the ... at the beginning and end):
Code:
...
def index():
if login():
addDir(translation(30002), urlMain+"/MyList?leid=595&link=seeall", 'listVideos', "")
addDir(translation(30010), "", 'listViewingActivity', "")
addDir(translation(30003), urlMain+"/WiRecentAdditionsGallery?nRR=releaseDate&nRT=all&pn=1&np=1&actionMethod=json", 'listVideos', "")
addDir(translation(30004), urlMain+"/WiHD?dev=PC&pn=1&np=1&actionMethod=json", 'listVideos', "")
addDir(translation(30005), urlMain+"/WiAltGenre?agid=83&pn=1&np=1&actionMethod=json", 'listVideos', "")
addDir(translation(30007), "WiAltGenre", 'listGenres', "")
addDir(translation(30006), urlMain+"/WiAltGenre?agid=6839&pn=1&np=1&actionMethod=json", 'listVideos', "")
addDir(translation(30009), "KidsAltGenre", 'listGenres', "")
addDir(translation(30008), "", 'search', "")
xbmcplugin.endOfDirectory(pluginhandle)
...
That should fix the problem of broken genre links. Until they break the other links, I guess.
Then find
def listVideos (NOT
def listVideo) and replace it with this (without the ... at the beginning and end):
Code:
...
def listVideos(url):
if not singleProfile:
setProfile()
xbmcplugin.setContent(pluginhandle, "movies")
content = opener.open(url).read()
if not 'id="page-LOGIN"' in content:
if singleProfile and 'id="page-ProfilesGate"' in content:
forceChooseProfile()
else:
if '<div id="queue"' in content:
content = content[content.find('<div id="queue"'):]
content = content.replace("\\t","").replace("\\n", "").replace("\\", "")
match1 = re.compile('<span id="dbs(.+?)_.+?alt=".+?" src="(.+?)"', re.DOTALL).findall(content)
match2 = re.compile('<span class="title "><a id="b(.+?)_', re.DOTALL).findall(content)
match3 = re.compile('<img class="boxart" src="(.+?)" alt="(.+?)".+?/><a class="playHover" href=".+?WiPlayer\\?movieid=(.+?)&', re.DOTALL).findall(content)
match4 = re.compile('<img class="boxShotImg hideBobBoxshot" alt="([^"]+?)" src=".+?" ><a id="[^"]+?" class="bobbable popLink hideBobBoxshot playLink full" href="[^"]+?WiPlayer\\?movieid=([^"]+?)&', re.DOTALL).findall(content)
if match1:
for videoID, thumbUrl in match1:
listVideo(videoID, "", thumbUrl, False, False)
elif match2:
for videoID in match2:
listVideo(videoID, "", "", False, False)
elif match3:
for thumbUrl, vidTitle, videoID in match3:
listVideo(videoID, vidTitle, thumbUrl, False, False)
elif match4:
for vidTitle, videoID in match4:
listVideo(videoID, vidTitle, "", False, False)
match = re.compile('&pn=(.+?)&', re.DOTALL).findall(url)
if match:
currentPage = match[0]
nextPage = str(int(currentPage)+1)
addDir(translation(30001), url.replace("&pn="+currentPage+"&", "&pn="+nextPage+"&"), 'listVideos', "")
if forceView:
xbmc.executebuiltin('Container.SetViewMode('+viewIdVideos+')')
xbmcplugin.endOfDirectory(pluginhandle)
else:
deleteCookies()
xbmc.executebuiltin('XBMC.Notification(Info:,'+str(translation(30127))+',10000)')
...
And that should successfully scrape their new format. For now.