-
-
Notifications
You must be signed in to change notification settings - Fork 975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Instagram] Add support for user's saved collection #2769
Conversation
0161fa6
to
5e3b5da
Compare
Thanks for the PR. I seem to be unable to push any changes regarding this PR to your branch, so please apply this patch yourself: diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py
index f6f76eee..8f179113 100644
--- a/gallery_dl/extractor/instagram.py
+++ b/gallery_dl/extractor/instagram.py
@@ -526,11 +526,19 @@ class InstagramCollectionExtractor(InstagramExtractor):
"https://www.instagram.com/instagram/saved/collection_name/123456789/",
)
+ def __init__(self, match):
+ InstagramExtractor.__init__(self, match)
+ self.user, self.collection_name, self.collection_id = match.groups()
+
+ def metadata(self):
+ return {
+ "collection_id" : self.collection_id,
+ "collection_name": text.unescape(self.collection_name),
+ }
+
def posts(self):
- collection_id = self.url.split(
- "/")[-2] if self.url[-1] == "/" else self.url.split("/")[-1]
- endpoint = "/v1/feed/collection/{}/posts/".format(collection_id)
- for item in self._pagination_api(endpoint, {}):
+ endpoint = "/v1/feed/collection/{}/posts/".format(self.collection_id)
+ for item in self._pagination_api(endpoint):
yield item["media"] It simplifies the 'collection_id' retrieval and adds some useful metadata fields. You should also run |
Thank you, I applied the patch and gave you write access to the branch. |
def _pagination_api(self, endpoint, params=None): | ||
def _pagination_api(self, endpoint, params={}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should mention I changed the None
to {}
here to prevent this error when the collection has more available
[instagram][error] An unexpected error occurred: TypeError - 'NoneType' object does not support item assignment. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues .
[instagram][debug]
Traceback (most recent call last):
File "/mnt/d/REPO/PUBLIC/gallery-dl/gallery_dl/job.py", line 77, in run
for msg in extractor:
File "/mnt/d/REPO/PUBLIC/gallery-dl/gallery_dl/extractor/instagram.py", line 49, in items
for post in self.posts():
File "/mnt/d/REPO/PUBLIC/gallery-dl/gallery_dl/extractor/instagram.py", line 541, in posts
for item in self._pagination_api(endpoint):
File "/mnt/d/REPO/PUBLIC/gallery-dl/gallery_dl/extractor/instagram.py", line 408, in _pagination_api
params["max_id"] = data["next_max_id"]
TypeError: 'NoneType' object does not support item assignment
This adds support for user's saved collection medias, previously it would just download the user's entire saved medias.