Hi,
i've made a new youtube script in python.
It works on amiga and so it shoudl work also on Linux
please test it, and maybe change the wiki page
Andrea
import os
import getopt
import sys
def usage():
print "usage:"
print " youtube.py -m url [-d]\n"
print "-m: media to play. For example: t3s-mG5yUjY"
print "-d: turn on debug messages"
def main():
resultstring = '"flashvars='
entirefile = ""
file = ""
debug = 0
if len(sys.argv) < 2:
usage()
sys.exit(2)
try:
opts, args = getopt.getopt(sys.argv[1:], "hm:d", ["help",
"movie=", "debug"])
except getopt.GetoptError, err:
print str(err)
usage()
sys.exit(2)
for o, a in opts:
if o in ("-h", "--help"):
usage()
elif o in ("-d", "--debug"):
debug = 1
elif o in ("-m", "--movie"):
file = "wget --quiet -O -
http://www.youtube.com/watch?v=" + a + " >youtube.txt"
if file == "":
usage()
sys.exit(2)
if debug == 1:
print "file=" + file
os.system(file)
f = open("youtube.txt","r")
entirefile = f.read()
f.close()
startline = entirefile.find('swfArgs')
if startline > 0:
endline = entirefile.find('\n',startline)
if endline > 0:
swfArgs = entirefile[startline+11:endline]
if debug == 1:
print "swfArgs=" + swfArgs
result = swfArgs.split(',')
i = 0
for t in result:
result2 = t.split(':')
for x in result2:
i = i + 1
x = x.replace('"','')
x = x.replace(' ','')
if i == 1:
resultstring = resultstring + x
+ '='
else:
resultstring = resultstring + x
+ '&'
i = 0
resultstring = resultstring[0:len(resultstring)-3]
resultstring = resultstring + '"'
os.system('gtk-gnash -F 2 -P ' + resultstring + '
http://www.youtube.com/player2.swf')
if debug == 1:
f = open("flashvars.txt","w")
f.write(resultstring)
f.close()
else:
print "Invalid movie!"
else:
print "Invalid movie!"
if __name__ == "__main__":
main()
_______________________________________________
Gnash-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnash-dev