Is it possible to lazy load spotify tracks?
paraswtf opened this issue · 13 comments
Is it possible to search the track from youtube only when it has started playing. Because currently spams the searches which is really wasteful...
Wasteful how? @ParasDeshpande
It takes resources to search every video in a spotify playlist, what if the user only plays the first song from the playlist which has 200+ songs. Now you have searched 200 songs to just play one song. It could be better if you store the data from spotify and then convert it to a youtube track once the player reaches there. @HysMX
Also it is better to tell the user that the player could not find a simillar track while playing the track instead of at the start while loading all tracks.
I am not sure what you mean by this, if loading a album or playlist and a track couldn't be found it'll just skip over it.
Also it is better to tell the user that the player could not find a simillar track while playing the track instead of at the start while loading all tracks.
I am not sure what you mean by this, if loading a album or playlist and a track couldn't be found it'll just skip over it.
Also it is better to tell the user that the player could not find a simillar track while playing the track instead of at the start while loading all tracks.
Yea... that can be done, but it loads everything at the start and takes much more time and resources than just having the tracks stored as spotify tracks and then loading them once the player reaches the track and needs to load them... So if someone starts a playlist from spotify and decides to stop after the first song in the playlist, the other tracks wont be searched because the player didn't need them... Add something like a fetch() function to the spotify track which will replace the track with a youtube one for playing and fetch the track from youtube only when the player reaches the track. I guess this cannot be done with a plugin and some changes will have to be made in the erela client as well... 🤔
I'm not sure about the fetch()
function, that would require modifying Erela to add something that some users won't use. I have an idea for this but I'm not sure if it'll be good in practice, basically I would create a lazy load function in the plugin (or in Erela for a global usage) to add tracks every at a specified interval. This wouldn't work the best from a users view because others could enqueue tracks while it's still adding it messing up the playlist order. My next thought would be to allocate empty values in the array to say those elements will be filled in later, this doesn't seem like a good idea, purposefully adding empty values. Another idea would be keep the last index for the queue and add tracks at that index.
It could be better if you store the data from spotify and then convert it to a youtube track once the player reaches there.
I did just read this and that could be a possibility, again it would probably require editing Erela to add something that may not be used as much.
I'll keep looking at this though.
I've been poking around with this and I have something that is working, basically I created a UnresolvedTrack in Erela that will resolve into a Track before being played, the plugin will create a unresolved track and add that into the queue. This isn't specific to Spotify, but any source out there, if you want to add a Deezer playlist you can use their API to create UnresolvedTracks that Erela will get the YouTube version. I'll be busy today so expect this in the build branch on both repositories for testing within a day or so.
Thanks... another issue... I guess this was intentional earlier but now that you are adding UnresolvedTrack this should be fine...
Currently the spotify plugin only loads 100 tracks as you are only getting a single page... The spotify data object for playlist also has a next
property for the next page of the playlist... I think you can loop through the playlist until the next property is undefined on the last page...
I was focused on not spamming YouTube first.
It's done...close it
Is this complete?
Is this complete?
Yes, songs from Spotify plugin are resolved only when it has started playing - depends on plugin options (but default is false - resolve only when it has started playing)
Alright, then issue is closed. If you have anything further, please do open another issue request, thank you!