tnychn / mpv-discord

🎈 A cross-platform Discord Rich Presence integration for mpv with no external dependencies.
MIT License
172 stars 14 forks source link

Discord rate limits the update frequency of the presence #21

Open ghost opened 3 years ago

ghost commented 3 years ago

After a little bit, Discord starts to ratelimit the AV: line, plus it's mostly useless because of the "xx:xx left" line (which isn't rate limited due to it being set once) anyway. This also means that it won't receive events for pausing once rate limited, causing it to keep counting down even after pausing. image

Kruchji commented 2 years ago

Is there any update on this issue?

tnychn commented 2 years ago

The video progress (the AV: 00:01:19/00:51:08 row) in Rich Presence requires frequent updates to keep it real time. But I don't think there is a workaround to bypass Discord's rate limit. Perhaps a solution to this issue is to use something else rather than video progress for the text.

Any suggestions on what the text could be?

Kruchji commented 2 years ago

Would it be possible to add an option (maybe in the config) to update the video progress less frequently?

e.g. every 10 seconds, so Discord's rate limit wouldn't come into effect

tnychn commented 2 years ago

Yes, that would be a great solution. I will try to implement it when I'm free.

zeratax commented 2 years ago

I don't know much about go so I just changed https://github.com/tnychn/mpv-discord/blob/663f0e3ee1fa81c9833444d9bd8e40583e39bb29/mpv-discord/main.go#L155

to:

   for range time.Tick(10 * time.Second) {

😄

The docs state that:

This has a rate limit of 5 updates per 20 seconds. https://discord.com/developers/docs/game-sdk/activities#updateactivity

So 10 seconds should be fine.

Don't know how much value there is in making in configurable?

zeratax commented 2 years ago

Actually still gets rate limited, just later lol ^^

Kruchji commented 2 years ago

Maybe the rate needs to be even lower?

But also games like League of Legends show exact time of match so there probably is another way of doing this

ghost commented 2 years ago

It's already implemented inside of the rich presence, so the easiest way would just be to either remove the line or retool it into something more.. useful.

zeratax commented 2 years ago

yeah that's what I was thinking about too. just deprecate that line and instead of updating based on an interval, updating after an action (pause,play,change title, etc) is performed.

side note: also created an action to build the binaries and attach them to releases if a tag is pushed https://github.com/tnychn/mpv-discord/commit/5ce0105391c4b28343cedc66077a16f85b2f75fd should probably put that on it's own branch and create a pr.

mfederczuk commented 11 months ago

Throwing my hat into the ring here to say that I was even blocked by Cloudflare after around 2 hours:

My only guess is that Cloudflare thinks that it was an attempted DoS due to the amount of calls sent to the servers.
Now, while it's definitely possible that this didn't result from this integration, I've never got something like this in all my years of using Discord (even with spamming the Discord servers myself a bit) and it only appeared after starting to use this integration.

I honestly think that this is f*cking hilarious, but this is definitely a problem lmao

Reinbowsaur commented 11 months ago

Throwing my hat into the ring here to say that I was even blocked by Cloudflare after around 2 hours:

My only guess is that Cloudflare thinks that it was an attempted DoS due to the amount of calls sent to the servers. Now, while it's definitely possible that this didn't result from this integration, I've never got something like this in all my years of using Discord (even with spamming the Discord servers myself a bit) and it only appeared after starting to use this integration.

I honestly think that this is f*cking hilarious, but this is definitely a problem lmao

This was a global problem just over an hour ago, unrelated to this tool 👍

mfederczuk commented 11 months ago

This was a global problem just over an hour ago, unrelated to this tool 👍

Ah, then I apologize. 🙇🏻
Unfortunate timing for me to start using this.