Closed shiioo closed 3 years ago
Hey, I'm aware of this issue. I believe it's because the script works by connecting -> setting your status -> immediately disconnecting. When the DiscordNP client times out a couple minutes later the status resets.
One solution would be to have the discordnp client stay connected all the time, except then this breaks mobile notifications when you're not around because you have an active client.
There is a long and somewhat complicated answer, but the short version is: I know how to fix it, but it requires me to finish a significant upgrade to the Mojo::Discord library before I can implement it. At this point I don't know if I'm ever going to get around to it. Sorry.
That's ok, just willing to make sure it wasn't something on my side =)
Can you at least enable intervals longer than 2 minutes so that we can get around this?
Hi, I have a fix for that issue. It relies on the fact that the Last.FM API indicates whether the last song in getRecentSongs is currently scrobbling or not.
So I've changed the code of Mojo::WebService::LastFM to get that property:
my $nowplaying = (defined $track->{'@attr'}{'nowplaying'} and $track->{'@attr'}{'nowplaying'} eq 'true') ? 'true' : 'false';
and I've added that value to the object returned by the nowplaying
sub.
Then in discordnp.pl
, I've made some slight changes to the update_status
sub.
First I've removed the format string from the $lastfm->nowplaying
call, so I get the full object.
Then instead of testing if $np eq $last_played
before updating the Discord status, I just check if $nowplaying->{'nowplaying'} eq 'true'
.
This way, the Discord status is always updated if a song is being currently scrobbled and it doesn't clear itself. But when no song is played, the Discord status is not updated anymore and it eventually clears itself.
Hi, I have a fix for that issue. It relies on the fact that the Last.FM API indicates whether the last song in getRecentSongs is currently scrobbling or not.
So I've changed the code of Mojo::WebService::LastFM to get that property:
my $nowplaying = (defined $track->{'@attr'}{'nowplaying'} and $track->{'@attr'}{'nowplaying'} eq 'true') ? 'true' : 'false';
and I've added that value to the object returned by thenowplaying
sub.Then in
discordnp.pl
, I've made some slight changes to theupdate_status
sub. First I've removed the format string from the$lastfm->nowplaying
call, so I get the full object.Then instead of testing if
$np eq $last_played
before updating the Discord status, I just check if$nowplaying->{'nowplaying'} eq 'true'
.This way, the Discord status is always updated if a song is being currently scrobbled and it doesn't clear itself. But when no song is played, the Discord status is not updated anymore and it eventually clears itself.
Would you be able to upload your version?
Would you be able to upload your version?
Sorry for the long wait. I've forked the code and committed my changes there: https://github.com/AurelienNoyer/Mojo-WebService-LastFM https://github.com/AurelienNoyer/Discord-NP
This shouldn't be a problem anymore, the app will update status as long as the song is still playing.
I'm trying your app and I'm having an "issue" with it. After something like one minute, Discord's status clears itself even though the song is still being played. If the song changes, the status reappears, but will again disappear after the same amount of time.
Is there a way around this (aka keeping the song being played until it's actually over)?