simon-weber / Autoplaylists-for-Google-Music

Adds autoplaylists, aka iTunes "smart playlists", to Google Music.
https://autoplaylists.simon.codes
MIT License
94 stars 18 forks source link

New Random Seed Every Sync #184

Closed Noggog closed 6 years ago

Noggog commented 6 years ago

Heya Simon. Hope you're doing well.

I feel like the random seed that powers the random selection of songs sometimes gets "stuck".

For example, just now I made a new test playlist with just 100 random songs, no other rules. Some results: 1) Coincidentally, right off the bat, the songs it chose were near exact to my other playlist I actually use with similar rules that also just filters out recently played. Seems like all playlists share the same seed. 2) Reopening Google Play Tab and resyncing produced the same results, despite the instructions saying this should reset the seed. 3) I right clicked Chrome in windows and exited. Reopened and resynced. Same results

I do see different songs every so often, so I'm not sure what the the triggering difference is that makes it select a new seed. Maybe a computer restart does the trick, so when I don't it stays the same?

Either way, if it's not a large tweak, I feel like it would be really nice to select a new seed every sync a bit more reliably? Is there a fundamental reason it reuses the seed so much?

Thanks!

simon-weber commented 6 years ago

Heyo!

Seems like all playlists share the same seed.

Yup, that's how it works currently. Behind the scenes there's a random number associated with each song, and sorting by random just sorts by this field. Reseeding involves assigning a new random number to each track.

Reopening Google Play Tab and resyncing produced the same results, despite the instructions saying this should reset the seed.

Hm. This worked as expected when I tried it just now, but I can dig into it a bit more. It might have been that Google was slow to reflect the new ordering. All of refreshing the tab, closing and reopening the tab, and restarting Chrome is expected to change it.

Is there a fundamental reason it reuses the seed so much?

Unfortunately, yes. The key piece is that load on Google seems proportionate to the number of adds+deletes+reorderings requested, and too much load quickly makes playlists unusable. Since switching the random ordering often generates the worst case - either a) delete all songs + add all songs, or b) reorder all songs - it's something that can't be done too often.

What do you think about making this explicit and putting it in the ui? I could pretty easily show the date the seed was last changed, as well as a button to manually switch it (without necessarily syncing right away).

Noggog commented 6 years ago

Yeah, the excessive modification issue makes sense to want to avoid.

A display + button for the seed would work just fine for me. That would also at least help with testing if the seed is being changed properly when doing refreshes/restarts/whatever.

simon-weber commented 6 years ago

Sounds good; that should be pretty straightforward. I'll let you know when I get to it.

Thanks for bringing it up!

simon-weber commented 6 years ago

I see what's going on. I was half right: refreshing the tab allows the random field to change the next time tracks are updated. I'll need to change it to update all the existing tracks too.

Resetting the extension and restarting chrome do work as expected.

simon-weber commented 6 years ago

I'm going to wait to release this until I add the UI + reset button.

simon-weber commented 6 years ago

Planning to release this tomorrow! Took an extra weekend since I needed to also start storing information about past syncs.

simon-weber commented 6 years ago

Released in 5.9.0.