From 17059607d506d25fff4d654146a5c7e9b663cc76 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 7 Apr 2022 15:30:02 +0200 Subject: Move script files into tools directory --- list-missing-unwatched.py | 50 ----------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100755 list-missing-unwatched.py (limited to 'list-missing-unwatched.py') diff --git a/list-missing-unwatched.py b/list-missing-unwatched.py deleted file mode 100755 index 980c500..0000000 --- a/list-missing-unwatched.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import sys - -def show_notification(title, description, urgency): - print("Notification: title: %s, description: %s" % (title, description)) - process = subprocess.Popen(["notify-send", "-a", "automedia", "-t", "10000", "-u", urgency, "--", title, description]) - stdout, stderr = process.communicate() - return process.returncode == 0 - -def get_downloaded(): - process = subprocess.Popen(["automedia", "downloaded"], stdout=subprocess.PIPE) - stdout, stderr = process.communicate() - if process.returncode != 0: - return None - return stdout.decode("utf-8").splitlines(False) - -def get_seen(): - try: - with open(os.path.expanduser("~/.config/automedia/seen")) as file: - return file.read().splitlines() - except IOError as err: - return [] - -def main(): - if len(sys.argv) != 2: - print("usage: list-missing-unwatched.py ") - sys.exit(1) - - automedia_dir = sys.argv[1] - if not os.path.exists(automedia_dir): - show_notification("list-missing-unwatched", "No such file or directory: " % automedia_dir, "critical") - sys.exit(2) - - downloaded = get_downloaded() - if not downloaded: - show_notification("list-missing-unwatched", "Failed to get downloaded episodes/chapters", "critical") - sys.exit(2) - - downloaded = dict.fromkeys(downloaded) - seen = dict.fromkeys(get_seen()) - unwatched = [t for t in downloaded if t not in seen] - missing = [u for u in unwatched if not os.path.exists(os.path.join(automedia_dir, u))] - for u in missing: - print(u) - -if __name__ == "__main__": - main() -- cgit v1.2.3