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
tmpdir = extract_db(newpipe_archive)
db_file = tmpdir / "newpipe.db"
if args.list_categories:
for category in list_categories(db_file):
print(category)
else:
categories = []
if not sys.stdin.isatty():
for line in sys.stdin:
categories.append(line.strip())
if len(args.categories) > 0:
categories = args.categories
elif len(categories) == 0:
categories = list_categories(db_file)
data = extract_categories_from_db(db_file, categories)
output_file = args.output
if output_file:
with open(output_file, mode="w", encoding="UTF-8") as file: