Jump to content

Script to create Per User Recently Watched Playlists


ginjaninja

Recommended Posts

ginjaninja

Goal
Automatically manage a 'curated' recently watched episode playlist, which works on Roku, in a similar vein to Plex's recently watched ribbon.
Last time i tested smart playlist and playback reporting plugins, their recently watched playlist's content was not visible on my Roku.

 

 

Changes

v0.0.0.3 - compatibility fix for 4.6.0.X, playlists now seem to need userid not just an apikey to enumerate, userid retrieved from the log.

v0.0.0.2beta - not compatable with old csvs and a new config option is required.

New - New config option DateTimeFormat - match your Datetime format in (new) log to this option.

New - Process.ps1 is now launched automatically by the logger on the onplaybackstopped event, so no need to schedule process.ps1. Ensures the playlist is only a few seconds behind real life.

 

Playlist v0.0.0.3.zip

Playlist v0.0.0.2beta.zip

Playlist v0.0.0.1.zip

Caveats
might need latest Powershell and a relaxed Powershell execution policy.
tested on Windows but should be agnostic.
a bit alpha - learning classes, methods, constructors, functions.
issues/suggestions welcome.

5eca340ab702d_ScripterXConfig.jpg

Edited by ginjaninja
v0.0.0.3 compatibility fix
  • Like 3
Link to comment
Share on other sites

Anthony Musgrove

I'm absolutely loving these scripts you're putting together mate.  I am so so glad that this is all coming together :) 

Link to comment
Share on other sites

Spaceboy

well i'm set up. I'll check back in tomorrow after i've watched some stuff tonight and the process script runs overnight

Link to comment
Share on other sites

ginjaninja

well i'm set up. I'll check back in tomorrow after i've watched some stuff tonight and the process script runs overnight

 

interested to see how you get on

If you run into problems i would try watching some old stuff manually to create a log "Queue,csv", and run the process script manually from pwsh, so you can see the output.

 

in order for process.ps1 to register a 'watch', the id needs to have a start event on an unplayed item and a stop event with a played item in the log. so a bit of tweaking required if testing on previously "played=true" content.

Added to playlist...

"onPlaybackStart","False"

"onPlaybackStopped","True"

Not added to playlist...

"onPlaybackStart","True"

"onPlaybackStopped","True"

"DateTime","Type","ID","Name","Username","Userid","Device","EventType","Played","Processed","Valid","Matched"
"23 May 2020 15:59:21","Episode","321997","The Return","User1","6cc6d0fa039849af8147592f5da46188","Chrome","onPlaybackStart","False","No","",""
"23 May 2020 15:59:22","Episode","321997","The Return","User1","6cc6d0fa039849af8147592f5da46188","Chrome","onPlaybackStopped","True","No","",""
Edited by ginjaninja
Link to comment
Share on other sites

ginjaninja

have notice a bug, if unprocessed rows remain in queue.csv when it is processed, the date format is changed and the script failss on subsequent runs...will need to fix that, although if running in middle of night you probably wont see this issue.

need to find a way to force a date format on powershells export-csv...ie keep it the same

 

edit

have not been able to find a way to control the datetime format internally in memory or on export or really understand how this works across regional cultures and i suspect the script may fail in other cultures.... so for now  have added a datetimeformat config option, so user can match the format in their logs in their local region (logging uses the default format)..

 

e.g my logging/default datetime format is

"24/05/2020 11:29:33","Episode","322312","What's the Matter with Tony Slattery?","user1","6cc6d0fa039849af8147592f5da46188","Chrome","onPlaybackStart","False","No","",""

so i have set my datetimeformat option in config to match (case and separators matter)

DateTimeFormat="dd/MM/yyyy HH:mm:ss"

hopefully this will make it reliable.

 

updated to v0.0.0.2

Edited by ginjaninja
Link to comment
Share on other sites

  • 5 months later...
ginjaninja

updated to 0.0.0.3 compatibility fix, 4.6.0.X needs userid not just api key to enumerate playlists it seems. v0.0.0.2 was creating multiple new playlists rather than updating an existing playlist

Edited by ginjaninja
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...