Skip to content

Commit

Permalink
try logging in every time a download comes in
Browse files Browse the repository at this point in the history
I may want to remove this later if it causes too many requests to Instagram's API
  • Loading branch information
kytpbs committed Aug 7, 2024
1 parent 82de825 commit 35ab72f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class InstagramDownloader(VideoDownloader):
@staticmethod
def download_video_from_link(url: str, path: str | None = None) -> VIDEO_RETURN_TYPE:
attachment_list: VIDEO_RETURN_TYPE = []
global logged_in # pylint: disable=global-statement # can't think of a better way rn
logged_in = _login() # retry login if it failed the first time

if path is None:
path = os.path.join("downloads", "instagram")
Expand All @@ -110,7 +112,7 @@ def download_video_from_link(url: str, path: str | None = None) -> VIDEO_RETURN_

file_path = os.path.join(path, f"{post.shortcode}_{index}.mp4") # type: ignore # there is a bug in pylance...
file = VideoFile(file_path, post.caption)

if not os.path.exists(file.path) and not downloaded:
downloader.download_post(post, path) # type: ignore # path is literally a Path object it cannot be None...
downloaded = True
Expand Down

0 comments on commit 35ab72f

Please sign in to comment.