[SOLVED]Display watching/recording in conky for plex

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
b2a8r1

[SOLVED]Display watching/recording in conky for plex

Post by b2a8r1 »

For anyone with better knowledge of conky i have the basics worked out but need help cleaning it up. The recording information is listed in the activities area.This is displayed in terminal, what I would like to show is the show name and progress but cleanly.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="1">
<Activity uuid="bfc2e9f3-70dd-40ce-b651-e89930bc9adf" type="grabber.grab" cancellable="1" userID="1" title="Recording" subtitle="Tennis - Third Round" progress="30">
<Context deviceID="1" itemKey="/tv.plex.providers.epg.onconnect:4/metadata/com%2Egracenote%2Eonconnect%3A%2F%2Fepisode%2FEP029126510003" itemMediaIndex="0" subscriptionID="6" />
</Activity>
</MediaContainer>
These 2 lines show if there are any shows being watched and or recorded I have a wintv-quad-hd and it will show a 4 if all tuners are working.

Code: Select all

Watching  ${execi 2 curl -sH "X-Plex-Token:yourtokenhere" http://127.0.0.1:32400/status/sessions | grep "size" | cut -f2 -d'"'}

Code: Select all

Recording ${execi 2 curl -sH "X-Plex-Token:yourtokenhere" http://127.0.0.1:32400/activities | grep "size" | cut -f2 -d'"'}
This next line are where I need the cleanup.Also note if 2 or more tuners are being use every 3rd line has this info so `sed -n '3p' '6p' etc.

Code: Select all

${execi 2 curl -sH "X-Plex-Token:yourtokenhere" http://127.0.0.1:32400/activities | sed -n '3p'|cut -c 130- }
this line shows as this

Code: Select all

Tennis - Third Round" progress="39">
I would like to remove the "" and the word progress=


here is a screenshot of what is showing so far.
Screenshot from 2018-06-02 13-22-49.png
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
zcot
Level 9
Level 9
Posts: 2798
Joined: Wed Oct 19, 2016 6:08 pm

Re: Display watching/recording in conky for plex

Post by zcot »

Is there some kind of xml parser you can get involved with? just eliminate almost the whole line and get predictable data no problem..
b2a8r1

Re: Display watching/recording in conky for plex

Post by b2a8r1 »

got it working it needs curl and xmlstarlet installed.

Code: Select all

Watching: ${execi 2 curl -sH "X-Plex-Token:yourtokenhere" http://127.0.0.1:32400/status/sessions | xmlstarlet sel -t -m "//MediaContainer" -v '@size'}
Recording: ${execi 2 curl -sH "X-Plex-Token:yourtokenhere" http://127.0.0.1:32400/activities | xmlstarlet sel -t -m "//MediaContainer" -v '@size'}
${execi 2 curl -sH "X-Plex-Token:yourtokenhere" http://127.0.0.1:32400/activities | xmlstarlet sel -t -m "//Activity" -v '@title' -o ": " -v '@subtitle' -o " (" -v '@progress' -o '%)' -nl}
looks like this.
Screenshot from 2018-06-02 23-16-32.png
User avatar
zcot
Level 9
Level 9
Posts: 2798
Joined: Wed Oct 19, 2016 6:08 pm

Re: Display watching/recording in conky for plex

Post by zcot »

Ha! Great! Very nice!

It would be nice to see you get rid of the duplicate call(the same curl call in the second and third line). It's not as efficient like that, but also, what about in the instances when an activity change happens between the 2nd and 3rd call? :twisted:

Maybe you can get rid of the call in the first line also. What's unique about that "/status/sessions" call? Can you not extrapolate the same info out of a single call to "/activities"? (You didn't show the return info on one of those calls.. or how an activities call returns the info when all 4 tuners are at play with playing and recording both.. maybe you can get everything at once from there?) The line says title="Recording", but does it say title="Playing" when that tuner is playing?

What is your global update interval? with those execi calls being every 2 seconds..
Locked

Return to “Compiz, Conky, Docks & Widgets”