Skip to content
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

Migrate channel related functionality to YouTube.js #3143

Merged
merged 18 commits into from Mar 1, 2023

Conversation

absidue
Copy link
Member

@absidue absidue commented Jan 31, 2023

Migrate channel related functionality to YouTube.js

Pull Request Type

  • Feature Implementation
  • Bug fixes
  • Other - Refactor

Related issue

closes #1359 (only local API as Invidious doesn't provide them)
closes #1357
closes #2901
closes #2851
closes #2887
closes #2805

Description

This pull request migrates the subscriptions and channels functionality to YouTube.js.
It adds support for channel handles, channel stats, channel tags (local API only), age restricted (local API only) and special auto generated channels (local API only).
It also fixes issues with fetching more videos and sorting on channels with both the local and Invidious APIs.

Channel handles are supported in two ways, as URLs https://youtube.com/@linustechtips or by themself @linustechtips.

Channel tags are shown in a list on the about tab of channels, as in NewPipe, clicking on them searches for that keyword. They are implemented as router-links so opening them in a new window is possible too (middle click, ctrl + click, context menu entry). If the hide search bar parental control setting is enabled, the tags are just displayed as spans and don't do any searching.

YouTube's auto generated topic and gaming channels have a different layout to normal channels and need to be treated differently, this PR doesn't add support for showing any content on them yet, it only makes sure that they load without errors and that the about tab is populated with the available information (the @gaming channel doesn't have anything that we can currently display on the about page).

Screenshots

Channel handle:
handle

Details and tags:
details-tags

Non-existent channel:
non-existent

Testing

LinusTechTips URL with handle: https://youtube.com/@linustechtips
LinusTechTips handle: @linustechtips
Invalid handle (LTT with typo) @linustehctips
Terminated channel: https://youtube.com/channel/UC59AcfHD5jOGqTxb-zAsahw
Channel with playlist categories: https://youtube.com/channel/UCez-2shYlHQY3LfILBuDYqQ
YouTube gaming: https://youtube.com/@gaming
Minecraft - Topic: https://www.youtube.com/channel/UCQvWX73GQygcwXOTSf_VDVg
Age restricted channel: https://www.youtube.com/channel/UCbfnHqxXs_K3kvaH-WlNlig

Refresh your subscriptions, I currently haven't changed the 150 limit before switching to RSS, as I don't have anywhere near enough subscriptions to hit ratelimits (it now makes 2 requests per channel instead of 1), so if you have lots of subscriptions please try this, although I highly recommend using a VPN to test this, so that if you do get ratelimited, you can change to a different location to get away from it.

Backup your subscriptions first
afterwards:
Export your subscriptions as OPML
Remove all subscriptions and profiles
Import your OPML export

Desktop

  • OS: Windows
  • OS Version: 10
  • FreeTube version: 0.18.0

@github-actions github-actions bot added PR: dependencies Pull requests that update a dependency file PR: waiting for review For PRs that are complete, tested, and ready for review labels Jan 31, 2023
@absidue absidue removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Jan 31, 2023
@ChunkyProgrammer
Copy link
Member

ChunkyProgrammer commented Feb 1, 2023

Adding support for https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ should be fairly easy (the header is formatted differently) and I think it'd be a good idea to support it (we only need to worry about the about page)

Edit: this channel does not work previous to this PR so adding support in this PR is not necessary

@absidue
Copy link
Member Author

absidue commented Feb 2, 2023

You should now be able to view that channel as well as other special auto generated ones like:
https://youtube.com/@gaming and https://www.youtube.com/channel/UCQvWX73GQygcwXOTSf_VDVg
You'll need to build YouTube.js from source again with the latest changes on it's main branch for this to work.

@absidue absidue mentioned this pull request Feb 8, 2023
4 tasks
@ChunkyProgrammer
Copy link
Member

ChunkyProgrammer commented Feb 15, 2023

Just wanted to add this as a potential test channel (age restricted channel for a whiskey distillery) https://www.youtube.com/channel/UCbfnHqxXs_K3kvaH-WlNlig

We dont need this channel to work but it'd be nice to know whether it works or not

@absidue
Copy link
Member Author

absidue commented Feb 16, 2023

ooh interesting so it looks like the channel page itself is age restricted but the all uploads playlist isn't (replace the first two characters in a channel URL with UU and use it as a playlist id)
https://www.youtube.com/playlist?list=UUbfnHqxXs_K3kvaH-WlNlig

@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@absidue absidue marked this pull request as ready for review February 17, 2023 16:52
@PikachuEXE
Copy link
Collaborator

I only have 123 channels subscribed, no rate limit hit with VPN enabled... with RSS
No rate limit hit without RSS too

@absidue
Copy link
Member Author

absidue commented Feb 24, 2023

That's great to hear, looks like we don't need to adjust the limits then, yay!

@ChunkyProgrammer
Copy link
Member

That's great to hear, looks like we don't need to adjust the limits then, yay!

Iirc one of the invidious team members mentioned that innertube doesnt get rate limited as often

Copy link
Member

@efb4f5ff-1298-471a-8973-3d47447115dc efb4f5ff-1298-471a-8973-3d47447115dc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    • Channel Handles
    • Terminated channel
    • Channel with playlist categories
    • Gaming
    • Minecraft Topic
    • Age restricted channel
    • Rate limited
    • OPML
    • Something i noticed

Results:

  1. Works as intended. Can click on a tag and searches it. Also click + enter works to open in new tab. Disable search bar disables ability to interact with tags.
  2. On local API: Shows Joined, Viewed and Location. On Invidious API: Shows Joined and Viewed. Is this intended behavior?
  3. Works with both API's.
  4. Doesn't happen anymore with both API's but i noticed that invidious fetches way more videos than local API. This wasn't the case before.
  5. User reported 2 issues in this one. 3 and 6 covers this issue so i wont be testing this one.
  6. Sorting works as intended on local API but not on invidious. Is this intended behavior?
  7. Channel handles works with both inputs on both API's. Invalid handle shows channel does not exists.
  8. Works for both API but i found some things i would like to address. On the invidious API it shows a toast with exactly the same info that is being displayed on the channel page. This toast message isn't shown on the local API. Why is this? Also when testing this and switching between API's i sometimes first got to see this channel doesn't exists and after hitting enter in the search bar a few times it would show me the correct message. I think i also saw this behavior on 7 a few times but i might be wrong.
  9. Works but same behavior as 6. Also with the local API i noticed an error popping up on the about page.
    duplicate-keys
  10. Works as intended only with local API
  11. Same as 10.
  12. Error dump on invidious API. On local API i just shows a nice message that the contents of the channel cannot be viewed.
  13. Tested by @PikachuEXE
  14. Works.
  15. Last thing i want to address is that sometimes when u go to a channel it briefly shows the message that the channel doesn't have videos uploaded to it and after that load the videos.

Edit: Updated list based on new commits

Note to self: u didnt test searching within the channel

@absidue
Copy link
Member Author

absidue commented Feb 26, 2023

I've fixed the bugs in 6 and 9.

  • 2. Unfortunately Invidious doesn't return the channel location in the API response, so yes that is unfortunately expected. (we can add support for it in the future if it gets added to their API response in the future)
  • 4. I switched to the videos endpoint for Invidious so that getting more videos would work properly, as I understand it Invidious doesn't just proxy the videos list from YouTube, instead they get it from their database, so them having more I guess depends on how many they extract from their database per request.
  • 8. the delay is because it resolves the handle and channel urls when you click enter and then sends you to the channel page afterwards, so doing it multiple times was not what made it work, it just took a while. The reason why I went with this approach, is that I originally did the resolving code purely for the local API and on my machine the resolving with the local API is so fast, that it's barely noticable but now that we have it for Invidious too (which is a lot slower) also for the resolving the original URL that was passed in is needed as we need to resolve handles and urls with usernames in them /user/{username} and /c/{username} to get their channel IDs. Doing it there seemed like the most logical place because it has access to the original URL that the user entered and it also means that the channel page only ever receives real channel IDs or @@@ for channels that don't exist.
    I should probably move that resolving to the channel page and pass the original URL to the channel page, that way you'll also see the loading symbol while it's loading instead of it looking like nothing is happening. Will be messier on the code level but should be more user friendly.
  • 12. expected as Invidious doesn't support age restricted channels (updated the pull request description now as I forgot to mention it there), we should probably make it clear to the user that the error came from Invidious and not from inside FreeTube.
  • 15. The content for the videos and playlists tabs is fetched at the same time, both of them hide the loading icon for the tabs and their content, so what is probably happening is that the playlists one finishes slightly before the videos one does, so when it hides the loading icon the content for the videos tab hasn't finished loading yet
    the fix is to implement lazy loading for the tabs, so it only loads the content when you select it for the first time but that is out of scope for this pull request

@efb4f5ff-1298-471a-8973-3d47447115dc

Updated the list. Did not check 8, 12 and 15.

Do you want to address 8 and 12 in this PR?
Should i create an issue for 15?

@absidue
Copy link
Member Author

absidue commented Feb 26, 2023

Can probably do 8 inside this PR and issue for 15 might be good.

@absidue
Copy link
Member Author

absidue commented Feb 28, 2023

@efb4f5ff-1298-471a-8973-3d47447115dc 8 should be fixed now

@efb4f5ff-1298-471a-8973-3d47447115dc

@absidue Everything from the list works.

I forgot to test searching within the channel, so i did it just now and does work for local api but not invidious api is that expected?

IRC message

Copy link
Member

@efb4f5ff-1298-471a-8973-3d47447115dc efb4f5ff-1298-471a-8973-3d47447115dc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U also might want to address this

@absidue
Copy link
Member Author

absidue commented Feb 28, 2023

Looks like the search is broken on Invidious' side: iv-org/invidious#3594 (comment)

@FreeTubeBot FreeTubeBot merged commit 291aeff into FreeTubeApp:development Mar 1, 2023
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Mar 1, 2023
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Mar 1, 2023
* development:
  Fix video throttling because of range header (FreeTubeApp#3234)
  Translated using Weblate (Greek)
  Migrate channel related functionality to YouTube.js (FreeTubeApp#3143)
  Differentiate links in readme.md (FreeTubeApp#3224)
@absidue absidue deleted the channels-youtubejs branch March 1, 2023 05:52
@Kazcade
Copy link

Kazcade commented Mar 2, 2023

Might be a bit late, but I can confirm that this does indeed fix #2901 , thank you for the feature migration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: dependencies Pull requests that update a dependency file
Projects
None yet
6 participants