mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-28 06:04:17 +01:00
option to choose which download method is preferred.
This commit is contained in:
parent
924cca1380
commit
8225cff429
@ -56,6 +56,7 @@ class Options:
|
||||
self.thumbnail = False
|
||||
self.all_episodes = False
|
||||
self.force_subtitle = False
|
||||
self.preferred = None
|
||||
|
||||
def get_media(url, options):
|
||||
|
||||
@ -196,6 +197,8 @@ def main():
|
||||
parser.add_option("-A", "--all-episodes",
|
||||
action="store_true", dest="all_episodes", default=False,
|
||||
help="Try to download all episodes.")
|
||||
parser.add_option("-P", "--preferred", default=None,
|
||||
metavar="preferred", help="preferred download method")
|
||||
(options, args) = parser.parse_args()
|
||||
if not args:
|
||||
parser.print_help()
|
||||
|
@ -2,5 +2,8 @@ class VideoRetriever:
|
||||
def __init__(self, options, url, bitrate, **kwargs):
|
||||
self.options = options
|
||||
self.url = url
|
||||
self.bitrate = bitrate
|
||||
self.bitrate = int(bitrate)
|
||||
self.kwargs = kwargs
|
||||
|
||||
def name(self):
|
||||
pass
|
@ -61,6 +61,9 @@ def hdsparse(options, manifest):
|
||||
return streams
|
||||
|
||||
class HDS(VideoRetriever):
|
||||
def name(self):
|
||||
return "hds"
|
||||
|
||||
def download(self):
|
||||
if self.options.live and not self.options.force:
|
||||
raise LiveHDSException(self.url)
|
||||
|
@ -52,6 +52,9 @@ def hlsparse(url):
|
||||
return streams
|
||||
|
||||
class HLS(VideoRetriever):
|
||||
def name(self):
|
||||
return "hls"
|
||||
|
||||
def download(self):
|
||||
if self.options.live and not self.options.force:
|
||||
raise LiveHLSException(self.url)
|
||||
|
@ -12,6 +12,9 @@ from svtplay_dl.utils.urllib import urlopen, Request, HTTPError
|
||||
from svtplay_dl.fetcher import VideoRetriever
|
||||
|
||||
class HTTP(VideoRetriever):
|
||||
def name(self):
|
||||
return "http"
|
||||
|
||||
def download(self):
|
||||
""" Get the stream from HTTP """
|
||||
request = Request(self.url)
|
||||
|
@ -11,6 +11,9 @@ from svtplay_dl.utils import is_py2
|
||||
from svtplay_dl.fetcher import VideoRetriever
|
||||
|
||||
class RTMP(VideoRetriever):
|
||||
def name(self):
|
||||
return "hds"
|
||||
|
||||
def download(self):
|
||||
""" Get the stream from RTMP """
|
||||
args = []
|
||||
|
@ -106,8 +106,13 @@ def check_redirect(url):
|
||||
return url
|
||||
|
||||
def select_quality(options, streams):
|
||||
if options.preferred:
|
||||
available = []
|
||||
data = sorted(streams, key=lambda x:(x.name()!= options.preferred, x.name()), reverse=True)
|
||||
for i in data:
|
||||
available.append(i.bitrate)
|
||||
else:
|
||||
available = sorted(int(x.bitrate) for x in streams)
|
||||
|
||||
try:
|
||||
optq = int(options.quality)
|
||||
except ValueError:
|
||||
|
Loading…
Reference in New Issue
Block a user