Coder Social home page Coder Social logo

rnagabhyrava / plex-playlist-sync Goto Github PK

View Code? Open in Web Editor NEW
167.0 8.0 23.0 117 KB

App to recreate spotify/deezer playlists in your local plex server.

License: GNU General Public License v3.0

Python 98.18% Dockerfile 1.82%
apple-music deezer plex spotify ytmusic

plex-playlist-sync's Introduction

Plex Playlist Sync

Create spotify and deezer playlists in your plex account using tracks from your server and keeps plex playlists in sync with original playlists.

This DOES NOT download any songs from anywhere.

Features

  • From Spotify: Sync all of the given user account's public playlists to plex
  • From Deezer: Sync all of the given user account's public playlists and/or any given public playlist IDs to plex
  • --- New ---
  • Option to write missing songs as a csv
  • Option to include poster and description in playlists.

Prerequisites

Plex

To use Spotify sync

To use Deezer sync

Docker Setup

You need either docker or docker with docker-compose to run this. Docker images are available on the hub for amd64, arm64 and arm/v7 and will be auto pulled based on your platform.

Configure the parameters as needed. Plex URL and TOKEN are mandatory and either one of the Options (1,2,3) fields are required.

Docker Run

docker run -d \
  --name=playlistSync \
  -e PLEX_URL=<your local plex url> \
  -e PLEX_TOKEN=<your plex token> \
  -e WRITE_MISSING_AS_CSV=<1 or 0> # Default 0, 1 = writes missing tracks from each playlist to a csv
  -e APPEND_SERVICE_SUFFIX=<1 or 0> # Default 1, 1 = appends the service name to the playlist name
  -e ADD_PLAYLIST_POSTER=<1 or 0> # Default 1, 1 = add poster for each playlist
  -e ADD_PLAYLIST_DESCRIPTION=<1 or 0> # Default 1, 1 = add description for each playlist
  -e APPEND_INSTEAD_OF_SYNC=0 # Default 0, 1 = Sync tracks, 0 = Append only
  -e SECONDS_TO_WAIT=84000 # Seconds to wait between syncs \
  -e SPOTIFY_CLIENT_ID=<your spotify client id> # Option 1 \
  -e SPOTIFY_CLIENT_SECRET=<your spotify client secret> # Option 1 \
  -e SPOTIFY_USER_ID=<your spotify user id from the account page> # Option 1 \
  -e DEEZER_USER_ID=<your deezer user id> # Option 2 \
  -e DEEZER_PLAYLIST_ID= #<deezer playlist ids space seperated> # Option 3 \
  -v <Path where you want to write missing tracks>:/data \
  --restart unless-stopped \
  rnagabhyrava/plexplaylistsync:latest

