Jump to content

Playlist Rotating


GregMo

Recommended Posts

GregMo

A while back I posted some bash scripts that could be used to rotate a playlist.  Those scripts are very crude compared to their current versions so I thought I would post an update.  I'm posting this in General because it works with any server type, and could be run from any POSIX install (cygwin maybe?) that supports bash and jq.  Anyways, from the README I wrote on it:

 

Quote

Have you ever gotten tired of binging on a show and wanted some ordered watching of shows?  This set of scripts is my answer to that issue.  It's a work in progess so don't expect fancy bells and whistles but it does get the job done for the most part.

What it does exactly is to read a playlist and identify the last item of the list.  It then searches the list for a previous episode of the same show to see what different show has followed it prior in the list.  If it finds a previous episode match, it will then add the next episode of the next show to the end of the list.  If it does not find a previous episode, it will start with the beginning of the playlist.  As an example, you could create a list with Friends 1x1, Scrubs 1x1, and Fraiser 1x1, and this script will add Friends 1x2 to the end of the list, to allow you to watch several shows in a rotating schedule like you would do if it was a network schedule.

As I mentioned above, it's not perfect as it fails when there are episodes that have multiple versions, at the end of a series, and other such anomalies, but for the most part it works great.  

To get this running you will likely have to first install the `jq' package.  The script relies on this package to be able to parse the JOSN responses from the Emby server.

That is all that is needed to run the scripts, but if you want a handy (but not pretty) HTML interface you can run a mini php server with something like `php -S 192.168.1.30:8080' and it'll run the scripts without you having to access a shell.

Before running this, you will need to set 4 variables in the embypl.dat file which are Host, UserId, EmbyXToken, and PlaylistItemNum.  Host is naturally the IP address of the server.  To get your UserID, in Emby, go to settings/Users/<your user name>.  You will see the UserID in the URL.  The PlaylistItemNum is found in similar fashion.  From the home screen click into your playlists, and then the playlist you want to rotate and the ID will be in the URL. For the EmbyXToken you have to create an API key in Emby.  This is done in settings/Api Keys.  Click on add new key and type in any random name you want here.  It will then generate a key that you copy into the file.

Of course, before you get the playlist ID you'll need to go into Emby and create a playlist to start with.

Once everything is properly set up, the following command will delete episodes you have already watched.

./delete_played.sh --commit

If you're not sure you want it to delete them, you can run it without the "--commit" option and it will just list the files that would have been deleted.

To add files to the list, you use the add_schedule.sh script.  This adds one item to the playlist.

To make it easier, I use the `doit' script to run both of the above scripts.  Also, say you are rotating 6 shows, you can set "rotate_cnt" in embypl.dat and `doit' will add the number of shows you speficify.

Future plans:  At some point I want to make changing between playlists and even different servers more efficient.  I also want to dress up the HTML more down the line.

 

list_rotate.rar

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...