itsagramlive icon indicating copy to clipboard operation
itsagramlive copied to clipboard

Added optional parameters to STOP(), added a Logger, added a try/except around parse_args() to prevent a crash

Open DylanCa opened this issue 2 years ago • 0 comments

Hi, I took the liberty to do a few modifications:

  1. 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.'. If save_to_igtv is not set, the behaviour stays the same. However, if it is set to either True or False, no input is required.
  1. Replaced print() methods with logger.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() and stop_broadcast() to properly relate what is happening in real time.
  1. 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.

DylanCa avatar Dec 31 '21 16:12 DylanCa