[GH-ISSUE #38] [Feature Request] Automatically Add Playlists #15

Open
opened 2026-03-23 20:33:17 +00:00 by mirror · 15 comments
Owner

Originally created by @LordFransie on GitHub (Jan 27, 2024).
Original GitHub issue: https://github.com/tubearchivist/tubearchivist-plex/issues/38

I've read the documentation.

Your Feature Request

It is not.

Describe the solution you'd like

I’d like TA’s Plex Plugin to automatically create playlists

Additional context

I’m aware this is on the roadmap but is not currently in development. I am creating this ticket to act as a hub to discuss the issue. I’ve already gone through the plugin’s code and I’d like to start the development on this feature.

Your help is needed!

  • Yes, I will work on this in the next few days or weeks.
Originally created by @LordFransie on GitHub (Jan 27, 2024). Original GitHub issue: https://github.com/tubearchivist/tubearchivist-plex/issues/38 ### I've read the documentation. - [X] I have read the [current limitations](https://github.com/tubearchivist/tubearchivist-plex#limitations), and confirmed that this hasn't been requested as a [feature request](https://github.com/tubearchivist/tubearchivist-plex/issues?q=is%3Aissue) previously. ### Your Feature Request ## Is your feature request related to a problem? Please describe. It is not. ## Describe the solution you'd like I’d like TA’s Plex Plugin to automatically create playlists ## Additional context I’m aware this is on the roadmap but is not currently in development. I am creating this ticket to act as a hub to discuss the issue. I’ve already gone through the plugin’s code and I’d like to start the development on this feature. ### Your help is needed! - [X] Yes, I will work on this in the next few days or weeks.
Author
Owner

@lamusmaser commented on GitHub (Jan 27, 2024):

From my initial brain dump on this issue:
Playlists will probably become collections.
Collections should be notated whether they are plug-in created vs other (this would hopefully correct #37).
Collections that are plug-in created would then be imported/updated following the appropriate scan/ update logic.
There should be a setting to enable/ disable automatic import of playlists.

Let me know if you have specific questions and I'll try to be responsive.

<!-- gh-comment-id:1912986356 --> @lamusmaser commented on GitHub (Jan 27, 2024): From my initial brain dump on this issue: Playlists will probably become collections. Collections should be notated whether they are plug-in created vs other (this would hopefully correct #37). Collections that are plug-in created would then be imported/updated following the appropriate scan/ update logic. There should be a setting to enable/ disable automatic import of playlists. Let me know if you have specific questions and I'll try to be responsive.
Author
Owner

@lamusmaser commented on GitHub (May 14, 2024):

Have you been able to work on this at all? If not, I will look into it further as potential feature with v0.2.0. Once I have more details, I can provide my notes here.

<!-- gh-comment-id:2110979963 --> @lamusmaser commented on GitHub (May 14, 2024): Have you been able to work on this at all? If not, I will look into it further as potential feature with v0.2.0. Once I have more details, I can provide my notes here.
Author
Owner

@LordFransie commented on GitHub (Aug 14, 2024):

Okay, I have a rather janky script that just barely works

from plexapi.server import PlexServer
import requests
import os

# Replace with your Plex server's URL and API token
PLEX_SERVER_URL = ''  # Replace with your Plex server URL
PLEX_API_TOKEN = ''  # Replace with your Plex token
LIBRARY_NAME = 'TubeArchivist' # Replace with the name of your Plex TubeArchivist Library Name

# Get a list of all playlists
TUBEARCHIVIST_URL = ""
TUBEARCHISIT_API = ""

playlists = []

######
# Finds playlists that the particular youtube video is in
# ytid: the youtube video youtube_id
######
def findPlaylists(ytid):
    videoIn = []
    for video in playlists:
        if video["yt_id"] == ytid:
            videoIn.append(video["playlist_name"])
    return videoIn

########
# Parses the Plex File for the ytid
###########
def plexVideoID(filePath):
    return os.path.splitext(os.path.basename(filePath))[0]

###########
# Creates the list of Tube Archivist playlists and videos
###########
def populatePlaylists():
    headers = {"Authorization": "Token " + TUBEARCHISIT_API}
    response = requests.get(TUBEARCHIVIST_URL + "/api/playlist/", headers=headers).json()
    for item in response['data']:
        entries = item["playlist_entries"]
        for entry in entries:
            playlists.append({"playlist_name": item["playlist_name"], "yt_id": entry["youtube_id"]})

populatePlaylists()


# Connect to Plex server
plex = PlexServer(PLEX_SERVER_URL, PLEX_API_TOKEN)
# Get the library
library = plex.library.section(LIBRARY_NAME)
# Fetch all videos in the library
all_shows = library.all()
# Iterate through the videos and print their file names
for show in all_shows:
    episodes = show.episodes()

    for episode in episodes:
        print("-"*40)
        print(f'Episode Title: "{episode.title}"')
        print(f'Episode ID: "{plexVideoID(episode.media[-1].parts[-1].file)}"')
        print("Found in following playlists")
        print(findPlaylists(plexVideoID(episode.media[-1].parts[-1].file)))
        for collection in findPlaylists(plexVideoID(episode.media[-1].parts[-1].file)):
            episode.addCollection(collection)
            print(f'Added to the : "{collection}" Collection')
        print("")
<!-- gh-comment-id:2289201012 --> @LordFransie commented on GitHub (Aug 14, 2024): Okay, I have a rather janky script that just barely works ``` from plexapi.server import PlexServer import requests import os # Replace with your Plex server's URL and API token PLEX_SERVER_URL = '' # Replace with your Plex server URL PLEX_API_TOKEN = '' # Replace with your Plex token LIBRARY_NAME = 'TubeArchivist' # Replace with the name of your Plex TubeArchivist Library Name # Get a list of all playlists TUBEARCHIVIST_URL = "" TUBEARCHISIT_API = "" playlists = [] ###### # Finds playlists that the particular youtube video is in # ytid: the youtube video youtube_id ###### def findPlaylists(ytid): videoIn = [] for video in playlists: if video["yt_id"] == ytid: videoIn.append(video["playlist_name"]) return videoIn ######## # Parses the Plex File for the ytid ########### def plexVideoID(filePath): return os.path.splitext(os.path.basename(filePath))[0] ########### # Creates the list of Tube Archivist playlists and videos ########### def populatePlaylists(): headers = {"Authorization": "Token " + TUBEARCHISIT_API} response = requests.get(TUBEARCHIVIST_URL + "/api/playlist/", headers=headers).json() for item in response['data']: entries = item["playlist_entries"] for entry in entries: playlists.append({"playlist_name": item["playlist_name"], "yt_id": entry["youtube_id"]}) populatePlaylists() # Connect to Plex server plex = PlexServer(PLEX_SERVER_URL, PLEX_API_TOKEN) # Get the library library = plex.library.section(LIBRARY_NAME) # Fetch all videos in the library all_shows = library.all() # Iterate through the videos and print their file names for show in all_shows: episodes = show.episodes() for episode in episodes: print("-"*40) print(f'Episode Title: "{episode.title}"') print(f'Episode ID: "{plexVideoID(episode.media[-1].parts[-1].file)}"') print("Found in following playlists") print(findPlaylists(plexVideoID(episode.media[-1].parts[-1].file))) for collection in findPlaylists(plexVideoID(episode.media[-1].parts[-1].file)): episode.addCollection(collection) print(f'Added to the : "{collection}" Collection') print("") ```
Author
Owner

@tehniemer commented on GitHub (Sep 10, 2024):

Another option for this may be to add a playlist as a "Series" in plex, with the additional option to allow channels to be hidden if they are not subscribed in TA.

For example, I subscribe to a bunch of playlists that have content from multiple channels. All of those channels show up as individual series in my plex library with one or two videos in them, I'd rather see the subscribed playlist show up as the series and the individual channels be hidden. I'm not sure if this is possible or should have a separate feature request.

<!-- gh-comment-id:2341638498 --> @tehniemer commented on GitHub (Sep 10, 2024): Another option for this may be to add a playlist as a "Series" in plex, with the additional option to allow channels to be hidden if they are not subscribed in TA. For example, I subscribe to a bunch of playlists that have content from multiple channels. All of those channels show up as individual series in my plex library with one or two videos in them, I'd rather see the subscribed playlist show up as the series and the individual channels be hidden. I'm not sure if this is possible or should have a separate feature request.
Author
Owner

@lamusmaser commented on GitHub (Sep 10, 2024):

@tehniemer Unfortunately, this one isn't possible. Because of how the relationship has to be associated when generating the Plex reference ID, I cannot a) associate the video in two places nor b) associate it as a Series component. This is because I generate the details based on the filesystem structure as a fallback for when the metadata isn't provided, and those are only associative to Channel/Video details. YouTube Playlists by nature will have to come in as Collections since Plex Playlists are a per-account level interaction and cannot be created by other users. Collections are the only thing that I've found that perform as expected for this area, just haven't had the development time to actually generate the functionality, although @LordFransie's work does help in this arena to lower the threshold for time requirements.

<!-- gh-comment-id:2341910906 --> @lamusmaser commented on GitHub (Sep 10, 2024): @tehniemer Unfortunately, this one isn't possible. Because of how the relationship has to be associated when generating the Plex reference ID, I cannot a) associate the video in two places nor b) associate it as a Series component. This is because I generate the details based on the filesystem structure as a fallback for when the metadata isn't provided, and those are only associative to Channel/Video details. YouTube Playlists by nature will have to come in as Collections since Plex Playlists are a per-account level interaction and cannot be created by other users. Collections are the only thing that I've found that perform as expected for this area, just haven't had the development time to actually generate the functionality, although @LordFransie's work does help in this arena to lower the threshold for time requirements.
Author
Owner

@tehniemer commented on GitHub (Sep 10, 2024):

Understood, I could live with collections of individually subscribed content, playlists or channels, sounds like that's possible?

<!-- gh-comment-id:2342027463 --> @tehniemer commented on GitHub (Sep 10, 2024): Understood, I could live with collections of individually subscribed content, playlists or channels, sounds like that's possible?
Author
Owner

@tehniemer commented on GitHub (Sep 10, 2024):

Maybe some of the methodology in this project could help with collection building?

https://github.com/Kometa-Team/Kometa

<!-- gh-comment-id:2342032863 --> @tehniemer commented on GitHub (Sep 10, 2024): Maybe some of the methodology in this project could help with collection building? https://github.com/Kometa-Team/Kometa
Author
Owner

@LordFransie commented on GitHub (Sep 10, 2024):

Understood, I could live with collections of individually subscribed content, playlists or channels, sounds like that's possible?

So currently the script that I posted does this. It turns each playlist into their own collection, so they'll actually show up alongside the channels when you look at library. Then if you want an even easier time going through them you can just hit "collections" and it will just show you your playlists turned collection.

I have an updated version I need to post that handles pagination and also adds playlists as playlists since that works a bit easier for me for downloading purposes, though it does still have the shortfalls mentioned earlier where playlists don't show up for everyone else on the server.

Feel free to give it a rip, it's python3 and very easy to run.

<!-- gh-comment-id:2342055458 --> @LordFransie commented on GitHub (Sep 10, 2024): > Understood, I could live with collections of individually subscribed content, playlists or channels, sounds like that's possible? So currently the script that I posted does this. It turns each playlist into their own collection, so they'll actually show up alongside the channels when you look at library. Then if you want an even easier time going through them you can just hit "collections" and it will just show you your playlists turned collection. I have an updated version I need to post that handles pagination and also adds playlists as playlists since that works a bit easier for me for downloading purposes, though it does still have the shortfalls mentioned earlier where playlists don't show up for everyone else on the server. Feel free to give it a rip, it's python3 and very easy to run.
Author
Owner

@tehniemer commented on GitHub (Sep 11, 2024):

Does it put each subscribed channel into its own collection also? I would personally like to be able to go to one location in plex to find only my subscribed content, both channels and playlists.

This is the example of what I'm struggling with, I don't want to see all the single video channels since I'm not actually subscribed to them, but the video is part of a playlist.
image

<!-- gh-comment-id:2343374554 --> @tehniemer commented on GitHub (Sep 11, 2024): Does it put each subscribed channel into its own collection also? I would personally like to be able to go to one location in plex to find only my subscribed content, both channels and playlists. This is the example of what I'm struggling with, I don't want to see all the single video channels since I'm not actually subscribed to them, but the video is part of a playlist. ![image](https://github.com/user-attachments/assets/19785787-f331-427c-b672-56c0879c1355)
Author
Owner

@LordFransie commented on GitHub (Sep 11, 2024):

No. Channels are still their own series.

The script that I wrote asks tube archivist for a list of all the playlists
it has and then recreates those in Plex as collections.

So you can click on the “collections” button for the library and only view
those collections.

I recommend creating a test collection to see how the collection experience
works.

On Wed, Sep 11, 2024 at 7:29 AM tehniemer @.***> wrote:

Does it put each subscribed channel into its own collection also? I would
personally like to be able to go to one location in plex to find only my
subscribed content, both channels and playlists.

This is the example of what I'm struggling with, I don't want to see all
the single video channels since I'm not actually subscribed to them, but
the video is part of a playlist.
image.png (view on web)
https://github.com/user-attachments/assets/19785787-f331-427c-b672-56c0879c1355


Reply to this email directly, view it on GitHub
https://github.com/tubearchivist/tubearchivist-plex/issues/38#issuecomment-2343374554,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAEDZAGPCUDX4JR56Z4PHJTZWASSPAVCNFSM6AAAAABCNCF75KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBTGM3TINJVGQ
.
You are receiving this because you were mentioned.Message ID:
@.***>

<!-- gh-comment-id:2343380136 --> @LordFransie commented on GitHub (Sep 11, 2024): No. Channels are still their own series. The script that I wrote asks tube archivist for a list of all the playlists it has and then recreates those in Plex as collections. So you can click on the “collections” button for the library and only view those collections. I recommend creating a test collection to see how the collection experience works. On Wed, Sep 11, 2024 at 7:29 AM tehniemer ***@***.***> wrote: > Does it put each subscribed channel into its own collection also? I would > personally like to be able to go to one location in plex to find only my > subscribed content, both channels and playlists. > > This is the example of what I'm struggling with, I don't want to see all > the single video channels since I'm not actually subscribed to them, but > the video is part of a playlist. > image.png (view on web) > <https://github.com/user-attachments/assets/19785787-f331-427c-b672-56c0879c1355> > > — > Reply to this email directly, view it on GitHub > <https://github.com/tubearchivist/tubearchivist-plex/issues/38#issuecomment-2343374554>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAEDZAGPCUDX4JR56Z4PHJTZWASSPAVCNFSM6AAAAABCNCF75KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBTGM3TINJVGQ> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@strese commented on GitHub (Oct 28, 2024):

@LordFransie
I've been trying using the script but I only get a SyntaxError.

File "ta-plex-playlist.py", line 59
print(f'Episode Title: "{episode.title}"')
^
SyntaxError: invalid syntax

SOLVED: I was running the wrong Python version. It was a fubar on my part.

<!-- gh-comment-id:2442606041 --> @strese commented on GitHub (Oct 28, 2024): @LordFransie I've been trying using the script but I only get a SyntaxError. File "ta-plex-playlist.py", line 59 print(f'Episode Title: "{episode.title}"') ^ SyntaxError: invalid syntax SOLVED: I was running the wrong Python version. It was a fubar on my part.
Author
Owner

@strese commented on GitHub (Oct 31, 2024):

@LordFransie
It's me again. 😂 Everything works flawlessly and it's great. Great job, really!
I have a feature request for the script. Is it possible to have it fetch metadata from the playlists from TubeArchivist as well? Metadata like playlist thumbnail, description and such and have it populated in Plex also?

<!-- gh-comment-id:2450604174 --> @strese commented on GitHub (Oct 31, 2024): @LordFransie It's me again. 😂 Everything works flawlessly and it's great. Great job, really! I have a feature request for the script. Is it possible to have it fetch metadata from the playlists from TubeArchivist as well? Metadata like playlist thumbnail, description and such and have it populated in Plex also?
Author
Owner

@LordFransie commented on GitHub (Dec 8, 2024):

@LordFransie It's me again. 😂 Everything works flawlessly and it's great. Great job, really! I have a feature request for the script. Is it possible to have it fetch metadata from the playlists from TubeArchivist as well? Metadata like playlist thumbnail, description and such and have it populated in Plex also?

I think I can give this the old college try. Playlist thumbnails was already on my roadmap and this will help me get that moving forward.

<!-- gh-comment-id:2525896639 --> @LordFransie commented on GitHub (Dec 8, 2024): > @LordFransie It's me again. 😂 Everything works flawlessly and it's great. Great job, really! I have a feature request for the script. Is it possible to have it fetch metadata from the playlists from TubeArchivist as well? Metadata like playlist thumbnail, description and such and have it populated in Plex also? I think I can give this the old college try. Playlist thumbnails was already on my roadmap and this will help me get that moving forward.
Author
Owner

@lamusmaser commented on GitHub (Mar 11, 2025):

This is probably going to be included as part of the effort with v0.2.0 release, due to the complexity of the playlists functionality.

<!-- gh-comment-id:2714804934 --> @lamusmaser commented on GitHub (Mar 11, 2025): This is probably going to be included as part of the effort with v0.2.0 release, due to the complexity of the playlists functionality.
Author
Owner

@coltoneshaw commented on GitHub (Dec 17, 2025):

Here's a rough PR for solving this - https://github.com/tubearchivist/tubearchivist-plex/pull/112 if anyone wants to test.

<!-- gh-comment-id:3665464003 --> @coltoneshaw commented on GitHub (Dec 17, 2025): Here's a rough PR for solving this - https://github.com/tubearchivist/tubearchivist-plex/pull/112 if anyone wants to test.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tubearchivist/archived-tubearchivist-plex#15
No description provided.