Elijas / auto-youtube-subscription-playlist-2

Script automatically adds videos to playlists from Youtube channels and/or subscriptions (Youtube Collections alternative).
MIT License
246 stars 54 forks source link

Cannot query for user RedstoneQuarry #83

Open Fabian42 opened 3 years ago

Fabian42 commented 3 years ago

I recently added "RedstoneQuarry" to the sheet for this channel: https://www.youtube.com/c/RedstoneQuarry/videos Since then, it got stuck on that entry with the debug sheet message "Cannot query for user RedstoneQuarry". When I use "UUW_OAaMdUH3fF00fh8_Koeg" instead, which is the playlist ID of their automatic "all uploads" playlist, that fails with "Cannot query for user UUW_OAaMdUH3fF00fh8_Koeg". Only the channel ID, which is "UCW_OAaMdUH3fF00fh8_Koeg" (C as second character) works, which can apparently only be obtained by saving the HTML source of the channel page and finding the »"externalId":"UCW_OAaMdUH3fF00fh8_Koeg"« element in some long JSON object (or maybe it's always the playlist ID, but with a C?). Other short channel URLs, like "slicedlime", "TheHappieCat" or "SiberianHat" work fine.

Fabian42 commented 3 years ago

The same happens for "tryashtar".

victorjzsun commented 3 years ago

It turns out the forUsername is not for shorter custom urls, it's actually for legacy YT usernames as mentioned here for channels like http://www.youtube.com/user/..... Therefore, there's no guarantees which ones will have correct results. For now, users will need to find the channel id externally before adding to the sheet instead of the "username".

JesperDramsch commented 3 years ago

I don't have a code solution for this problem, but finding the channel ID can be a tad easier.

  1. click on any of the videos on the channel
  2. click on the channel name
  3. the URL now contains the ID instead of the shortname

image

Fabian42 commented 3 years ago

That doesn't work if they have a custom URL.

victorjzsun commented 3 years ago

The only somewhat solution is mentioned here using search.list, but even that is not 100% reliable.

JesperDramsch commented 3 years ago

That doesn't work if they have a custom URL.

Odd. As seen in the screenshot that would be exactly how I get the channel ids from custom URLs, specifically the ones listed in the OP. I just read the "I had to dig into some JSON" and thought there must be an easier way. I'm on Chrome, don't know if that makes a difference.

I agree that we shouldn't over-complicate the script with something that regularly breaks to maybe 30% solve this problem when getting the channel ID by hand and putting it into the spreadsheet 100% solves the issue.

victorjzsun commented 3 years ago

I don't have a code solution for this problem, but finding the channel ID can be a tad easier.

  1. click on any of the videos on the channel
  2. click on the channel name
  3. the URL now contains the ID instead of the shortname

image

I can attest to this, it works for channels with custom urls too

JesperDramsch commented 3 years ago

I don't have a code solution for this problem, but finding the channel ID can be a tad easier.

  1. click on any of the videos on the channel
  2. click on the channel name
  3. the URL now contains the ID instead of the shortname

Maybe this can be linked to in the FAQ?

get_url_when_custom

victorjzsun commented 3 years ago

Thanks for making the gif, added it to the README with https://github.com/Elijas/auto-youtube-subscription-playlist-2/commit/0ca280edd9a81f8974040d578d58ecbb27557273.

EmiLuna commented 2 years ago

The trick to find the channel ID doesn't work anymore for me. I find another way by inspecting the elements but it doesn't work on mobile. Is there another way to find it ?

victorjzsun commented 2 years ago

Interesting that they removed it. Here are two possible solutions:

Solution 1: Search for the custom url in YT Search to get a list of channels, and then check each channel to see if the custom url matches (source: https://gist.github.com/stvar/f57e9792c3dc49fab2690247d6ee74de). This can be implemented within the spreadsheet allowing users to input custom urls too. One disadvantage is if the custom url is too popular in channel name or is not even in the channel name, this method will fail.

Solution 2: The Video api contains channel id so we can create a modal that allows a user to input a video id and get the associated channel id. This method requires more work for both developers and the user but has no failure cases.

Fabian42 commented 1 year ago

It seems like every method gives only the custom URL now. How can new entries be added to the script? I've heard mentions of something in "inspect", but where? My current example: https://www.youtube.com/@CinemaTherapyShow All the methods I've found only return that name, but it doesn't work in the script, neither with or without the @.

victorjzsun commented 1 year ago

My previous comment's two solutions still work, either search for the cannel using Search:list and then verifying the custom url using Channels:list, or by looking up a video using Videos:list and getting the channel id from the response.

I'll probably have time in the coming days to add one or both solutions to the sheet. For now, you can use the Try It! explorer on each page to run queries and get the results.

Fabian42 commented 1 year ago

That gives me error 400 when trying to log in. Good job, Google!

victorjzsun commented 1 year ago

I've added a simple function under the YouTube Controls custom menu to convert channel name to channel ID in the recent commit. It'll give you URLs to confirm that the channel found is the correct one. Please give it a try.

Fabian42 commented 1 year ago

Somehow I lost my note to look at this again, but randomly remembered it again now. I fed the function various forms of input and it worked for all of them.

Fabian42 commented 10 months ago

Just found a failure case: I had &app=desktop at the end of the input URL and the new function gave me lots of wrong channels, but not the right one.

victorjzsun commented 10 months ago

Are you putting URLs in the input? You should just be putting the channel name. What’s the input you put, for me to take a look?

Fabian42 commented 10 months ago

Interesting, it does work with most normal URLs. My example was: https://www.youtube.com/@pLOLitik/videos?app=desktop It does work without "?app=desktop".