From 8d1b7a66b7fc59bc3499218ddd8e0104a53b5bb6 Mon Sep 17 00:00:00 2001 From: Richard Mwewa <74001397+rly0nheart@users.noreply.github.com> Date: Sat, 24 Sep 2022 16:28:59 +0200 Subject: [PATCH] Updated downloader.py and README.md --- README.md | 1 + downloader.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4782620..2ca28e3 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ python downloader.py https://www.facebook.com/PageName/videos/VideoID | *-A/--audio* | download audio only (coming soon) | | *-o/--output* | output filename | | *-v/--version* | show program's version number and exit | +| *-d/--debug* | enable debug mode | # Donations If you would like to donate, you could Buy A Coffee for the developer using the button below diff --git a/downloader.py b/downloader.py index a11dca4..44e1649 100644 --- a/downloader.py +++ b/downloader.py @@ -46,7 +46,7 @@ class FacebookDownloader: with open(file, "wb") as f: f.write(data.content) f.close() - exit(f"Updated: Re-run program.") + logging.info(f"Updated: Re-run program.") else: pass @@ -82,8 +82,12 @@ parser = argparse.ArgumentParser(description='Facebook-Downloader — by Richard parser.add_argument('url', help='facebook video url (eg. https://www.facebook.com/PageName/videos/VideoID') parser.add_argument('-A', '--audio', help=argparse.SUPPRESS, action='store_true') parser.add_argument('-o', '--output', help='output filename') +parser.add_argument('-d', '--debug', help='enable debug mode', action='store_true') args = parser.parse_args() -logging.basicConfig(format='[%(asctime)s] %(levelname)s: %(message)s', datefmt='%I:%M:%S%p', level='NOTSET') +if args.debug: + logging.basicConfig(format='[%(asctime)s] %(message)s', datefmt='%I:%M:%S%p', level=logging.DEBUG) +else: + logging.basicConfig(format='[%(asctime)s] %(message)s', datefmt='%I:%M:%S%p', level=logging.INFO) if __name__ == "__main__": try: @@ -93,4 +97,4 @@ if __name__ == "__main__": logging.warning('Process interrupted with Ctrl+C.') except Exception as e: - logging.error(e) \ No newline at end of file + logging.error(f'An error occured: {e}') \ No newline at end of file