1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-23 19:55:38 +01:00

Added some boolean flags to the postprocess

* replaced `--remux` with `--no-remux`
    * added `--no-merge`
    * added `--no-postprocess`
    * added `--keep-original`

This should be sufficient to consider issue #1194 fixed.
This commit is contained in:
iwconfig 2020-01-02 20:53:23 +01:00 committed by Johan Andersson
parent d32bc0280d
commit 19d63f1eb9
3 changed files with 50 additions and 10 deletions

View File

@ -83,6 +83,11 @@ class postprocess:
if returncode != 0:
return
if self.config.get("keep_original") is True:
logging.info("Muxing done, keeping original file(s).")
os.rename(tempfile, new_name)
return
if self.config.get("merge_subtitle") and not self.config.get("subtitle"):
logging.info("Muxing done, removing the old files.")
if self.subfixes and len(self.subfixes) >= 2:
@ -166,6 +171,11 @@ class postprocess:
if returncode != 0:
return
if self.config.get("keep_original") is True:
logging.info("Merging done, keeping original files.")
os.rename(tempfile, orig_filename)
return
logging.info("Merging done, removing old files.")
if self.config.get("only_video") or not self.config.get("only_audio"):
os.remove(orig_filename)

View File

@ -208,12 +208,23 @@ def get_one_media(stream):
if fstream.config.get("thumbnail") and hasattr(stream, "get_thumbnail"):
stream.get_thumbnail(stream.config)
post = postprocess(fstream, fstream.config, subfixes)
if fstream.audio and not post.detect and fstream.finished:
logging.warning("Cant find ffmpeg/avconv. audio and video is in seperate files. if you dont want this use -P hls")
elif fstream.audio and post.detect:
post.merge()
elif fstream.name == "hls" or fstream.config.get("remux"):
post.remux()
if fstream.config.get("no_postprocess") is True or all(fstream.config.get(x) for x in ["no_remux", "no_merge"]) is True:
logging.info("All done. Not postprocessing files, leaving them completely untouched.")
if fstream.config.get("no_postprocess") is False:
post = postprocess(fstream, fstream.config, subfixes)
if fstream.audio and not post.detect and fstream.finished:
logging.warning("Can't find ffmpeg/avconv. audio and video is in seperate files. if you dont want this use -P hls or hds")
if fstream.audio and post.detect and fstream.config.get("no_merge") is False:
post.merge()
elif fstream.name == "hls" and post.detect and fstream.config.get("no_remux") is False:
if fstream.config.get("no_merge") is True:
logging.warning("Can't remux HLS streams without merging. Use --no-postprocess to leave content completely untouched.")
post.merge()
post.remux()
else:
logging.info("All done. Not postprocessing files, leaving them completely untouched.")
if fstream.config.get("silent_semi") and fstream.finished:
logging.log(25, "Download of %s was completed" % fstream.options.output)

View File

@ -124,7 +124,6 @@ def gen_parser(version="unknown"):
metavar="cookie1=value;cookie2=value2",
help="A cookies to add to each HTTP request.",
)
general.add_argument("--remux", dest="remux", default=False, action="store_true", help="Remux from one container to mp4 using ffmpeg or avconv")
general.add_argument(
"--exclude",
dest="exclude",
@ -267,6 +266,20 @@ def gen_parser(version="unknown"):
cmorep.add_argument("--cmore-operatorlist", dest="cmoreoperatorlist", default=False, action="store_true", help="show operatorlist for cmore")
cmorep.add_argument("--cmore-operator", dest="cmoreoperator", default=None, metavar="operator")
postprocessing = parser.add_argument_group("Post-processing")
postprocessing.add_argument("--no-remux", dest="no_remux", default=False, action="store_true", help="Do not automatically remux to mp4")
postprocessing.add_argument(
"--no-merge",
dest="no_merge",
default=False,
action="store_true",
help="Do not automatically merge video, audio and possibly also subtitle(s) together",
)
postprocessing.add_argument("--no-postprocess", dest="no_postprocess", default=False, action="store_true", help="Do not postprocess anything")
postprocessing.add_argument(
"--keep-original", dest="keep_original", default=False, action="store_true", help="Do postprocessing while also keeping original files"
)
parser.add_argument("urls", nargs="*")
return parser
@ -321,7 +334,10 @@ def setup_defaults():
options.set("audio_language", None)
options.set("audio_role", None)
options.set("stream_prio", None)
options.set("remux", False)
options.set("no_remux", False)
options.set("no_merge", False)
options.set("no_postprocess", False)
options.set("keep_original", False)
options.set("silent_semi", False)
options.set("proxy", None)
options.set("include_clips", False)
@ -369,7 +385,10 @@ def parsertoconfig(config, parser):
config.set("audio_role", parser.audio_role)
config.set("audio_language", parser.audio_language)
config.set("stream_prio", parser.stream_prio)
config.set("remux", parser.remux)
config.set("no_remux", parser.no_remux)
config.set("no_merge", parser.no_merge)
config.set("no_postprocess", parser.no_postprocess)
config.set("keep_original", parser.keep_original)
config.set("get_all_subtitles", parser.get_all_subtitles)
config.set("get_raw_subtitles", parser.get_raw_subtitles)
config.set("convert_subtitle_colors", parser.convert_subtitle_colors)