In regard to the official Academic Earth plugin, it's not working for me either. It needs fixing. The webpage may have changed or something.
Your code is having an error when I can find a video to play.
Code:
15:03:20 T:4867248128 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.UnboundLocalError'>
Error Contents: local variable 's2' referenced before assignment
Traceback (most recent call last):
File "/Users/xyz/Library/Application Support/XBMC/addons/plugin.video.schneidz-academic-earth/default.py", line 196, in <module>
playvid(url)
File "/Users/xyz/Library/Application Support/XBMC/addons/plugin.video.schneidz-academic-earth/default.py", line 76, in playvid
s1 = re.search('url=(http.+?)\\\\', s2)
UnboundLocalError: local variable 's2' referenced before assignment
-->End of Python script error report<--
15:03:20 T:4867248128 INFO: Python script stopped
If I indent your playvid(url) function from:
Code:
def playvid(url):
html=urllib2.urlopen(url).read().replace(",","\\\n")
for line in html.split("\n"):
if "itag=22" in line:
s2 = line
s1 = re.search('url=(http.+?)\\\\', s2)
sig = re.search('sig=(.+?)\\\\', s2)
yturl = s1.groups() + sig.groups()
yturl = str(tuple(yturl))
yturl = yturl.replace("', '","&signature=")
yturl = yturl.replace("%3A",":")
yturl = yturl.replace("%2F","/")
yturl = yturl.replace("%3F","?")
yturl = yturl.replace("%3D","=")
yturl = yturl.replace("%252C","%2C")
yturl = yturl.replace("%26","&")
yturl = yturl.replace("%253A",":")
yturl = yturl.replace("('","\"")
yturl = yturl.replace("')","\"")
yturl = yturl.replace('"','')
print "\n yturl.replace = " + yturl
xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play(yturl)
to:
Code:
def playvid(url):
html=urllib2.urlopen(url).read().replace(",","\\\n")
for line in html.split("\n"):
if "itag=22" in line:
s2 = line
s1 = re.search('url=(http.+?)\\\\', s2)
sig = re.search('sig=(.+?)\\\\', s2)
yturl = s1.groups() + sig.groups()
yturl = str(tuple(yturl))
yturl = yturl.replace("', '","&signature=")
yturl = yturl.replace("%3A",":")
yturl = yturl.replace("%2F","/")
yturl = yturl.replace("%3F","?")
yturl = yturl.replace("%3D","=")
yturl = yturl.replace("%252C","%2C")
yturl = yturl.replace("%26","&")
yturl = yturl.replace("%253A",":")
yturl = yturl.replace("('","\"")
yturl = yturl.replace("')","\"")
yturl = yturl.replace('"','')
print "\n yturl.replace = " + yturl
xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play(yturl)
Then the video plays, but if I stop the video or let it play to the end, then playback of the same video in a continuous loop.
At that point I have to kill XBMC process. It has to do with how you call the xbmc.Player. There is an indirect way to play a resolved url which opens the player for you without a direct call.