harrypython / itsagramlive

It's A Gram Live is a Python script that create a Instagram Live and provide you a rtmp server and stream key to streaming using sofwares like OBS-Studio.
GNU General Public License v3.0
175 stars 51 forks source link

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

Open DylanCa opened 2 years ago

DylanCa commented 2 years ago

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.
  2. 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.
  3. 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.