mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-27 21:54:17 +01:00
Argument handling
This commit is contained in:
parent
97eb0a6c4a
commit
96f717fa66
14
svtplay-dl
14
svtplay-dl
@ -4,6 +4,7 @@ import urllib2
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
def getdata(url):
|
def getdata(url):
|
||||||
""" Get the page to parse it for streams """
|
""" Get the page to parse it for streams """
|
||||||
@ -54,8 +55,15 @@ def gethttp(url, output):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" Main program """
|
""" Main program """
|
||||||
argv = sys.argv[1]
|
usage = "usage: %prog [options] arg1"
|
||||||
data = getdata(argv)
|
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=(.*)\&\;background', data)
|
match = re.search('dynamicStreams=(.*)\&\;background', data)
|
||||||
if match:
|
if match:
|
||||||
new = match.group(1)
|
new = match.group(1)
|
||||||
@ -68,7 +76,9 @@ def main():
|
|||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
stream = match.group(1)
|
stream = match.group(1)
|
||||||
|
if not output:
|
||||||
output = os.path.basename(stream)
|
output = os.path.basename(stream)
|
||||||
|
print "Outfile: ", output
|
||||||
|
|
||||||
if stream[0:4] == "rtmp":
|
if stream[0:4] == "rtmp":
|
||||||
getrtmp(stream, output)
|
getrtmp(stream, output)
|
||||||
|
Loading…
Reference in New Issue
Block a user