Viperinius / jellyfin-plugin-spotify-import

Import playlists from Spotify in Jellyfin
GNU General Public License v3.0
40 stars 3 forks source link

Can not import user playlists #46

Closed formeo14 closed 3 days ago

formeo14 commented 3 days ago

Description When the scheduled task for importing Spotify playlists runs, it encounters a NullReferenceException and fails. This issue started occurring recently, and it was working without any problems before. The authorization for the Spotify API is correctly configured and enabled. My username is also right.

Configuration: User Setup: A specific user is configured to import all their Spotify playlists.

Steps to Reproduce:

  1. Trigger the scheduled task to import Spotify playlists.
  2. The task fails with a NullReferenceException.

Logs

Log Entries - [2024-11-30 11:06:08.250 +00:00] [INF] [24] Viperinius.Plugin.SpotifyImport.Spotify.SpotifyLogger: "POST" https://accounts.spotify.com/api/token [""] "System.Net.Http.FormUrlEncodedContent" - [2024-11-30 11:06:08.299 +00:00] [WRN] [24] Jellyfin.Networking.Manager.NetworkManager: "xxx.xxx.xxx.xxx": Only loopback "127.0.0.1" returned, using that as bind address. - [2024-11-30 11:06:08.789 +00:00] [INF] [30] Viperinius.Plugin.SpotifyImport.Spotify.SpotifyLogger: --> OK "application/json" "{\"access_token\":\"xxxx\",\"token_type\":\"Bearer\",\"expi" - [2024-11-30 11:06:08.805 +00:00] [INF] [30] Viperinius.Plugin.SpotifyImport.Spotify.SpotifyLogger: "GET" users/3nvv3ll7vy034sai0x72xxxxx/playlists [""] null - [2024-11-30 11:06:09.222 +00:00] [INF] [30] Viperinius.Plugin.SpotifyImport.Spotify.SpotifyLogger: --> OK "application/json" "{\"href\":\"https://api.spotify.com/v1/users/3nvv3ll7" - [2024-11-30 11:06:09.223 +00:00] [ERR] [30] Emby.Server.Implementations.ScheduledTasks.TaskManager: Error executing Scheduled Task System.NullReferenceException: Object reference not set to an instance of an object. at Viperinius.Plugin.SpotifyImport.Spotify.SpotifyPlaylistProvider.GetUserPlaylistsInfo(TargetUserConfiguration target, Nullable`1 cancellationToken) at Viperinius.Plugin.SpotifyImport.Spotify.SpotifyPlaylistProvider.GetUserPlaylistsInfo(TargetUserConfiguration target, Nullable`1 cancellationToken) at Viperinius.Plugin.SpotifyImport.GenericPlaylistProvider.GetUserPlaylistIds(TargetUserConfiguration target, Nullable`1 cancellationToken) at Viperinius.Plugin.SpotifyImport.Tasks.SpotifyImportTask.ExecuteAsync(IProgress`1 progress, CancellationToken cancellationToken) at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options) - [2024-11-30 11:06:09.236 +00:00] [INF] [30] Emby.Server.Implementations.ScheduledTasks.TaskManager: "Import Spotify playlists" Failed after 0 minute(s) and 1 seconds
Viperinius commented 3 days ago

Oh boy, Spotify changed its API again, restricting access to quite a lot of stuff (for reference: https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api and https://github.com/JohnnyCrazy/SpotifyAPI-NET/issues/1012). It seems like this also affects playlists in the sense that the API now only returns user-created playlists. "Spotify-owned" playlists like the weekly discovery or playlists for some genres are returning null, which causes the exception you are seeing...

A fix for that exception is included in the new plugin release (1.11.0.0), please try again with that version.

formeo14 commented 3 days ago

It appears to be working. It needs now a few hours to run, but the initial start was successful, so I'm hopeful. Thank you for the fast fix!

formeo14 commented 3 days ago

It works, and it was much faster, as you mentioned, because it ignores Spotify's created playlists. This is a bit disappointing, but I can manage since I can copy them to my own playlists. However, Lidarr can still grab all playlists. I'm not sure what they're doing differently there. Thanks for your help!

Viperinius commented 3 days ago

Interesting, maybe they scrape Spotify without using the API

formeo14 commented 3 days ago

I'm not sure, but I think it's unlikely because Spotify playlists are always different for each user, and I need to authenticate with Spotify, which is the same process as with Jellyfin. Here's a screenshot in German for my account: Image

Viperinius commented 3 days ago

Ah, I'll take a look if I can find out what they do

Druidblack commented 2 days ago

good afternoon. I didn't quite get it. is the plugin currently unable to update playlist data from spotify?

Playlists that were from spotify have not been updated (plugins of the latest version). It is sad. I hope the author can get around this limitation.

formeo14 commented 2 days ago

The Plugin supports all playlists except those from Spotify.

If you want to use a Spotify playlist, you'll need to convert it to your own playlist first.

I need to correct my earlier statement: Lidarr does not work with Spotify playlists either. Adding just one Spotify playlist will cause an error, and pressing another playlist will ignore the Spotify one. So, Lidarr has the same issue. I apologize for providing incorrect information.

Druidblack commented 2 days ago

It was convenient when the playlists were from spotify and they were updated periodically.

I assume that the converted playlists will be static. And they won't be updated like spotify playlists. They will need to be updated manually.

Viperinius commented 2 days ago

I assume that the converted playlists will be static. And they won't be updated like spotify playlists. They will need to be updated manually.

Correct.

For the time being this is necessary, let's hope Spotify change their mind on how much they make inaccessible or maybe I can find another way to get the data.

Viperinius commented 2 days ago

I need to correct my earlier statement: Lidarr does not work with Spotify playlists either. Adding just one Spotify playlist will cause an error, and pressing another playlist will ignore the Spotify one. So, Lidarr has the same issue. I apologize for providing incorrect information.

Ah, no problem, what a shame though that is doesn't work. There might be apps that are still working because in the Spotify announcement it seemed like some bigger apps could get at least some kind of grace period.