Help converting a bash (wget+grep) linux script into python (Rai Italian TV)?
#1
Big Grin 
http://svn.assembla.com/svn/montoya83/ra...rai-viewer

That linux script plays italian television, but it requires wget (useragent is necessary because the mms url are dinamically set, and you need to behave as a browser, you need to be a fake web browser Smile) and some grep/head/sed stuff.

Could you help me converting it?
Reply
#2
grab this and try it as a video plugin
http://www.mediafire.com/download.php?qyxhuhzoi2y

i think i am grabbing processing the same urls that the perl script is. I don't think i can play the videos because they are geo locked. i just get region lock videos or a little 3 second demo. let me know if they work for you.

there are alot more videos in that xml though. i don't know Italian so i don't what the other stuff is.

edit:
i made some changes and added a subdirectory that lists the other videos from the xml.
download
http://www.mediafire.com/download.php?myhwygjdznm

i got the rainews24 video working. it doesn't seem to be geolocked
Reply
#3
Thank you!
RaiNews works here too, and the "altri video" (other videos) subdir too.
The main channels (RaiUno, Raidue, Raitre -> RaiOne, RaiTwo, Raithree) shows just 3 seconds of a banner (while the bash script works fine).
how to get some debug?
Reply
#4
judging from the bash script, it seems there's another step to do:
Quote:wget -U "$USERAGENT" -O $LAST $TMP
VIDEO=$(cat $LAST | cut -d'"' -f4)
this is used to get the video after the banner...
Reply
#5
I will see what i can do. i don't really know perl or python so i am not sure what i am doing. I will look a little closer and try to figure it out.
Reply
#6
BlueCop Wrote:I will see what i can do. i don't really know perl or python so i am not sure what i am doing. I will look a little closer and try to figure it out.

basically the issue with your script is that you grab (for example, RaiUno: http://mediapolis.rai.it/relinker/relink...m?cont=983) and send it to the player. But this url should be re-downloaded with the user agent before sending it to the player, so it cointains the right mms stream.
  • No useragent (wget http://mediapolis.rai.it/relinker/relink...m?cont=983):
    Quote:<ASX VERSION="3.0"> <ENTRY> <REF HREF="http://www.banneradmin.rai.it/ads/siparietti/buona_visioneMed_Progautopromo.wmv" /> </ENTRY> </ASX>
  • Useragent (wget -U "Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6" http://mediapolis.rai.it/relinker/relink...m?cont=983):
    Quote:<ASX VERSION="3.0"><ENTRY><REF HREF="mms://livestream.rai.it.edgestreams.net/reflector:64084?auth=daEbYdJcKbDb1d_bZcubibtaoceaac2dIdH-bj8a1H-b4-AmwwxFw&aifp=V001" /></ENTRY></ASX>
Reply
#7
i thought that was the problem but i tried downloading with the correct user agent and processing the ASX for the mms url and it still gave me the http://www.banneradmin.rai.it/ads/sipari...opromo.wmv url. it might just be that i am located in the US. i will upload a modified version shortly for you to test
Reply
#8
try this
http://www.mediafire.com/download.php?kw2dfg31n22

it just gives me the same 3 second preview url.

when you try this version could you post you debug logs to pastebin or some other service so i can see what the asx file data you are retrieving. i added some extra debugging output.
Reply
#9
how can i get the debug?
Reply
#10
http://wiki.xbmc.org/?title=HOW-TO_Submi...Bug_Report

read the section on Collecting an XBMC debug log
Reply
#11
BlueCop Wrote:http://wiki.xbmc.org/?title=HOW-TO_Submi...Bug_Report

read the section on Collecting an XBMC debug log

The useragent does not work...
Reply
#12
Cimi Wrote:The useragent does not work...
ok nevermind. if you aren't going to help me help you i am not going to try.
Reply
#13
BlueCop Wrote:ok nevermind. if you aren't going to help me help you i am not going to try.

?
I've seen from the debug logs that I get the non-useragent URL, so I guess the useragent request to urllib2 didn't work.
Reply
#14
i understand but i asked you to post the log because i wanted to see it.

this should work
http://www.mediafire.com/download.php?zczn2nomnnh
Reply
#15
haven't seen yours yet, but this works here:
Code:
def getHTML( url ):

        print 'Rai Italian Tv --> getHTML :: url = '+url
        opener = urllib2.build_opener()
    opener.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6')]
    response = opener.open(url)
        link=response.read()
        response.close()
        return link

EDIT: your works too!!! it's the linux useragent, then.
Reply

Logout Mark Read Team Forum Stats Members Help
Help converting a bash (wget+grep) linux script into python (Rai Italian TV)?0