obervinov / pyinstabot-downloader

This project is a Telegram bot that allows you to upload posts from your Instagram profile to the cloud like any cloud storage that supports WebDav.
MIT License
0 stars 4 forks source link

Add exception handling for the downloader for 400, 401 http codes #18

Closed obervinov closed 4 months ago

obervinov commented 1 year ago

HTTP/401

[2023-09-14 18:43:25,082] INFO [root.check_permissions:50] [class.UsersAuth] access allowed from userid ****
[2023-09-14 18:43:25,098] INFO [root.get_post_account:153] [__main__] starting handler for url https://www.instagram.com/p/****/?igshid=****==...
JSON Query to api/v1/media/****/info/: HTTP error code 401. [retrying; skip with ^C]
JSON Query to api/v1/media/****/info/: HTTP error code 401. [retrying; skip with ^C]
Unable to fetch high quality image version of <Post ****>: JSON Query to api/v1/media/****/info/: HTTP error code 401.

HTTP/400

[2023-09-14 19:03:06,792] INFO [root.check_permissions:50] [class.UsersAuth] access allowed from userid ****
[2023-09-14 19:03:06,808] INFO [root.get_post_account:153] [__main__] starting handler for url https://www.instagram.com/p/****/?igshid=****==...
download_pic(): HTTP error code 400. [retrying; skip with ^C]
download_pic(): HTTP error code 400. [retrying; skip with ^C]
Traceback (most recent call last):
  File "/home/pyinstabot-downloader/app/bot.py", line 220, in <module>
    main()
  File "/home/pyinstabot-downloader/app/bot.py", line 216, in main
    constants.BOT.polling()
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/telebot/__init__.py", line 1043, in polling
    self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/telebot/__init__.py", line 1118, in __threaded_polling
    raise e
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/telebot/__init__.py", line 1074, in __threaded_polling
    self.worker_pool.raise_exceptions()
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/telebot/util.py", line 147, in raise_exceptions
    raise self.exception_info
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/telebot/util.py", line 90, in run
    task(*args, **kwargs)
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/telebot/__init__.py", line 6770, in _run_middlewares_and_handler
    result = handler['function'](message)
  File "/home/pyinstabot-downloader/app/bot.py", line 183, in get_post_account
    d_response = constants.DOWNLOADER_INSTANCE.get_post_content(
  File "/home/pyinstabot-downloader/app/modules/downloader.py", line 231, in get_post_content
    self.instaloader.download_post(post, '')
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/instaloader/instaloader.py", line 747, in download_post
    downloaded &= self.download_pic(filename=sidecar_filename, url=sidecar_node.video_url,
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/instaloader/instaloader.py", line 109, in call
    return call(instaloader, *args, **kwargs)
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/instaloader/instaloader.py", line 109, in call
    return call(instaloader, *args, **kwargs)
  File "/home/pyinstabot-downloader/.local/lib/python3.10/site-packages/instaloader/instaloader.py", line 101, in call
    raise ConnectionException(error_string) from None
instaloader.exceptions.ConnectionException: download_pic(): HTTP error code 400.

To-Do:

obervinov commented 5 months ago

A controversial solution, until its benefits are understood