BenediktAlkin / SongTaggerForSpotify

Song tagging for Spotify
MIT License
83 stars 4 forks source link

Tagger crashes upon trying to play a song #29

Closed Spruce8913 closed 7 months ago

Spruce8913 commented 8 months ago

Whenever I doubleclick a song in the tagger program, it crashes. I have tried to make it work with both Spotify for Desktop as the web player, both on my desktop as on laptop, and in all these cases the program silently crashes.

Luckily I could still generate playlists for every single tag I assigned, because I'm doubtful if this program is still maintained... Though I am a big fan of the project, I will have to move to "tagging" using playlists within Spotify.

BenediktAlkin commented 8 months ago

I unfortunately dont have the time to actively maintain the project.

It frequently occours that the Spotify API throws some new error that is not handled properly and after a few days they fix it and everything works again. So maybe this issue will resolve itself in a few days.

Spruce8913 commented 8 months ago

Thank you for the response and clarification! Okay, I will check some time later if it resolved itself.

Also, I completely understand not finding time to maintain side projects. Thank you for starting it, and making it open source!

bradzom commented 7 months ago

Thanks @BenediktAlkin for the awesome program! Was really bummed when it ceased working. Just tried it again tonight and it is back to being operational, fyi @Spruce8913.

Spruce8913 commented 7 months ago

Yesss! Thank you for letting me know!

Maflex24 commented 7 months ago

Hello! :)

I have the same problem right now. Song doesn't need to play, just when app get information what song is in actual in player, it's crashing

2024-01-21 23_17_48-

Only way to use is to has spotify player closed, but its harder to tag, without listening :)

Thanks for app! If it would no crash, will be amazing! :)

bradzom commented 7 months ago

Hey everyone,

I wanted to give you all a quick update and share a fix for the Spotify Song Tagger issue some of us have been experiencing. Apologies in advance for the long post and the less-than-conventional approach to using GitHub. I'm not a coder by trade; I'm just a curious guy who likes to tinker.

So, last time I mentioned that the program was working, it turns out I may have jumped the gun. It worked flawlessly for a few hours but then hit a snag the next day. I think I might have accidentally avoided the buggy code path, but that's just a hunch. Sorry for any confusion caused by my previous claim that the API issues were resolved.

From what I gathered, Spotify seems to have tweaked how their API sends back data for the getartist and getartists calls. Specifically, there's a followers' detail where one attribute is supposed to be a null string (as per the docs) and another an integer. It looks like they might now be coming back as floats, and that mismatch was tripping up the program every time a song loaded up.

After some trial and error, I made a change that did the trick, albeit it's not perfect. Inside TagEditor.xaml.cs, I adjusted the method private async void SetArtisGenresForCurrentlyPlayingTrack() to handle nulls better. This tweak essentially results in the genre info always being null because it triggers the error handling with every song. The side effect is that the genre display in the song tagger, which usually shows Spotify's genre tags, is now blank.

Here's the gist for anyone who's in the same boat and wants to give it a shot:

1 - Clone the code from GitHub using VisualStudio 2022. 2 - Modify the Code: Open TagEditor.xaml.cs and locate the SetArtisGenresForCurrentlyPlayingTrack method. Change the block of code to the following:


private async void SetArtisGenresForCurrentlyPlayingTrack() { if (BaseViewModel.PlayerManager.Track == null) return; var trackId = BaseViewModel.PlayerManager.TrackId;

var artistIds = BaseViewModel.PlayerManager.Track.Artists.Select(x => x.Id).ToList();
var spotifyArtists = await SpotifyOperations.GetArtists(artistIds);
var spGenres = String.Join(" / ", spotifyArtists
                  .Where(artist => artist != null && artist.Genres != null)
                  .Select(x => String.Join(", ", x.Genres)).ToList());

PlayerManager.Instance.ArtistsGenreString = spGenres;

}

**This piece of code essentially filters out the null genres and allows the app to run without encountering the float/int issue.

3 - Test the App: Use Visual Studio's debugging feature to run the app and check if the changes have fixed the issue. 4 - Recompile the Program: If the app runs without crashing, you can build the solution to create new executable files. If it works, recompile the program. (I had to bypass compiling some 'test' and 'mock' modules that were causing some namespace reference issues.) 5 - Replace the new compiled files with the old ones—don't touch the .sqlite database file to avoid data loss! 6 - Run SongTaggerForSpotify as usual and it should work without further intervention.

This isn't a polished fix, but the program now runs without crashing, which I can live with. When I started looking at this, I had hoped to be able to fully update this and follow GitHub conventions. I initially encountered an issue when loading the "Setup" solution into VisualStudio; it was marked as incompatible, and I couldn't figure out how to update the installer. I attempted to submit a pull request on GitHub to share this fix more formally, but I ran into difficulties. As such, I'm opting for this unorthodox approach to share my steps with those who might find them useful.

For anyone looking to bypass the initial steps, I've attached a zip file with the compiled files you would obtain if you followed steps 1-4. This allows you to skip right to step 5.

Good luck with the implementation, and don't hesitate to reach out if you need any clarifications on the steps mentioned. Here's hoping this helps until someone may be able to come up with a better fix or at least integrate this in a more conventional way.

Replacement SongTaggerForSpotify Files To Resolve Jan 2024 API Crashing Issues.zip

BenediktAlkin commented 7 months ago

Hi, great analysis and writeup! It's unfortunate how Spotify makes backward compatibility breaking changes.

I included your code and made a new release. It should be up shortly.