2006-03-22, 16:09
i am trying to make a live365 script and thought i had it figured out.. but apparently i went wrong somewhere. this is my first attempt at python. i will post the script below.
import clientcookie
import xbmc, xbmcgui
from string import find
# you must fill out this information first
# station number can be found out from saving the pls file from live365 and opening it in a text editor and find the number that comes right after live365.com/play/
membername = ''
passwd = ''
station = ''
loginurl = 'http://www.live365.com/cgi-bin/login.cgi...mbername=' + membername + '&password=' + passwd
request = clientcookie.request(loginurl)
response = clientcookie.urlopen(request)
cj = clientcookie.cookiejar()
cookies = cj.make_cookies(response, request)
saneid = none
sessionid = none
memberid = none
for cookie in cookies:
xbmcgui.dialog().ok("live365", "cookie")
if cookie.has_nonstandard_attr("saneid") and cookie.has_nonstandard_attr("sessionid"):
saneid = cookie.get_nonstandard_attr("saneid")
tempsession = cookie.get_nonstandard_attr("sessionid")
index = find(tempsession, "%3a")
if index > 0:
memberid = tempsession[:index]
sessionid = tempsession[index+3:]
break
if sessionid is not none:
file='http://www.live365.com/play/' + station + '?saneid=' + saneid + '&membername=' + memberid + '&session=' + sessionid
try:
xbmc.player().play(file)
except:
xbmcgui.dialog().ok("live365","unable to play live365 station")
else:
xbmcgui.dialog().ok("live365", "unable to retrieve cookie from live365")
i always get the last error about unable to retrieve cookie. i never can seem to get the message about it recieving a cookie. i have the clientcookie in a subdirectory of my script. i removed my login information but other than that its the same. does anyone see anything obviously wrong with what i am trying to do? i got the idea from here live365 mplayer
since i cant run bash scripts i tried to convert it into python but so far have been unsuccessful. any ideas?
import clientcookie
import xbmc, xbmcgui
from string import find
# you must fill out this information first
# station number can be found out from saving the pls file from live365 and opening it in a text editor and find the number that comes right after live365.com/play/
membername = ''
passwd = ''
station = ''
loginurl = 'http://www.live365.com/cgi-bin/login.cgi...mbername=' + membername + '&password=' + passwd
request = clientcookie.request(loginurl)
response = clientcookie.urlopen(request)
cj = clientcookie.cookiejar()
cookies = cj.make_cookies(response, request)
saneid = none
sessionid = none
memberid = none
for cookie in cookies:
xbmcgui.dialog().ok("live365", "cookie")
if cookie.has_nonstandard_attr("saneid") and cookie.has_nonstandard_attr("sessionid"):
saneid = cookie.get_nonstandard_attr("saneid")
tempsession = cookie.get_nonstandard_attr("sessionid")
index = find(tempsession, "%3a")
if index > 0:
memberid = tempsession[:index]
sessionid = tempsession[index+3:]
break
if sessionid is not none:
file='http://www.live365.com/play/' + station + '?saneid=' + saneid + '&membername=' + memberid + '&session=' + sessionid
try:
xbmc.player().play(file)
except:
xbmcgui.dialog().ok("live365","unable to play live365 station")
else:
xbmcgui.dialog().ok("live365", "unable to retrieve cookie from live365")
i always get the last error about unable to retrieve cookie. i never can seem to get the message about it recieving a cookie. i have the clientcookie in a subdirectory of my script. i removed my login information but other than that its the same. does anyone see anything obviously wrong with what i am trying to do? i got the idea from here live365 mplayer
since i cant run bash scripts i tried to convert it into python but so far have been unsuccessful. any ideas?