Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
data
is not guaranteed to contain amin_position
key (#544 (comment)), so either check withdata.get("min_position") is None
or("min_position" in data and data["min_position"] is None)
, depending on whether there is a difference betweenmin_position
is set andNone
andmin_position
is not set.(
is
is also preferred over==
when testing forNone
)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 didn't know that, whoops. The fix ended up being a bit more complicated then I thought. There is 6 possible responses from Twitter:
gallery-dl should continue:
{"has_more_items":True}
(This happens on the first page){"has_more_items":True, "min_position":"123..."}
{"has_more_items":False, "min_position":"123..."}
gallery-dl should stop:
{"has_more_items":False}
{"has_more_items":False, "min_position":None}
{"has_more_items":True, "min_position":None}
Basically we want to stop whenever
min_position
is None or doesn't exist, except when there is more items andmin_position
doesn't exist.