-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix KeyError for video_url, and better workflow #1321
Conversation
Sorry for a lame question, but where can I put those lines to make it work? |
Attribute |
|
db521b5
to
afb4909
Compare
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.
Hi! Sorry for my late response, I have been quite busy the last few weeks.
The change looks very good, I have only inline-commented a little suggestion.
I have noticed that one of the Actions failed, fixed that, and rebased your branch on the now-current master.
if self._context.iphone_support and self._context.is_logged_in: | ||
try: | ||
version_urls.extend(version['url'] for version in self._iphone_struct['video_versions']) | ||
except (InstaloaderException, KeyError, IndexError) as err: | ||
self._context.error(f"Unable to fetch high-quality video version of {self}: {err}") | ||
return version_urls[0] | ||
else: | ||
version_urls = list(dict.fromkeys(version_urls)) |
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.
This is to remove duplicates, right? It might be a little cleaner to use a set
for version_urls
rather than a list. It does not store the order of items, so we will loose the enumeration in the warning message "Video URL candidate 1/4 for ..."; but neither does list(dict.fromkeys(...))
ensure that the order is kept. But that's okay anyway, there is probably little value in printing the index of the URL that fails.
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.
Yeah, this is to remove duplicates. I prefer this way than set
exactly because of the order preservation (even though not very important here), and IIRC since Py 3.5 dicts are ordered, so this operation will keep the order of items.
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.
Ah interesting, did not know that. Then it is fine. Thanks!
Fixes #1320.
Also improves the workflow a little bit.