[YouTube] Make channelId resolution follow redirects and fix YoutubeStreamInfoItemLockupExtractor building incorrect handles#1347
Conversation
This is not always the case, this is the first time I see this. You can try for instance with Please update your comment in the code and your PR description :) |
Ref: TeamNewPipe#1347 (comment) Co-Authored-By: Audric V. <74829229+AudricV@users.noreply.github.com>
Done :) |
Stypox
left a comment
There was a problem hiding this comment.
Code in this PR looks good to me, and this function is only called to resolve URLs upon fetching stuff so it's not like we're going to get many more requests (it'd be bad if it was one request per info item). Thanks!
| if (webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE") | ||
| || webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL") |
There was a problem hiding this comment.
Btw this (|| &&) combination might be wrong, since clarifying parenthesis are missing. What is the intended condition here @AudricV?
There was a problem hiding this comment.
the equalsIgnoreCase should also likely be inverted for better null safety (we can also then remove the "" initialization above)
There was a problem hiding this comment.
What is the intended condition here
The intended condition is if it is a valid webpage type and a valid browse ID so:
(webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE")
|| webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL"))
&& !browseId.isEmpty()Thanks for catching this 4 year-old-bug I introduced!
There was a problem hiding this comment.
Fixed in 6397b2e. It wasn't the only place where the parenthesis was missing. getChannelResponse and resolveChannelId are quite similar and might qualify for deduplication at a later point...
There was a problem hiding this comment.
I wonder if there's any checkstyle rule for this, but I could only find one which does the opposite 😅 https://checkstyle.org/checks/coding/unnecessaryparentheses.html
| // It works like that: | ||
| // @TheDailyShow | ||
| // -> resolves to thedailyshow | ||
| // -> resolves to the id: UCwWhs_6x42TyRM4Wstoq8HA | ||
| // Please note that this is not always the case, some handles | ||
| // e.g. @google or @Gronkh directly resolve the id |
There was a problem hiding this comment.
Not really important, but I wonder whether the contrary is more common instead. If so, this comment should updated.
| if (webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE") | ||
| || webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL") |
There was a problem hiding this comment.
What is the intended condition here
The intended condition is if it is a valid webpage type and a valid browse ID so:
(webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE")
|| webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL"))
&& !browseId.isEmpty()Thanks for catching this 4 year-old-bug I introduced!
There was a problem hiding this comment.
We should probably add tests for channels without this handle -> c/ -> browseId redirection.
There was a problem hiding this comment.
added in aa70b5a. I amended the initial commit which creates the YouTubeChannelHelperTest because the other mocks were touched while recording the new ones for the class.
Ref: TeamNewPipe#1347 (comment) Co-Authored-By: Audric V. <74829229+AudricV@users.noreply.github.com>
3deef52 to
6397b2e
Compare
Ref: TeamNewPipe/NewPipeExtractor#1347 (comment) Co-Authored-By: Audric V. <74829229+AudricV@users.noreply.github.com>
Ref: TeamNewPipe#1347 (comment) Co-Authored-By: Audric V. <74829229+AudricV@users.noreply.github.com>
Ref: TeamNewPipe#1347 (comment) Co-Authored-By: Audric V. <74829229+AudricV@users.noreply.github.com>
Followup of #1344 (comment)
Fixes #1345
This fixes the following problems:
When resolving a YT handle like
@TheDailyShow, YT first returns a response withWEB_PAGE_TYPE_UNKNOWNand a redirect tothedailyshow. The redirect must then be resolved again to get the actual channel id which isUCwWhs_6x42TyRM4Wstoq8HA. However this is not always the case.YoutubeStreamInfoItemLockupExtractorincorrectly, however it was (sometimes?) resolved correctly due to the previous problem.