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

Auto Redirecting Albums for LibRedirect #33

Closed
ManeraKai opened this issue Feb 24, 2022 · 7 comments
Closed

Auto Redirecting Albums for LibRedirect #33

ManeraKai opened this issue Feb 24, 2022 · 7 comments

Comments

@ManeraKai
Copy link

ManeraKai commented Feb 24, 2022

We're working on LibRedirect for auto redirecting YT Music links to your project. I didn't success in redirecting albums.

The id on the beatbump url is just weird. I didn't find it anywhere in the YT Music url.


Albums

YT music:  https://music.youtube.com/playlist?list=OLAK5uy_mOa4i-kkW9ZA9jU2REQR1fB2ZNWhdDCv0
Beatbump: https://beatbump.ml/release?id=MPREb_3DURc4yEUtD

YT Music:  https://music.youtube.com/playlist?list=OLAK5uy_n6OHVllUZUCnlIY1m-gUaH8uqkN3Y-Ca8
Beatbump: https://beatbump.ml/release?id=MPREb_QygdC0wEoLe

Singles

YT Music:  https://music.youtube.com/playlist?list=OLAK5uy_n-9HVh3cryV2gREZM9Sc0JwEKYjjfi0dU
Beatbump: https://beatbump.ml/release?id=MPREb_evaZrV1WNdS

@snuffyDev
Copy link
Owner

I'll see what I can do to change the url formatting, I've needed to change them for a long time but haven't got around to it. I'll reply soon once I fix it

@snuffyDev
Copy link
Owner

This will be interesting. Currently the reason Beatbump uses the ID's that it does is because they're the internal ID's for the releases. YTM does use the ID's Beatbump uses, but they do a redirect like this:

https://music.youtube.com/browse/MPREb_HtX6bEyViGY
which redirects to
https://music.youtube.com/playlist?list=OLAK5uy_lseCZ03C0sqvERTr-GDpthp-ty48bqh3s

That only uses one HTTP request though, so I need to figure out what exactly happens behind the scenes with that.

As well as internal ID's, YouTube Music has "internal playlist ID's" too, so for releases that start with OLAK the internal ID would be VLOLAK. These internal playlist ID's work with Beatbump, with some slight tweaking on the backend, but the release "header" doesn't show up in the returned JSON. Got a few ideas though so I'll reply with any updates.

What I meant by release "header":
Screenshot 2022-02-27 141023

@snuffyDev
Copy link
Owner

Example of the returned JSON. There should be a "header" object in the response but there isn't. Which makes me think YTM does something weird when they redirect from /browse/MPR... to /playlist?list=....

image

If I can figure out what they're doing, then that might be the key to solving this.

@snuffyDev
Copy link
Owner

snuffyDev commented Feb 27, 2022

Okay, so here's what I've figured out.

YTM initially links to /browse/MPREb..., which redirects to the /playlist?list= URL. Only uses 1 HTTP request.

But if you go to https://music.youtube.com/playlist?list=OLAK5uy_lseCZ03C0sqvERTr-GDpthp-ty48bqh3s -- it'll change the URL to https://music.youtube.com/browse/MPREb_HtX6bEyViGY, then back to the /playlist?list=OLAK URL.

Example of what I mean:
https://user-images.githubusercontent.com/72365477/155903148-064ab146-18f0-4f15-8558-03c039632406.mp4

Here's where the link comes from in the HTML
image

I don't know what they're doing, it's weird but then again everything YTM does is weird. Is there any way, on the extension side of things, you could fetch the HTML (https://music.youtube.com/playlist?list=OLAK5uy_lseCZ03C0sqvERTr-GDpthp-ty48bqh3s) and parse out the ID?

Here's an example Codepen of what I mean. For the Codepen to work, you'll need a CORS extension or a CORS proxy since it's directly fetching the YTM page. I'd do it on the Beatbump side of things, but I'm already pushing the memory limits it seems.

The Regular Expression I used was /\\x7b\\x22browseId\\x22:\\x22(MPREb[a-zA-Z0-9_-]+)\\x22/gm

For further clarification, once you parse out the browseId, (for example: MPREb_HtX6bEyViGY), you could then redirect to Beatbump's URL https://beatbump.ml/release?id=MPREb_HtX6bEyViGY

@ManeraKai
Copy link
Author

I understood what you meant. I can make the extension fetch the id and then connect to Beatbump but this will defeat the whole purpose of the extension (to prevent connecting directly to those websites). Anyone who doesn't use the extension and just replaces YT Music url with Beatbump won't be able to do that and get their Albums on Beatbump. Some people just use https://einaregilsson.com/redirector/ rather than my extension and they won't be able to do that.

@snuffyDev
Copy link
Owner

snuffyDev commented Feb 28, 2022

image

My apologies, I was all over the place earlier. How's this (for now at least, til I can figure out something better)?

Any URLs that start as 'OLAK5...' for releases (singles/albums) would just need VL in front ?

It lacks the header info as well as OG data, which really isn't too important, but at least it would allow you guys to have it integrated and wouldn't need to worry about it

@ManeraKai
Copy link
Author

Any URLs that start as 'OLAK5...' for releases (singles/albums) would just need VL in front ?

I added that logic before for playlists. So, it's now working without even modifying my code.

It lacks the header info as well as OG data, which really isn't too important, but at least it would allow you guys to have it integrated and wouldn't need to worry about it

I see.

Thanks! Hopefully this project will get more popular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants