aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlater10
1 files changed, 7 insertions, 3 deletions
diff --git a/later b/later
index 61d8abe..5b82a6e 100755
--- a/later
+++ b/later
@@ -21,6 +21,10 @@ class YTDLPLogger:
print("later: yt-dlp:", msg, file=sys.stderr)
+def exit(message=""):
+ sys.exit(f"later: {message}" if message else 0)
+
+
def get_xdg(type, fallback):
env = f"XDG_{type.upper()}_HOME"
if env in os.environ:
@@ -75,7 +79,7 @@ class TitleMap:
# Clobber the title cache if it was corrupted
self.commit_to_disk = True
except Exception as err:
- sys.exit(f"later: cannot read title cache: {err}")
+ exit(f"cannot read title cache: {err}")
def mark_seen(self, key):
self.seen.add(key)
@@ -96,7 +100,7 @@ class TitleMap:
# necessary: importing yt_dlp is noticeably slow :(
import yt_dlp
except ModuleNotFoundError:
- sys.exit("later: yt-dlp was requested, but yt_dlp python module not found")
+ exit("yt-dlp was requested, but yt_dlp python module not found")
if not self.ytdl:
self.ytdl = yt_dlp.YoutubeDL({"logger": YTDLPLogger()})
@@ -131,7 +135,7 @@ class TitleMap:
with open(self.path, "w") as handle:
json.dump(seen_entries, handle)
except OSError as err:
- sys.exit(f"later: cannot write title cache: {err}")
+ exit(f"cannot write title cache: {err}")
def entries(title_map):