itsagramlive
itsagramlive copied to clipboard
Added optional parameters to STOP(), added a Logger, added a try/except around parse_args() to prevent a crash
Hi, I took the liberty to do a few modifications:
- Added optional parameters to the
stop()
method:
- I am using this package with Django, and I need to be able to fully control the live without having to input anything manually, so I have added 3 parameters, which are
save_to_igtv: bool = None, title = 'Live video', description = 'Live Instagram video.'
. Ifsave_to_igtv
is not set, the behaviour stays the same. However, if it is set to either True or False, no input is required.
- Replaced
print()
methods withlogger.info()
methods:
- To make the code more maintainable and reliable, I setup a basic logger and replaced the prints methods so us developers can know exactly what is happening and where.
- I have added a couple logging in methods, such as
start_broadcast()
andstop_broadcast()
to properly relate what is happening in real time.
- Added a try/except around
parser.parse_args()
in__init__()
to prevent a SystemExit error to crash the app:
- Because the parser tries to get args, when there are no arguments provided, it raises a
SystemExit
error which makes the whole app to crash. - This try/except is used only to catch the error and instead log what is happening then raises a non-fatal error.
I did my best to not modify but only improved what you did, and try to adapt the code to fit with my needs, which basically are 'be able to fully manage an instance of ItsAGramLive using Django & REST endpoints".
If you have any question or if you want me to change things, please do not hesitate.