meeb / tubesync

Syncs YouTube channels and playlists to a locally hosted media server
GNU Affero General Public License v3.0
1.99k stars 130 forks source link

Add sources with /user/ URL #243

Open tyronemills opened 2 years ago

tyronemills commented 2 years ago

Just found tubesync and love it! Just one small issue at the moment. There are several channels that I want to add with a /channel/ or /user/ URL, rather than the /c/ URL. I have tried using /source-add for the URLS with /channel/, but that results in a non-working URL.

E.G.: https://www.youtube.com/channel/UC69FffuTsdjqEfLeodRNgtQ/

If I manually add the source using the key, I get the following URL from tubesync:

https://www.youtube.com/c/UC69FffuTsdjqEfLeodRNgtQ/ which results in a Youtube error page.

Here is an example URL with /user/:

https://www.youtube.com/user/LyonsArcade

Is there a method to add /channel/ and/or /user/ URLS?

meeb commented 2 years ago

You need to add channels by ID using the "add channel by ID" method to add a source, that will use the correct /channel/ URI prefix.

I've been attempting to work out a sane way to add source by user, the issue with it is some /user/name URIs are channels, some are playlists, some are collections of playlists, some are random favourite videos. There isn't much consistency with what YouTube returns for a /user/name page. I could just add them in without attempting to check it, but then if you add /user/name and that user then adds a playlist from a massive channel to their page TubeSync will zoom off and download every video on the playlist which is probably not ideal or an obvious side-effect.

tyronemills commented 2 years ago

Thanks for the prompt response. I hadn't realized the distinction between /user/ and /channel/ URLs on Youtube. I can see how treating them equally could lead to unexpected and likely unwanted behaviour.

voarsh2 commented 2 years ago

I'm struggling with this myself. Trying to add https://youtube.com/user/rossmanngroup Tubesync gives https://www.youtube.com/channel/rossmanngroup - link doesn't work.

meeb commented 2 years ago

@voarsh2 yeah that's another vanity URL and not the actual channel name. The actual channel name / ID for that channel is "UCl2mFZoRqjw_ELax4Yisf6w" so pop into TubeSync:

https://www.youtube.com/channel/UCl2mFZoRqjw_ELax4Yisf6w

ThibaultNocchi commented 2 years ago

How do you find a channel URL from a user?

meeb commented 2 years ago

It's burried in the metadata, there is an issue to automate this, but for now you can use a command line tool to extract the channel ID for annoying URLs that hide the ID. Go to a channel which is a /user/whatever style page (for example https://youtube.com/user/rossmanngroup from above) and pick a random video on it, for example this one https://www.youtube.com/watch?v=87poTGAasbE which is the latest video on /user/rossmanngroup/videos.

Then pop over to your docker host where TubeSync is running and run this command:

docker exec -ti tubesync python3 /app/manage.py youtube-dl-info "https://www.youtube.com/watch?v=87poTGAasbE" | grep channel_url

Change the YouTube video URL to whatever video you want the channel ID for. This command will output, in the case of the above video:

"channel_url": "https://www.youtube.com/channel/UCl2mFZoRqjw_ELax4Yisf6w",

Which is the channel URL you can copy/paste into TubeSync.

ThibaultNocchi commented 2 years ago

Thanks! In the meantime, I've found another way. I open the web inspector on the user page and search for "externalId" and found it. Thanks !

meeb commented 2 years ago

Yep! That's exactly the same metadata, the channel ID is visible in the video page source code in some JSON as well as you've found.

tehniemer commented 2 years ago

@meeb This was really helpful; I think it would be a good idea to add the procedure to the README since this scenario can happen often.

meeb commented 2 years ago

Yeah might do, it's just such a hack (and one that doesn't work 100% of the time) I was partially leaning towards not adding it as an official suggestion.