1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 04:05:39 +01:00

Argument handling

This commit is contained in:
Johan Andersson 2011-03-19 17:15:21 +01:00
parent 97eb0a6c4a
commit 96f717fa66

View File

@ -4,6 +4,7 @@ import urllib2
import sys
import os
import subprocess
from optparse import OptionParser
def getdata(url):
""" Get the page to parse it for streams """
@ -54,8 +55,15 @@ def gethttp(url, output):
def main():
""" Main program """
argv = sys.argv[1]
data = getdata(argv)
usage = "usage: %prog [options] arg1"
parser = OptionParser(usage=usage)
parser.add_option("-o", "--output",
metavar="OUTPUT", help="Outputs to the given filename.")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("incorrect number of arguments")
output = options.output
data = getdata(args[0])
match = re.search('dynamicStreams=(.*)\&amp\;background', data)
if match:
new = match.group(1)
@ -68,7 +76,9 @@ def main():
sys.exit(2)
stream = match.group(1)
if not output:
output = os.path.basename(stream)
print "Outfile: ", output
if stream[0:4] == "rtmp":
getrtmp(stream, output)