mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-24 04:05:39 +01:00
Added argument -q to choose what quality of the stream to download
-q 2400 for HD -q 1200 for High -q 850 for mid -q 320 for low
This commit is contained in:
parent
83f790c7d1
commit
d941a979f5
23
svtplay-dl
23
svtplay-dl
@ -57,31 +57,48 @@ def gethttp(url, output):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" Main program """
|
""" Main program """
|
||||||
usage = "usage: %prog [options] arg1"
|
usage = "usage: %prog [options] url"
|
||||||
parser = OptionParser(usage=usage)
|
parser = OptionParser(usage=usage)
|
||||||
parser.add_option("-o", "--output",
|
parser.add_option("-o", "--output",
|
||||||
metavar="OUTPUT", help="Outputs to the given filename.")
|
metavar="OUTPUT", help="Outputs to the given filename.")
|
||||||
parser.add_option("-l", "--live",
|
parser.add_option("-l", "--live",
|
||||||
action="store_true", dest="live", default=False,
|
action="store_true", dest="live", default=False,
|
||||||
help="Enable for live streams")
|
help="Enable for live streams")
|
||||||
|
parser.add_option("-q", "--quality",
|
||||||
|
metavar="quality", help="Choose what format to download.\nIt will download the best format by default")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
if len(args) != 1:
|
if len(args) != 1:
|
||||||
parser.error("incorrect number of arguments")
|
parser.error("incorrect number of arguments")
|
||||||
output = options.output
|
output = options.output
|
||||||
live = options.live
|
live = options.live
|
||||||
|
quality = options.quality
|
||||||
data = getdata(args[0])
|
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)
|
||||||
tmp = new.split("|")
|
tmp = new.split("|")
|
||||||
match = re.search('url:(.*)\,', tmp[0])
|
streams = {}
|
||||||
|
for f in tmp:
|
||||||
|
match = re.search('url:(.*)\,bitrate:([0-9]+)', f)
|
||||||
|
streams[int(match.group(2))] = match.group(1)
|
||||||
|
if not quality:
|
||||||
|
stream = streams[sorted(streams.keys()).pop()]
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
stream = streams[int(quality)]
|
||||||
|
except ValueError:
|
||||||
|
print "Err: Cant find that quality. try 2400 (HD), 1200 (high), 850 (mid) or 320 (low)"
|
||||||
|
sys.exit(2)
|
||||||
|
except KeyError:
|
||||||
|
print "Err: Cant find that quality. try 2400 (HD), 1200 (high), 850 (mid) or 320 (low)"
|
||||||
|
sys.exit(2)
|
||||||
else:
|
else:
|
||||||
match = re.search('pathflv=(.*)\&\;background', data)
|
match = re.search('pathflv=(.*)\&\;background', data)
|
||||||
if not match:
|
if not match:
|
||||||
print "Err: cant find stream"
|
print "Err: cant find stream"
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
stream = match.group(1)
|
||||||
|
|
||||||
stream = match.group(1)
|
|
||||||
if not output:
|
if not output:
|
||||||
output = os.path.basename(stream)
|
output = os.path.basename(stream)
|
||||||
print "Outfile: ", output
|
print "Outfile: ", output
|
||||||
|
Loading…
Reference in New Issue
Block a user