2013-05-30, 20:30
Hello,
I had problem with the plugin crashing due to ValueError: Extra data when trying to watch some subscribed videos. It happened during parse of json data in YouTubePlayer.py method extractFlashVars.
For some reason the json parser doesnt like extra data. The extra data was html tags at the end. Dunno why though.
I'm running XBMC 12.1 on Ubuntu 13.04. Plugin version 4.4.4
Resolved it with this code:
I had problem with the plugin crashing due to ValueError: Extra data when trying to watch some subscribed videos. It happened during parse of json data in YouTubePlayer.py method extractFlashVars.
For some reason the json parser doesnt like extra data. The extra data was html tags at the end. Dunno why though.
I'm running XBMC 12.1 on Ubuntu 13.04. Plugin version 4.4.4
Resolved it with this code:
Code:
def extractFlashVars(self, data):
flashvars = {}
found = False
for line in data.split("\n"):
if line.strip().find(";ytplayer.config = ") > 0:
found = True
p1 = line.find(";ytplayer.config = ") + len(";ytplayer.config = ") - 1
p2 = line.rfind(";")
if p1 <= 0 or p2 <= 0:
continue
data = line[p1 + 1:p2]
break
self.common.log(u"searching for crap at end")
pos = data.find("};")
if pos != -1:
self.common.log(u"found crap at end")
data=data[:pos+1]
self.common.log(u"crap trimmed")
if found:
try:
data = json.loads(data)
except ValueError:
self.common.log(u"Unable to parse")
self.common.log(pos)
self.common.log(data)
raise
flashvars = data["args"]
self.common.log(u"flashvars: " + repr(flashvars), 2)
return flashvars