1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

logging f-strings fixes

This commit is contained in:
Johan Andersson 2021-12-18 21:36:16 +01:00
parent 96544ae2f8
commit e20d753a15
8 changed files with 18 additions and 15 deletions

View File

@ -72,5 +72,5 @@ def main():
except KeyboardInterrupt: except KeyboardInterrupt:
print("") print("")
except (yaml.YAMLError, yaml.MarkedYAMLError) as e: except (yaml.YAMLError, yaml.MarkedYAMLError) as e:
logging.error(f"Your settings file(s) contain invalid YAML syntax! Please fix and restart!, {str(e)}") logging.error("Your settings file(s) contain invalid YAML syntax! Please fix and restart!, %s", str(e))
sys.exit(2) sys.exit(2)

View File

@ -57,9 +57,9 @@ class postprocess:
videotrack, audiotrack = _checktracks(streams) videotrack, audiotrack = _checktracks(streams)
if self.config.get("merge_subtitle"): if self.config.get("merge_subtitle"):
logging.info(f"Merge audio, video and subtitle into {new_name.name}") logging.info("Merge audio, video and subtitle into %s", new_name.name)
else: else:
logging.info(f"Merge audio and video into {new_name.name}") logging.info("Merge audio and video into %s", new_name.name)
tempfile = orig_filename.with_suffix(".temp") tempfile = orig_filename.with_suffix(".temp")
arguments = ["-c:v", "copy", "-c:a", "copy", "-f", "matroska" if self.config.get("output_format") == "mkv" else "mp4"] arguments = ["-c:v", "copy", "-c:a", "copy", "-f", "matroska" if self.config.get("output_format") == "mkv" else "mp4"]

View File

@ -55,7 +55,7 @@ class Service:
else: else:
self.http = http self.http = http
logging.debug(f"service: {self.__class__.__name__.lower()}") logging.debug("service: %s", self.__class__.__name__.lower())
@property @property
def url(self): def url(self):

View File

@ -38,7 +38,7 @@ class subtitle:
self.output["ext"] = output_ext self.output["ext"] = output_ext
dupe, fileame = find_dupes(self.output, self.config, False) dupe, fileame = find_dupes(self.output, self.config, False)
if dupe and not self.config.get("force_subtitle"): if dupe and not self.config.get("force_subtitle"):
logging.warning(f"File ({fileame.name}) already exists. Use --force-subtitle to overwrite") logging.warning("File (%s) already exists. Use --force-subtitle to overwrite", fileame.name)
return return
subdata = self.http.request("get", self.url) subdata = self.http.request("get", self.url)
if subdata.status_code != 200: if subdata.status_code != 200:

View File

@ -44,7 +44,7 @@ def get_media(url, options, version="Unknown"):
url = f"http://{url}" url = f"http://{url}"
if options.get("verbose"): if options.get("verbose"):
logging.debug(f"version: {version}") logging.debug("version: %s", version)
stream = service_handler(sites, options, url) stream = service_handler(sites, options, url)
if not stream: if not stream:
@ -141,8 +141,11 @@ def get_one_media(stream):
pub_date = None pub_date = None
if after_date is not None and pub_date is not None and pub_date.date() < after_date.date(): if after_date is not None and pub_date is not None and pub_date.date() < after_date.date():
logging.info( logging.info(
f"Video {stream.output['title']}S{stream.output['season']}E{stream.output['episode']}" "Video %sS%dE%d skipped since published %s.",
f" skipped since published {pub_date.date()} before {after_date.date()}.", stream.output["title"],
stream.output["season"],
stream.output["episode"],
pub_date.date(),
) )
return return
@ -163,7 +166,7 @@ def get_one_media(stream):
else: else:
errormsg = str(exc) errormsg = str(exc)
if errormsg: if errormsg:
logging.error(f"No videos found. {errormsg}") logging.error("No videos found. %s", errormsg)
else: else:
logging.error("No videos found.") logging.error("No videos found.")
else: else:
@ -188,7 +191,7 @@ def get_one_media(stream):
dupe, fileame = find_dupes(fstream.output, stream.config) dupe, fileame = find_dupes(fstream.output, stream.config)
if dupe and not stream.config.get("force"): if dupe and not stream.config.get("force"):
logging.warning(f"File ({fileame.name}) already exists. Use --force to overwrite") logging.warning("File (%s) already exists. Use --force to overwrite", fileame.name)
return return
if fstream.config.get("output_format") and fstream.config.get("output_format").lower() not in ["mkv", "mp4"]: if fstream.config.get("output_format") and fstream.config.get("output_format").lower() not in ["mkv", "mp4"]:
logging.error("Unknown output format. please choose mp4 or mkv") logging.error("Unknown output format. please choose mp4 or mkv")
@ -206,7 +209,7 @@ def get_one_media(stream):
stream.get_thumbnail(stream.config) stream.get_thumbnail(stream.config)
if fstream.config.get("silent_semi") and fstream.finished: if fstream.config.get("silent_semi") and fstream.finished:
logging.log(25, f"Download of {formatname(fstream.output, fstream.config, fstream.output_extention)} was completed") logging.log(25, "Download of %s was completed", formatname(fstream.output, fstream.config, fstream.output_extention))
if fstream.config.get("no_postprocess") is True or all(fstream.config.get(x) for x in ["no_remux", "no_merge"]) is True: 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.") logging.info("All done. Not postprocessing files, leaving them completely untouched.")

View File

@ -33,7 +33,7 @@ def write_nfo_episode(output, config):
filename = formatname(loutout, config) filename = formatname(loutout, config)
dupe, fileame = find_dupes(loutout.copy(), config, False) dupe, fileame = find_dupes(loutout.copy(), config, False)
if dupe and not config.get("force_nfo"): if dupe and not config.get("force_nfo"):
logging.warning(f"File ({fileame.name}) already exists. Use --force-nfo to overwrite") logging.warning("File (%s) already exists. Use --force-nfo to overwrite", fileame.name)
return return
logging.info("NFO episode: %s", filename) logging.info("NFO episode: %s", filename)
@ -67,7 +67,7 @@ def write_nfo_tvshow(output, config):
filename = formatname(loutput, cconfig) filename = formatname(loutput, cconfig)
dupe, fileame = find_dupes(loutput, cconfig, False) dupe, fileame = find_dupes(loutput, cconfig, False)
if dupe and not cconfig.get("force_nfo"): if dupe and not cconfig.get("force_nfo"):
logging.warning(f"File ({fileame.name}) already exists. Use --force-nfo to overwrite") logging.warning("File (%s) already exists. Use --force-nfo to overwrite", fileame.name)
return return
logging.info("NFO show: %s", filename) logging.info("NFO show: %s", filename)

View File

@ -463,7 +463,7 @@ def readconfig(config, configfile, service=None, preset=None):
data = fd.read() data = fd.read()
configdata = safe_load(data) configdata = safe_load(data)
except PermissionError: except PermissionError:
logging.error(f"Permission denied while reading config: {configfile}") logging.error("Permission denied while reading config: %s", configfile)
if configdata is None: if configdata is None:
return config return config

View File

@ -8,5 +8,5 @@ def run_program(cmd, show=True):
stderr = stderr.decode("utf-8", "replace") stderr = stderr.decode("utf-8", "replace")
if p.returncode != 0 and show: if p.returncode != 0 and show:
msg = stderr.strip() msg = stderr.strip()
logging.error(f"Something went wrong: {msg}") logging.error("Something went wrong: %s", msg)
return p.returncode, stdout, stderr return p.returncode, stdout, stderr