I think the Topic explains about everything ;)
I think the Topic explains about everything ;)
If Plex doesn't implement this, I'm working on a work-around you might be interested in.
Hi Moviefan,
good idea to get going - i checked your files, problem is my box runs on Debian Linux ;)
I also tried the sqllite DB, but there is no table "playlists", so i am really curious where plex stores my playlist i created for testing.... if i could find where it is, i would just hack together a shell script which adds any new files in a folder to the designated playlist. If folder has no playlist, just create it - as simple as that and my problems/feature request is solved for now.
So if you could tell me where to find the playlist, this would also be very helpful....
Thanks in advance!
Phil
I’m away from my computer so i don’t have the exact madness but playlists are a combination of 3 tables. Metadata_items which hold the name, (something)_generated is the actual list, and (something)_accounts is what shows on the webapp.
Thanks a lot - that helped ;)
To select all entries of a playlist you would use:
select pqg.playlist_id , pqg.id , mi.title , mi.original_title , d.path , mp.file from play_queue_generators pqg join metadata_items mi on mi.id = pqg.metadata_item_id join media_items m on m.metadata_item_id = mi.id join media_parts mp on mp.media_item_id = m.id join directories d on mp.directory_id = d.id where pqg.playlist_id = 112764 -- check for playlist id in table play_queue_generators
the playlist_id is created from sqlite_seqence table "metadata_item_id" id is autoincrement
To get a new playlist_id you need to insert into metadata_items with "metadata_type=15" (playlist), title = playlist title, title_sort = title...
but i am not sure how to create the required "guid" field content like "com.plexapp.agents.none://e74013fa-491b-4ba2-8e2b-af12266308b0"
That is based on an algorithm that uses the timestamp. I found that plex doesn't really use it that i can tell so i just put the string up to the //. You also need the created at and updated at values. Those are required values.
Edit: You don't need the directories table. Just use the file column in media_parts. It is not so easy to just create a new playlist. The database doesn't support referential integrity so you have to manually add the entries into each table. I actually start by creating the playlist entry in metadata_items, then lookup the newly created id to create the entry in metadata_item_accounts, then create all the entries for each playlist item in play_queue_generators including the metadata_item_id field from the previous step and increment the order field, then I go back to the metadata_items table and update the media_item_count, although it doesn't look like Plex uses this. At least the WebApp doesn't. Maybe once playlsits are supported on other clients, this will have an effect. Mine script is also a little more complicated in that I need to check if the file I want to include in the playlist actually exists within the database.
Good luck on your efforts.
root@openmediavault:~/plex# php plexPlaylist.phpPlease use this script with the following commands:
Welcome!php plexPlaxlist.php
The playlist name is shown in the different Plex Apps, you can rename it later via Plex-Web-App.
All Chars except letters, numbers, space or - will be removed!The folder is relative to your music library, i.e. if you have a folder called Jazz located in
/media/123123/music/Jazz then just enter Jazz as folder name. The folder needs to be known by Plex!The database-location is the absolute path to the file com.plexapp.plugins.library.db - no trailing slash!
root@openmediavault:~/plex# php plexPlaylist.php "Playlist 2014-08" 2014-08 /media/2c663779-17fc-4ecf-8acc-432adafaf229/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/DatabasesResult:
Connecting to Plex-DB…
Folder contains 218 items.
…Playlist created.
Thanks for using my Script - Cheers Ph1975
root@openmediavault:~/plex# php plexPlaylist.php "Playlist 2014-03" 2014-03 /media/2c663779-17fc-4ecf-8acc-432adafaf229/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases Making backup of database...Connecting to Plex-DB... Error: Given folder was not found in Plex-DB
see the attached screenshot for success!
Nice work. Only comment is regarding the order field. That field has a 7 digit precision so it maxes out at 9,999,000 (9,999 songs in the playlist). Not sure why Plex uses multiples of 1,000. I got rid of the extra zeros so my list allows 9,999,999 songs to be included. I could have just gotten rid of 1 or 2 zeros, but I figured why allow any limit.
Thanks - the 1000 steps could be sort of space for later user-based reshuffling... even though it is not the nicest approach ;)
Yeah. It is just easier to resort the entire list.
Early 2021 clean-up: duplicate