daspartho / SpotiByeAds

Skip spotify ads by automatically restarting application when ad plays
GNU General Public License v3.0
284 stars 41 forks source link

Way to reduce number of requests sent #44

Closed daspartho closed 3 years ago

daspartho commented 3 years ago

There is limit on number of requests to spotify api and since the program sends one every sec so its quite easy to exhaust it in a long music session which will break the script. We can reduce that one way. Since after a restart its quite certain that there won't be any ad for some time so we can make the detection program sleep for a few min after a restart as we are certain there won't be any ad any time soon. This would somewhat reduce the number of request. What you guys think?

AnonymouX47 commented 3 years ago

Umm... To quite an extent, i think the assumption is safe. So, i'm in support.

The question now is, how many minutes?

daspartho commented 3 years ago

As for mins ig 3 will be ok as the average length of a song is about that. We can do more as its unlikely that ad will come after 1 song. But shouldn't compromise. What others think?

AnonymouX47 commented 3 years ago

I think 3 minutes is just okay.

The-Glit-ch commented 3 years ago
 time.sleep(spotify.current_user_playing_track['duration_ms']/1000) 
        #Instead of checking every second for an ad. We simply get the total length of the song and wait for that ammount of time. 
        #Now spotify returns miliseconds for song length which is weird but this can easily be fixed with some basic math.
        #We get the song duration and divide it by 1000 and we get our time in seconds

I had this code in one of my pull requests so that we dont keep pinging spotify every second. idk if it could help

AnonymouX47 commented 3 years ago

Oh, that's way much better, can you please reference the PR, can't seem to find it.

Also, i think a subtraction of about 5-10 seconds would come in handy.

The-Glit-ch commented 3 years ago

Oh, that's way much better, can you please reference the PR, can't seem to find it.

Also, i think a subtraction of about 5-10 seconds would come in handy.

It was from PR #8

AnonymouX47 commented 3 years ago

Oh, i see. You can open another PR and try to make the change specific i.e addressing just this issue alone.

The-Glit-ch commented 3 years ago

Done #45

The-Glit-ch commented 3 years ago

Had to fetch upstream ^^^