Closed Fakhrillo closed 2 weeks ago
Looking into this. Can you share some urls that are not working? Will attempt to fix it today.
from pyigdl import IGDownloader
data = IGDownloader("https://www.instagram.com/reel/C-0CTl6o7SO/?igsh=MTRqeGJyY3hsdThhaA==")
print(data[0]["download_link"])
I tried this one and got link to it's thumbnail image:
Quick update on the issue, so, the API response from the scraper had been changed. Updating the new code and testing it before sharing it. Should be live in an hour or so.
Hey @Fakhrillo , try now, patched it. Let me know if you still face any issue.
Will look into an improved solution in near future.
Hey @CrypticGuy , love your work.
I’m encountering an issue with the IGDownloader
function from pyigdl
. When running the following code:
from pyigdl import IGDownloader
data = IGDownloader("https://www.instagram.com/p/C_B03_ry0aK/?utm_source=ig_web_copy_link")
# print(data[0]["download_link"])
print(data)
I noticed that the thumbnail_link
values are not returned correctly after the first three items. It returns thumbnail_link': '/imgs/loader.gif
, whereas download_link
is returned correctly.
I'm including the response in JSON format:
Is there a known issue or limitation with the IGDownloader
function that could explain this behavior?
I appreciate your help in resolving this issue. Thank you!
Hey @amiteshore , looking into this. Is this like one of those carousel posts? I haven't evaluated those yet, but I'll check this and get back.
@CrypticGuy Yes, the issue I'm describing occurs specifically with carousel posts.
The IGDownloader
function works correctly for single photos or reels. However, when handling links that contain multiple posts (such as carousel posts), it seems to encounter problems, leading to incorrect thumbnail_link
values after the initial items.
Sure. Will check it out and see what the issue is.
Hey @amiteshore , try running it now. Made some patches to support carousel downloads. It should work now.
Hi @CrypticGuy,
Thanks for the quick update! The changes you made have indeed resolved the issues with carousel posts—they are now working as expected.
However, I've encountered a new issue with single photo posts. Here’s the test code I used:
from pyigdl import IGDownloader
import json
# data = IGDownloader("https://www.instagram.com/p/C-VlefaxDc9") # Carousel, works
# data = IGDownloader("https://www.instagram.com/reel/C-TIiK4y7_w") # Reel, works
data = IGDownloader("https://www.instagram.com/p/C-5szP6xjoC") # Single photo, doesn't work
formatted_data = json.dumps(data, indent=4, sort_keys=True)
print(formatted_data)
When attempting to download a single photo, I get the following error:
Traceback (most recent call last):
File "/home/username/exp/downloader/venv/lib/python3.12/site-packages/pyigdl/igdl.py", line 59, in IGDownloader
return _sendPostRequest(serverUrl, payloadData, headers)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/username/exp/downloader/venv/lib/python3.12/site-packages/pyigdl/igdl.py", line 52, in _sendPostRequest
return _parseResponse(response)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/username/exp/downloader/venv/lib/python3.12/site-packages/pyigdl/igdl.py", line 42, in _parseResponse
"download_link": elem.css(".download-items__btn > a").attrib["href"]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'href'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/username/exp/downloader/venv/src/new.py", line 6, in <module>
data = IGDownloader("https://www.instagram.com/p/C-5szP6xjoC") # Single photo
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/username/exp/downloader/venv/lib/python3.12/site-packages/pyigdl/igdl.py", line 61, in IGDownloader
print(e.with_traceback())
^^^^^^^^^^^^^^^^^^
TypeError: BaseException.with_traceback() takes exactly one argument (0 given)
It seems there’s a problem specifically with handling single photo posts. Could you please take a look at this?
Thanks again for your time!
Yeah, the initial idea was never about downloading photos, but I'll try to add support for the same in a day. @amiteshore , I'll probably close this issue, and open a new one for downloading posts containing single photos.
Also, if this is something that you can share @amiteshore and @Fakhrillo , I would be excited to hear more about the use cases. Maybe just drop me an email if that works for you. And if it's a public project, I would be glad to add it to the README. Thanks.
Resolving the issue as the original query has been addressed. Creating new issue for photos download url.
Hey there, I saw your work, that's great, but I couldn't use it to download Instagram videos, instead, it's giving download links to the thumbnail only, if you can fix that part it would be very great, thanks.