Notes

  • Include http:// in the PLEX_URL
  • Remove comments (ex: # Optional x) before running

Docker Compose

docker-compose.yml can be configured as follows. See docker-compose-example.yml for example

version: "2.1"
services:
  playlistSync:
    image: rnagabhyrava/plexplaylistsync:latest
    container_name: playlistSync
    # optional only if you chose WRITE_MISSING_AS_CSV=1 in env
    volumes:
      - <Path where you want to write missing tracks>:/data
    environment:
      - PLEX_URL= <your local plex url>
      - PLEX_TOKEN=<your plex token>
      - WRITE_MISSING_AS_CSV=<1 or 0> # Default 0, 1 = writes missing tracks from each playlist to a csv
      - APPEND_SERVICE_SUFFIX=<1 or 0> # Default 1, 1 = appends the service name to the playlist name
      - ADD_PLAYLIST_POSTER=<1 or 0> # Default 1, 1 = add poster for each playlist
      - ADD_PLAYLIST_DESCRIPTION=<1 or 0> # Default 1, 1 = add description for each playlist
      - APPEND_INSTEAD_OF_SYNC=0 # Default 0, 1 = Sync tracks, 0 = Append only
      - SECONDS_TO_WAIT=84000
      - SPOTIFY_CLIENT_ID=<your spotify client id>
      - SPOTIFY_CLIENT_SECRET=<your spotify client secret>
      - SPOTIFY_USER_ID=<your spotify user id>
      - DEEZER_USER_ID=<your spotify user id>
      - DEEZER_PLAYLIST_ID= #<deezer playlist ids space seperated>
    restart: unless-stopped

And run with :

docker-compose up

Issues

Something's off? See room for improvement? Feel free to open an issue with as much info as possible. Cheers!

plex-playlist-sync's People

Contributors

jerixmx avatar rnagabhyrava avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

plex-playlist-sync's Issues

Bug in code. OR instead of AND

Describe the bug
I believe you used OR instead AND at this place during plex search

if (not search) or len(track.title.split("(")) > 1:
otherwise it does not make sense.

Also it would be cool to increase search limit to higher number. Some songs were not found because of big music library.

To Reproduce
Just look at the code. Does not matter if you find anything, it will try to look for shorter name (splitted by "(" character )

Expected behavior
If match is found, do not keep looking

select specific playlists to be synced

Did you search the existing issue to make sure this is not a duplicate?
yes

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
some playlists are not syncing somehow. might be that they are too big (too many songs on them) or too many playlists to sync

Describe the solution you'd like
A clear and concise description of what you want to happen.
As not all playlists are synced somehow, it would be nice to be able to select certain playlists to be synced through spotify URI (spotify:user:xxxx:playlist:xxxx). That way you would also be able to select a different user then your own who has the playlist you want.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Option to merge playlists

Did you search the existing issue to make sure this is not a duplicate?
Didn't find anything about this

Is your feature request related to a problem? Please describe.
I synchronize different playlists from deezer and spotify and I would love to be able to merge specific playlists in a new one

Describe the solution you'd like
Add a list of Deezer Ids or Spotify urls then a separator and the playlist name you want to be created that will merge the playlists defined

Describe alternatives you've considered
Soundiiz seems to have this functionnality but I'd like to stick with your app

Additional context
As Plex doesn't allow to make smart playlist based on other playlist, this feature request would make a great difference

Remastered album name shenanigans

Did you search the existing issue to make sure this is not a duplicate?
Yes. I didn't see anything

Is your feature request related to a problem? Please describe.
Syncing from Spotify to Plex works amazingly well. Kudos! There is one small rub, however. Spotify seems to have the remastered albums instead of the original album. My Plex library has original albums. Because of this, the script isn't matching the album because the album name has something like "Remastered" in the name. Examples:

Van Halen,1984 (Remastered)
Nick Cave & The Bad Seeds,Let Love In (2011 Remastered Version)
Led Zeppelin, Led Zeppelin II (1994 Remaster)
Ultramagnetic MC's, Critical Beatdown (Re-Issue)

Describe the solution you'd like
Would some sort of fuzzy matching on the album name be an option?

Describe alternatives you've considered
If I add these songs in by hand to the playlist, the next run of the script will delete and rebuild the playlist, so this doesn't work.

Additional context
N/A

m!

How does it search Plex for the song?

Hi, not sure if this is a bug or request... so put it as a request.

How does this playlist creator find the music on my plex server?

This is the first time I have used this docker.
On a recent playlist imported from Spotify, I looked at the CSV file created for the tracks not found.
On checking a few of them I do have them on my server but not in the Album Spotify has them in, mine are in Compilation albums.

So does your script look up Song Name, Artist and Album?
If so can it then search just on Song Name and Artist as a fall back to see if it is anywhere else on the Plex server?

An example from the logs:
INFO:root:retrying search for Lovefool - Radio Edit
INFO:root:search for Lovefool - Radio Edit successful

But this did not go into the playlist on Plex, but when I search for Lovefool I have the song twice, once by Just Jack (live lounge) and the other by The Cardigans

When it says successful, does that mean it was successfully added to the CSV file or the playlist?

Thanks

Publish to Docker Hub

I would like to build this into unraid,
Could you per chance publish this on Docker?

thanks for considering.

Manually added songs in existing playlist got removed after next sync

Hi,

I want to manually add songs to my Plex playlist that aren't being detected correctly by the script.

My problem is that when I start the script again after a while to update the playlists, the manually added songs disappear. Why is this happening? I tought it updates existing playlist and does not delete them if they already exists?

Could you please let me know which part of the code is responsible for this behavior, and perhaps I can make the necessary changes in my local branch.

JSON/CSV support for playlist IDS

I'd like to specify which playlists from my profile to sync rather than all public. With many public playlists having them all sync through can be problematic.

I imagine that this should be fairly easy to implement, perhaps even within the environment variables and that these playlist IDs are already coming into account as they are for the Deezer side.

All playlists follow the same url structure: https://open.spotify.com/playlist/1A2B3C...

Expanding Plex Playlist Sync to search for the missing songs in CSV in music library

Did you search the existing issue to make sure this is not a duplicate?
Yes

Is your feature request related to a problem? Please describe.
I am trying to write a python script that can search through the CSVs generated by PSS, then search for the songs in my plex library, and add them to the appropriate playlists on Plex.

Describe alternatives you've considered
I could go through and add everything individually but I figured this would be more useful in the long run.

Additional context
I have a working script linked below.

https://github.com/secretlycarl/plex-playlist-fix

Music association in the wrong way

Hello, when associating the music from a Spotify playlist to Plex, it associates it incorrectly because it seems like it only looks for the name of the song and not also the artist(s) so there may be inconsistencies with the result. Would there be a way to solve this?

Option to disable suffix

I'd like to be able to disable the service suffix (e.g., - Spotify). This way the playlists would have the same name both on Deezer or Spotify and Plex.

Spotify sync error

I follow a bunch of Spotify playlist , the playlist are public but they don't sync , I receive this error

  • Network plexplaylistspotifysync_default Created 0.0s
  • Container playlistSync Created 0.1s
    Attaching to playlistSync
    playlistSync | INFO:root:Starting playlist sync
    playlistSync | INFO:root:Starting spotify playlist sync
    playlistSync | Traceback (most recent call last):
    playlistSync | File "/app/usage.py", line 73, in
    playlistSync | track_names, poster_url = get_sp_track_names(
    playlistSync | File "/app/helper.py", line 81, in get_sp_track_names
    playlistSync | trackNames.append(track['track']['name'])
    playlistSync | TypeError: 'NoneType' object is not subscriptable

Add playlists as collections

Since playlists are by default not shared in Plex, I usually use Collections to have my users commonly benefit from a list of tracks.

It would therefore be nice to have the option to add playlists as collections.

exited with code 1

All Spotify playlist are followed and added to profile and I receive this error

exited with code 1
playlistSync | INFO:root:Starting playlist sync
playlistSync | INFO:root:Starting spotify playlist sync
playlistSync | Traceback (most recent call last):
playlistSync | File "/app/usage.py", line 73, in
playlistSync | track_names, poster_url = get_sp_track_names(
playlistSync | File "/app/helper.py", line 82, in get_sp_track_names
playlistSync | trackNames.append(track['track']['name'])
playlistSync | TypeError: 'NoneType' object is not subscriptable

Sync error, URI too large

Hey! I have recently found that my playlist was empty, so I started digging.
There seems to be size limit, looo at log @bottom.

Steps to reproduce the behavior:
Sync playlist with 3400 songs.

  1. Configuration:
  2. Spotify > Plex
  3. Playlist(s) causing the issue: Playlist - Spotify

I was not adding any songs to this playlist since first sync, and at that time, it worked. It may be because I have added more songs (files) in Plex that are going to be added by this script.

Container logs:

File "/usr/local/lib/python3.10/site-packages/plexapi/server.py", line 653, in playlist
  raise NotFound('Unable to find playlist with title "%s".' % title) from None
plexapi.exceptions.NotFound: Unable to find playlist with title "Playlist - Spotify".
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/./plex-playlist-sync/run.py", line 71, in <module>
  spotify_playlist_sync(sp, plex, userInputs)
File "/app/plex-playlist-sync/utils/spotify.py", line 105, in spotify_playlist_sync
  update_or_create_plex_playlist(plex, playlist, tracks, userInputs)
File "/app/plex-playlist-sync/utils/plex.py", line 161, in update_or_create_plex_playlist
  plex.createPlaylist(title=playlist.name, items=available_tracks)
File "/usr/local/lib/python3.10/site-packages/plexapi/server.py", line 491, in createPlaylist
  return Playlist.create(
File "/usr/local/lib/python3.10/site-packages/plexapi/playlist.py", line 417, in create
  return cls._create(server, title, items)
File "/usr/local/lib/python3.10/site-packages/plexapi/playlist.py", line 359, in _create
  data = server.query(key, method=server._session.post)[0]
File "/usr/local/lib/python3.10/site-packages/plexapi/server.py", line 706, in query
  raise BadRequest(message)
plexapi.exceptions.BadRequest: (414) request_uri_too_large; https://plex.domain.co./playlists?smart=0&title=Playlist%20-%20Spotify&type=audio&uri=server%.............%2Fcom.plexapp.plugins.library%2Flibrary%2Fmetadata%2F37222%2C38884%2C..........a lot of content..........166327 <html>
<head><title>414 Request-URI Too Large</title></head>
<body>
<center><h1>414 Request-URI Too Large</h1></center>

Wont Sync Playlist curated by other users

Describe the bug
I have a Christmas LoFi playlist saved and added to my profile so it can be seen publicly. It is not downloading this music, and it would be nice to have those there as well.

To Reproduce
Steps to reproduce the behavior:

  1. Configuration: docker, spotify, plex
  2. Playlist(s) causing the issue: https://open.spotify.com/playlist/4trQzGLmMY9csy5tshBEQa?si=eee04d97609a4240
  3. Song(s) causing the issue: n/a

Expected behavior
It pull the playlist and find the music as it would others

Screenshots
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Poster and description missing for Deezer playlists

Describe the bug
Playlists sync from Deezer profile doesn't have poster or description.

To Reproduce
Steps to reproduce the behavior:
With this docker compose

services:
  playlistSync:
    image: rnagabhyrava/plexplaylistsync:latest
    container_name: playlistSync
    # optional only if you chose WRITE_MISSING_AS_CSV=1 in env
    volumes:
      - /mnt/user/downloads/:/data
    environment:
      - PLEX_URL=http://192.168.1.30:32400
      - PLEX_TOKEN=token
      - WRITE_MISSING_AS_CSV=1 # Default 0, 1 = writes missing tracks from each playlist to a csv
      - ADD_PLAYLIST_POSTER=1 # Default 1, 1 = add poster for each playlist
      - ADD_PLAYLIST_DESCRIPTION=1 # Default 1, 1 = add description for each playlist
      - APPEND_INSTEAD_OF_SYNC=0 # Default 0, 1 = Sync tracks, 0 = Append only
      - SECONDS_TO_WAIT=84000
      - SPOTIFY_CLIENT_ID=id
      - SPOTIFY_CLIENT_SECRET=id
      - SPOTIFY_USER_ID=userid
      - DEEZER_USER_ID=userid
      - DEEZER_PLAYLIST_ID=id #<deezer playlist ids space seperated>
    restart: unless-stopped

Deezer playlists are sync but description and poster are missing

Expected behavior
Description and poster should be retrieved from deezer

[Feature Request] Add option to sync or update playlist

For daily updated playlists it could be great to have the possibility to choose between :

  • sync (local playlist will be a copy of current spotify/deezer playlist)
  • update (items in current spotify/deezer playlist will be added to existing items in local playlist)

ERROR:root:Missing Plex Authorization Variables

Every time I try to run the pulled image I get this error. Any idea how to fix it. I am not well-versed on programming.

Steps to reproduce the behavior:

  1. Configuration: Docker Desktop Windows 11. Running latest plexplaylistsync image pulled from the hub.
  2. Playlist(s) causing the issue:
  3. Song(s) causing the issue:

A clear and concise description of what you expected to happen.

Screenshots
Screenshot (65)

Additional context
Add any other context about the problem here.

Append Service Suffix always shows the service, doesn't toggle off.

Describe the bug
APPEND_SERVICE_SUFFIX always shows after the playlist name, regardless if it's a 0 or 1.

To Reproduce
Steps to reproduce the behavior:

  1. Configuration: Running in Docker on a Synology NAS, happens while using Synology UI or Portainer UI.
  2. Playlist(s) causing the issue: All
  3. Song(s) causing the issue: N/A

Expected behavior
I expect "- Spotify" to not be put at the end of the playlist name when APPEND_SERVICE_SUFFIX is set to a 0

Screenshots
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Issue with track name 'NoneType not subscriptable'

Whenever I try to run the script on this specific playlist (https://open.spotify.com/playlist/0Nq1trkWUxqlG1QjNnH5gw) it crashes with the error 'NoneType object is not subscriptable'. Since the logging isn't very robust, Ill try to spin up a dev environment tomorrow and see exactly what song is causing the issue, if you aren't able to get to it

Error is as follows:

today at 11:21:21 PMTraceback (most recent call last):
today at 11:21:21 PM  File "/app/./plex-playlist-sync/run.py", line 71, in <module>
today at 11:21:21 PM    spotify_playlist_sync(sp, plex, userInputs)
today at 11:21:21 PM  File "/app/plex-playlist-sync/utils/spotify.py", line 92, in spotify_playlist_sync
today at 11:21:21 PM    tracks = _get_sp_tracks_from_playlist(
today at 11:21:21 PM  File "/app/plex-playlist-sync/utils/spotify.py", line 74, in _get_sp_tracks_from_playlist
today at 11:21:21 PM    list(map(extract_sp_track_metadata, sp_playlist_tracks["items"]))
today at 11:21:21 PM  File "/app/plex-playlist-sync/utils/spotify.py", line 58, in extract_sp_track_metadata
today at 11:21:21 PM    title = track["track"]["name"]
today at 11:21:21 PMTypeError: 'NoneType' object is not subscriptable

An expected behavior could be to run through a playlist, and perhaps log an error of the song, instead of crashing completely.

[BUG] Syncing the wrong songs to playlist

Describe the bug
I have this bug where when syncing my Top 100 songs for 2023. It puts in songs that has the same name but completely different artist

To Reproduce
Steps to reproduce the behavior:

  1. use playlist link redacted
  2. use tool to sync
  3. For custom order track 43 Not OK by Robert Grace. I get in Plex Not Ok by Kygo

Can try this song in your playlist to test but I think there are more songs that happens to this bug happening just dont have an exhaustive list.

Expected behavior
Having Not OK by Robert Grace in Playlist. btw, I do have the song in my plex.

Screenshots
on Spotify:
image

on Plex:
image

Additional context
Add any other context about the problem here.

PlexSyncList Container Crashing Due to Spotify API Rate Limit and Error Handling Issues

Hello,

I am experiencing consistent crashes with the PlexSyncList Docker container (rnagabhyrava/plexplaylistsync:latest). The primary issue seems to be related to the handling of Spotify API requests, leading to rate limit errors (HTTP 429) and occasional 502 errors.

Environment
Docker version: [Container Manager 20.10.23-1437]
Host OS: [Synology DSM]
PlexSyncList version: Latest (rnagabhyrava/plexplaylistsync:latest)
Configuration Details
Here's the relevant part of my docker-compose.yml:

services:
  playlistSync:
    image: rnagabhyrava/plexplaylistsync:latest
    container_name: playlistSync
    volumes:
      - /volume1/data/media/missing:/data
    environment:
      - PLEX_URL=[REDACTED]
      - PLEX_TOKEN=[REDACTED]
      - WRITE_MISSING_AS_CSV=1 
      - APPEND_SERVICE_SUFFIX=1 
      - ADD_PLAYLIST_POSTER=1 
      - ADD_PLAYLIST_DESCRIPTION=1 
      - APPEND_INSTEAD_OF_SYNC=0 
      - SECONDS_TO_WAIT=84000
      - SPOTIFY_CLIENT_ID=[REDACTED]
      - SPOTIFY_CLIENT_SECRET=[REDACTED]
      - SPOTIFY_USER_ID=[REDACTED]
    restart: unless-stopped
    network_mode: synobridge 

Observed Behavior
The container consistently crashes or encounters issues during its operation.
The logs indicate errors related to Spotify's API, specifically HTTP status code 429, suggesting rate limit exceeding.
There are also mentions of "too many 502 error responses" and "max retries exceeded" errors.
Troubleshooting Steps Taken
Verified SECONDS_TO_WAIT is set to 84000 seconds (23.3 hours), which seems adequate to avoid rate limiting issues under normal circumstances.
Reviewed Docker configuration for any misconfigurations or missing settings.

Possible Causes
The application might be making multiple requests in a short period that are not governed by the SECONDS_TO_WAIT setting.
The error handling for Spotify API requests (especially for HTTP 429 and 502 errors) may not be robust, leading to crashes.

Request for Assistance
Could you please help in identifying why these errors are occurring and suggest any potential fixes or workarounds? Additionally, if there are any specific logs or further information you need, I am happy to provide them.

Thank you for your time and assistance with this issue.

not all public playlists are synced

Hi,

I love Plex Playlist Sync; it makes it so much easier to automate getting updated playlists in Plex.

However, I've encountered an issue:
All my playlists are set to public, but only a part of them is being synced. Why is that?

ERROR:root:Plex Authorization error

Describe the bug
ERROR:root:Plex Authorization error on spinning up the docker container.

To Reproduce
Steps to reproduce the behavior:

  1. Configuration:
version: "2.1"
services:
  playlistSync:
    image: rnagabhyrava/plexplaylistsync:latest
    container_name: playlistSync
    volumes:
      - /home/user/music:/data
    environment:
      - PLEX_URL=http://IP:32400
      - PLEX_TOKEN=<X-Plex-Token>
      - WRITE_MISSING_AS_CSV=1 # Default 0, 1 = writes missing tracks from each playlist to a csv
      - APPEND_SERVICE_SUFFIX=1 # Default 1, 1 = appends the service name to the playlist name
      - ADD_PLAYLIST_POSTER=1 # Default 1, 1 = add poster for each playlist
      - ADD_PLAYLIST_DESCRIPTION=1 # Default 1, 1 = add description for each playlist
      - APPEND_INSTEAD_OF_SYNC=1 # Default 0, 1 = Sync tracks, 0 = Append only
      - SECONDS_TO_WAIT=84000
      - SPOTIFY_CLIENT_ID=<client_id>
      - SPOTIFY_CLIENT_SECRET=<client_secret>
      - DEEZER_USER_ID=<spotify user id>
      - DEEZER_PLAYLIST_ID= #<deezer playlist ids space seperated>
    restart: unless-stopped
  1. Playlist(s) causing the issue:
    All

Expected behavior
Playlists from spotify are synced on plex

Screenshots
Screen Shot 2023-08-29 at 9 55 50 PM

Deezer Sync Issue

Hi,

Getting this error when running the docker container. I am just syncing my deezer playlist


INFO:root:Starting playlist sync
INFO:root:Starting Spotify playlist sync
INFO:root:Missing one or more Spotify Authorization Variables, skipping spotify sync
INFO:root:Spotify playlist sync complete
INFO:root:Starting Deezer playlist sync
Traceback (most recent call last):
  File "/app/./plex-playlist-sync/run.py", line 79, in <module>
    deezer_playlist_sync(dz, plex, userInputs)
  File "/app/plex-playlist-sync/utils/deezer.py", line 105, in deezer_playlist_sync
    playlists = _get_dz_playlists(dz, userInputs)
  File "/app/plex-playlist-sync/utils/deezer.py", line 52, in _get_dz_playlists
    dz_playlists = list(set(dz_user_playlists + dz_id_playlists))
TypeError: unsupported operand type(s) for +: 'PaginatedList' and 'list'

Links in description rendered as raw html tags

When there is a link in a Spotify playlist description, the links are rendered as raw html tags (i.e., <a href="link">text<a/>). I don't believe that Plex support links in the descriptions, so one workaround would be to strip the text from the tags and render it as pure text.

INFO:root:Failed to update poster for playlist (your playlist name here) - (Your streaming app)

Describe the bug
Images do not download. Plex is on windows and playlist is on docker (NAS)
To Reproduce
Steps to reproduce the behavior:

  1. Configuration:
  2. Playlist(s) causing the issue:
  3. Song(s) causing the issue:

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Does the script consider disabled songs on spotify?

Hi,

Sometimes songs on Spotify have become disabled after a while, but you can still see them in playlists, grayed out. If I have these songs locally, the user might forget that they even exist in the local library and just using the playlists.

So, does the script take into consideration the disabled songs on Spotify and add them to the Plex playlist if they are still available locally?

Container keeps shutting down

Describe the bug
The container keeps crashing after a few seconds. and i have no idea why

To Reproduce
Steps to reproduce the behavior:

  1. Configuration:

version: "2.1"
services:
playlistSync:
image: rnagabhyrava/plexplaylistsync:latest
container_name: playlistSync
# optional only if you chose WRITE_MISSING_AS_CSV=1 in env
volumes:
- /usr/music:/data
environment:
- PLEX_URL= redacted
- PLEX_TOKEN= redacted
- WRITE_MISSING_AS_CSV=0
- APPEND_SERVICE_SUFFIX=1
- ADD_PLAYLIST_POSTER=1
- ADD_PLAYLIST_DESCRIPTION=1
- APPEND_INSTEAD_OF_SYNC=0
- SECONDS_TO_WAIT=84000
- SPOTIFY_CLIENT_ID=redacted
- SPOTIFY_CLIENT_SECRET= redacted
- SPOTIFY_USER_ID= redacted
- DEEZER_USER_ID=
- DEEZER_PLAYLIST_ID=
restart: unless-stopped

This is from the log:

INFO:root:Starting playlist sync
INFO:root:Starting Spotify playlist sync
INFO:root:retrying search for Selvtillid og selvværd - del 1 (Meditation)
INFO:root:search for Selvtillid og selvværd - del 1 (Meditation) successful
INFO:root:retrying search for Selvtillid og selvværd - del 2 (Meditation)
INFO:root:search for Selvtillid og selvværd - del 2 (Meditation) successful
INFO:root:retrying search for Selvtillid og selvværd - del 3 (Meditation)
INFO:root:search for Selvtillid og selvværd - del 3 (Meditation) successful
INFO:root:retrying search for Indre ro (meditation)
INFO:root:search for Indre ro (meditation) successful
Traceback (most recent call last):
File "/app/./plex-playlist-sync/run.py", line 71, in
spotify_playlist_sync(sp, plex, userInputs)
File "/app/plex-playlist-sync/utils/spotify.py", line 105, in spotify_playlist_sync
update_or_create_plex_playlist(plex, playlist, tracks, userInputs)
File "/app/plex-playlist-sync/utils/plex.py", line 150, in update_or_create_plex_playlist
available_tracks, missing_tracks = _get_available_plex_tracks(plex, tracks)
File "/app/plex-playlist-sync/utils/plex.py", line 84, in _get_available_plex_tracks
None, s.artist().title.lower(), track.artist.lower()
AttributeError: 'NoneType' object has no attribute 'lower'
INFO:root:Starting playlist sync
INFO:root:Starting Spotify playlist sync
INFO:root:retrying search for Selvtillid og selvværd - del 1 (Meditation)
INFO:root:search for Selvtillid og selvværd - del 1 (Meditation) successful
INFO:root:retrying search for Selvtillid og selvværd - del 2 (Meditation)
INFO:root:search for Selvtillid og selvværd - del 2 (Meditation) successful
INFO:root:retrying search for Selvtillid og selvværd - del 3 (Meditation)
INFO:root:search for Selvtillid og selvværd - del 3 (Meditation) successful
INFO:root:retrying search for Indre ro (meditation)
INFO:root:search for Indre ro (meditation) successful
Traceback (most recent call last):
File "/app/./plex-playlist-sync/run.py", line 71, in
spotify_playlist_sync(sp, plex, userInputs)
File "/app/plex-playlist-sync/utils/spotify.py", line 105, in spotify_playlist_sync
update_or_create_plex_playlist(plex, playlist, tracks, userInputs)
File "/app/plex-playlist-sync/utils/plex.py", line 150, in update_or_create_plex_playlist
available_tracks, missing_tracks = _get_available_plex_tracks(plex, tracks)
File "/app/plex-playlist-sync/utils/plex.py", line 84, in _get_available_plex_tracks
None, s.artist().title.lower(), track.artist.lower()
AttributeError: 'NoneType' object has no attribute 'lower'

CSV files not deleted when all media exists in Plex

Description:
When all media files in a playlist exist in Plex, the associated CSV file is not deleted and the following message is displayed: "playlistSync | INFO:root:Failed to delete --csv--, likely permission issue".

Configuration
The Docker container is on Windows via docker-desktop (WSL2) with the mount being local to the computer.
The Plex server is on a separate computer running Linux Mint and the media files are on a NAS.

Steps to Reproduce:

1. Run the Docker container and observe the logs.
2. Create a playlist with media files that exist in Plex.
3. Check if the associated CSV file is deleted.
4. If the CSV file is not deleted, check if the message "playlistSync | INFO:root:Failed to delete --csv--, likely permission issue" is displayed.

Expected behavior:
When all media files in a playlist exist in Plex, the associated CSV file should be deleted automatically.

Screenshots:
image

Additional Information:
If the issue is related to my docker-compose configuration or some Windows setting, let me know.

Get list of missing songs

An additional question. Is it possible to get the list of songs that are not available in Plex (just to be aware of the difference between Spotify and Plex).
I tried to add a command to get_available_plex_tracks() (write track and artist to a .csv file, if except IndexError in line 235 and except BadRequest in line 211 ), but it seems to not pick-up all songs. Am I missing something?

Add Spotify CSV Importer

Did you search the existing issue to make sure this is not a duplicate?

Yes

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

No

Describe the solution you'd like
A clear and concise description of what you want to happen.

With CSV output of missing tracks, send this to Spotify to create a new playlist or add to existing playlist. Combine this with Lidarr Import List functionality to have a recursive loop that keeps a Spotify and Plex playlist in sync indefinitely by downloading any missing tracks. Lidarr can monitor a Spotify playlist and automatically download the album for any songs added to import to Plex.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Lidarr functionality exists in a similar project (https://github.com/maxpfandl/SpotifyPlexSync/tree/main) and CSV import exists as well (https://github.com/smtchahal/spotify-import)

Additional context
Add any other context or screenshots about the feature request here.

This could be a really cool feature!

Failing when tracks or posters no longer exists in playlists

Using docker on ubuntu server 22.04 vm

INFO:root:Starting playlist sync
INFO:root:Starting Spotify playlist sync
ERROR:root:Spotify User ID Error
Traceback (most recent call last):
  File "/app/./plex-playlist-sync/run.py", line 71, in <module>
    spotify_playlist_sync(sp, plex, userInputs)
  File "/app/plex-playlist-sync/utils/spotify.py", line 88, in spotify_playlist_sync
    tracks = _get_sp_tracks_from_playlist(
  File "/app/plex-playlist-sync/utils/spotify.py", line 64, in _get_sp_tracks_from_playlist
    tracks = list(map(extract_sp_track_metadata, sp_playlist_tracks["items"]))
  File "/app/plex-playlist-sync/utils/spotify.py", line 58, in extract_sp_track_metadata
    url = track["track"]["external_urls"]["spotify"]
KeyError: 'spotify'

works in https://github.com/bassrock/spotify-plex-playlists, but that hasn't been updated in a couple of years.

No clue what I'm looking at.

Allow user to skip poster and description

Did you search the existing issue to make sure this is not a duplicate?
Yes

Is your feature request related to a problem? Please describe.
Currently, there is no option to toggle poster and description creation. This will always replace the poster/description on next run. Which will erase any manually added poster/description by the user.

Describe the solution you'd like
Allow user to choose if they want to save or not. This can be an option in docker env variables.

Describe alternatives you've considered
N/A

Additional context
N/A

Spotify only pulls 50 playlists in its call, if you have more than that it doesn't grab them

Describe the bug
I have over 70 spotify playlists and I was looking at the calls, it looks like it only gets the last 50, we can put the call in a loop (I have a hacky fix locally but a ton of other changes too so I will try and fix this myself if nobody else does)

Something like this will get the next batch
sp_playlists = sp.user_playlists(user_id, limit=50, offset=50)
To Reproduce
Have more than 50 playlists

Expected behavior
Grabs all of the playlists (can batch them using offset)

Screenshots
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Keep getting error in middle of sync

Describe the bug
A clear and concise description of what the bug is.Traceback (most recent call last):
File "/app/./plex-playlist-sync/run.py", line 71, in
spotify_playlist_sync(sp, plex, userInputs)
File "/app/plex-playlist-sync/utils/spotify.py", line 105, in spotify_playlist_sync
update_or_create_plex_playlist(plex, playlist, tracks, userInputs)
File "/app/plex-playlist-sync/utils/plex.py", line 150, in update_or_create_plex_playlist
available_tracks, missing_tracks = _get_available_plex_tracks(plex, tracks)
File "/app/plex-playlist-sync/utils/plex.py", line 66, in _get_available_plex_tracks
search = plex.search(track.title, mediatype="track", limit=5)
File "/usr/local/lib/python3.10/site-packages/plexapi/server.py", line 740, in search
for hub in self.fetchItems(key, Hub):
File "/usr/local/lib/python3.10/site-packages/plexapi/base.py", line 267, in fetchItems
data = self._server.query(ekey, params=url_kw)
File "/usr/local/lib/python3.10/site-packages/plexapi/server.py", line 696, in query
response = method(url, headers=headers, timeout=timeout, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 578, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.1.192', port=32400): Read timed out. (read timeout=30)

To Reproduce
Steps to reproduce the behavior:

  1. Configuration:
  2. Playlist(s) causing the issue:
  3. Song(s) causing the issue:

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

Add playlist to multiple users

First of all, thanks for the amazing script. It works very well.

I have a question/ feature request. Instead of adding the playlist 'only' for one user, I would like to add it to the main user + one additional user in plex. The reason: the audio app (Plexamp) doesn't show shared playlists, but only playlists created by the user.

Would it be possible to add this feature (or you could also give me a hint here and I could try myself). Thanks in advance.

Spotify User ID Error

I'm sure I'm doing something wrong, but can't figure it out.
I have added my Spotify Client ID, Client Secret and User ID according to the Readme and Docker Setup and keep getting this error. I know for a fact that I do have playlists. My Deezer account is working fine, just Spotify.

INFO:root:Starting Spotify playlist sync
ERROR:root:Spotify User ID Error
ERROR:root:No spotify playlists found for given user

SSL self-signed certificate issue / ignore request / bug

Describe the bug
Hi,

First off i like what you are doing so thanks for that.
I currently run a remote plex server a remote host due to my homelab connection being to slow for multiple streams.
my homelab server basically does everything else (expect Plex).

Now when i run the container via HTTP to the remote host everything works and spotify playlists are imported into plex via API.
The issue starts when i change HTTP to HTTPS.

I rent the server via ultra.cc --> a known plex host but no root / admin rights on the server, i dont need it since i only run plex on there.
Since they control everything you are limited to the use of their domain --> in this case as follows:

https://cypher-direct.usbx.me:PORTNUMBER

so my configuration is pretty simple in my homelab:

playlistSync: image: rnagabhyrava/plexplaylistsync:latest container_name: playlistSync environment: - PLEX_URL= http://cypher-direct.usbx.me:PORTNUMBER - PLEX_TOKEN=PlexToken - SECONDS_TO_WAIT=21600 - SPOTIFY_CLIENT_ID=CLIENTID - SPOTIFY_CLIENT_SECRET=SECRET - SPOTIFY_USER_ID=USERID restart: unless-stopped

The above configuration works perfectly but i dont want my homelab to communicate over the internet via http.
If i then change it to https i get the following error:

`2024-01-05T13:18:19.864646939Z INFO:root:Starting playlist sync

2024-01-05T13:18:19.943271702Z WARNING:urllib3.connection:Certificate did not match expected hostname: cypher-direct.usbx.me. Certificate: {'subject': ((('commonName', '.HIDDEN.plex.direct'),),), 'issuer': ((('countryName', 'US'),), (('organizationName', "Let's Encrypt"),), (('commonName', 'R3'),)), 'version': 3, 'serialNumber': 'HIDDEN', 'notBefore': 'Dec 30 19:07:18 2023 GMT', 'notAfter': 'Mar 29 19:07:17 2024 GMT', 'subjectAltName': (('DNS', '.HIDDEN.plex.direct'),), 'OCSP': ('http://r3.o.lencr.org',), 'caIssuers': ('http://r3.i.lencr.org/',)}

2024-01-05T13:18:19.943297344Z ERROR:root:Plex Authorization error`

Could you please add a feature (flag) to ignore self-signed certificate checks

For example:
environment:

  • IGNORE_SSC=1 for yes 0 for null --> default 0

If any further information is required please dont hasitate to ask.

Spotify private playlist support

Did you search the existing issue to make sure this is not a duplicate?

Yes

Is your feature request related to a problem? Please describe.

Yes, only my public playlists listed on my profile sync.

Describe the solution you'd like

Would be nice to have the private playlists sync too, if possible. Even having public but not listed on profile playlists would be great.

Describe alternatives you've considered

I can make the playlists public, sync, and then private again, but would be nice (and kind of the goal of using this code) to have it automated.

Additional context

None, thank you for the work you've done so far! I love it, would be nice to have this feature though.

Search playlists and songs async

Did you search the existing issue to make sure this is not a duplicate?
Yes

Is your feature request related to a problem? Please describe.
It would be nice if all of the requests could be done asynchronously, instead of going in a nice order, it could go through all the playlists async, and then for each song do the request async. This would speed up the time to do the requests a lot I would assume, even with only ~20 threads running

Describe the solution you'd like
In the playlists loops spin up new threads, in the search loops spin up other threads. Even just one or the other would be really useful

Describe alternatives you've considered
None

Additional context
None

Missing playlists are not being removed when all songs become available

Describe the bug
When a playlist is missing some tracks locally, program creates csv file with missing tracks. But when all the missing tracks were added to plex and on rerun the csv file should be empty or deleted but that's not happening.

To Reproduce
Steps to reproduce the behavior:

  1. Create some playlist (with a few missing tracks and turn on write missing)
  2. Add all missing tracks manually after first run
  3. Check csv file now (should be empty or missing but no changes)

Expected behavior
csv file should be deleted if no songs were missing.

Additional context
Ref:

if missing_tracks and userInputs.write_missing_as_csv:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.