diff --git a/modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-newpipe-db b/modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-newpipe-db.py similarity index 73% rename from modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-newpipe-db rename to modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-newpipe-db.py index 697d013f..df5a904d 100755 --- a/modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-newpipe-db +++ b/modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-newpipe-db.py @@ -27,33 +27,35 @@ def kebab_case(string): def extract_categories_from_db(db_file, categories): with sqlite3.connect(db_file) as db: db.row_factory = sqlite3.Row - query = ''' + query = """ SELECT subscriptions.name AS name, subscriptions.url AS url, feed_group.name AS tag FROM subscriptions INNER JOIN feed_group_subscription_join AS subs_join INNER JOIN feed_group ON subs_join.subscription_id = subscriptions.uid AND feed_group.uid = subs_join.group_id ORDER BY name COLLATE NOCASE; - ''' + """ - data = { kebab_case(category): { - "subscriptions" : [], - "extraArgs" : [] - } for category in categories } + data = { + kebab_case(category): {"subscriptions": [], "extraArgs": []} + for category in categories + } for row in db.execute(query): category = row["tag"] if category in categories: - data[kebab_case(category)]["subscriptions"].append({ "url": row["url"], "name": row["name"] }) + data[kebab_case(category)]["subscriptions"].append( + {"url": row["url"], "name": row["name"]} + ) return data def list_categories(db_file): with sqlite3.connect(db_file) as db: - query = ''' + query = """ SELECT name FROM feed_group ORDER BY name; - ''' + """ data = [] for row in db.execute(query): data.append(row[0]) @@ -69,10 +71,30 @@ def extract_db(newpipe_archive): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument("newpipe_db", metavar="NEWPIPE_DB", help="Newpipe database file (as a zip file) exported straight from the app.") - parser.add_argument("categories", metavar="CATEGORIES", nargs="*", help="A list of categories to be extracted. If absent, it will extract with all categories.") - parser.add_argument("--list-categories", "-l", action="store_true", help="List all categories from the database.") - parser.add_argument("--output", "-o", action="store", metavar="FILE", help="If present, store the output in the given file") + parser.add_argument( + "newpipe_db", + metavar="NEWPIPE_DB", + help="Newpipe database file (as a zip file) exported straight from the app.", + ) + parser.add_argument( + "categories", + metavar="CATEGORIES", + nargs="*", + help="A list of categories to be extracted. If absent, it will extract with all categories.", + ) + parser.add_argument( + "--list-categories", + "-l", + action="store_true", + help="List all categories from the database.", + ) + parser.add_argument( + "--output", + "-o", + action="store", + metavar="FILE", + help="If present, store the output in the given file", + ) args = parser.parse_args() newpipe_archive = args.newpipe_db diff --git a/modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-rss-opml b/modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-rss-opml.py similarity index 99% rename from modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-rss-opml rename to modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-rss-opml.py index faa9d37f..88375388 100755 --- a/modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-rss-opml +++ b/modules/nixos/tasks/multimedia-archive/scripts/create-jobs-from-rss-opml.py @@ -270,7 +270,7 @@ if __name__ == "__main__": for key in keys: data[kebab_case(key)] = data.pop(key) - json_dump_kwargs = { "default": vars } + json_dump_kwargs = {"default": vars} if "output_file" in args: with open(args.file, mode="r") as output_file: