twlite / youtube-sr

A dead-simple youtube metadata scraper
https://npmjs.com/package/youtube-sr
MIT License
115 stars 15 forks source link

Mix is always fake and doesnt include more than one song #55

Open Shiny1708 opened 1 year ago

Shiny1708 commented 1 year ago

I used the mix from #31 https://www.youtube.com/watch?v=zhl-Cs1-sG4&list=RDzhl-Cs1-sG4 to test the new mix feature as well as multiple from my own YouTube Music but i always get a fake playlist from the fallback as a result. This is the data for the link:

image
twlite commented 1 year ago

@Shiny1708 this can happen for most of the mixes because youtube mixes are generated per user and it is not available to youtube-sr. It might work if you supply your youtube cookie:

getPlaylist(url, {
  requestOptions: { headers: { cookie: '...' } }
})

when youtube-sr cant find mix information, it returns a fake playlist with one track in it.

Shiny1708 commented 1 year ago

I did some digging and from my understanding visting a private mix with a link just generates a mix based on the first video. Would it be possible to use the new generated mix? From what i can tell thats what lavaplayer does to get mixes

twlite commented 1 year ago

image

Lavaplayer seems to be using singleColumn for the result while youtube-sr is using twoColumn

image

I will see what I can do

Shiny1708 commented 1 year ago

I think detecting mixes only with the regex /(RDC|O)LAK5uy[a-zA-Z0-9-]{33}/; doesnt detect all mixes. Mixes from yt music dont necessarily have the RD part at the start. Lavaplayer uses this for mix recognition: "https://music.youtube.com/watch?v=f9awN8BCUe8&list=PLXftWo8BlN2lx5iHhkp-3Yg5aRRbe6Qme". So mixes are catergorized by the fact that they have the watch part followed by the list part and that they use music,youtube instead of youtube.com.

Shiny1708 commented 1 year ago

The youtube music mixes are not consistent across clients so the bot would have a different queue than the user but i think the ability to access the youtube music autoqueue in itself is extremly useful since its very good in finding related songs

twlite commented 1 year ago

The you link gave has playlist page too https://music.youtube.com/playlist?list=PLXftWo8BlN2lx5iHhkp-3Yg5aRRbe6Qme

image

Mixes usually dont have playlist page

The youtube music mixes are not consistent across clients

yeah I think so. I will try to wrap around innertube next time using this library https://github.com/LuanRT/YouTube.js

Shiny1708 commented 1 year ago

I just compared the mix and playlist result. From what i can tell the links to the videos are extracted from the thumbnail image links when loading playlists correct? The problem I'm facing when entering a mix url is that the tag where the queue would be located if the procedure is the same for mixes is just empty. image image

Why is this part not loaded for the yt music link? The approach to get the link via thumbnail should work with mixes as well if we get that ytmusic-app tag populated image

(I'm still new to webdev so I hope this makes some sense and im not completly missing the mark)

Shiny1708 commented 1 year ago

The you link gave has playlist page too https://music.youtube.com/playlist?list=PLXftWo8BlN2lx5iHhkp-3Yg5aRRbe6Qme

image

Mixes usually dont have playlist page

The youtube music mixes are not consistent across clients

yeah I think so. I will try to wrap around innertube next time using this library https://github.com/LuanRT/YouTube.js

You're right I didn't realize I started the mix from a playlist. Sorry