-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add a --likes flag (fixes #16) #17
base: master
Are you sure you want to change the base?
Conversation
Hey @ArcticZeroo, This looks great 🎉 To fix that, run $ ./node_modules/.bin/prettier -l src/*.js And push those changes, then we can merge this. |
* @returns {Promise.<Array.<T>|*>} | ||
*/ | ||
async function getSortedPlaylist(playListId, comparator = viewComparator) { | ||
try { |
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'm not sure why a try/catch
is required over here?
Because there's a try/catch
in the main function
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.
Node's async doesn't catch errors thrown by await
, they need to be explicitly thrown with throw
or explicitly caught in some way. As a result, if the YouTube API replies with an error of some kind, an error will be printed to console about an uncaught promise, but getSortedPlaylist won't actually reject the promise.
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.
Are you sure about that?? 🤔
Because I commented out the try/catch
added by you over here and explicitly threw an error in api.getVideoIdsFromPlayList and it did get caught by the catch block in main.js
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'm like 75% sure (it's definitely been an issue many times for me on other projects), I'll do some testing of my own when I'm back at my dorm
Whoops, phone misclick. Ignore that. I'll make the changes later, just left the dorm! |
This PR does a few things:
getSortedPlaylist
which allows custom comparators to be usedgetSortedPlaylist
method because async functions don't catch failures inawait
calls--likes
option to sort videos by likes (alias-l
) (fixes Provide a flag to sort videos by likes #16 )