[SOLVED]Display watching/recording in conky for plex

Forum rules
Before you post please read how to get help
Post Reply
b2a8r1
Level 1
Level 1
Posts: 31
Joined: Tue May 21, 2013 3:55 pm

[SOLVED]Display watching/recording in conky for plex

Post by b2a8r1 » Sat Jun 02, 2018 1:35 pm

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 b2a8r1 on Thu Jun 07, 2018 5:56 am, edited 1 time in total.
Arch 4.16.8
AMD RYZEN 5 1600 ASUSTeK PRIME B350-PLUS 8gb Mem
XFX Rx 480 os Samsung_SSD_850_500GB Storage 3TB Seagate Mythtv 29.1/fixes
Tuners 1x HVR 1150 1x Quadhd ATSC

User avatar
zcot
Level 3
Level 3
Posts: 135
Joined: Wed Oct 19, 2016 6:08 pm

Re: Display watching/recording in conky for plex

Post by zcot » Wed Jun 06, 2018 7:38 am

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
Level 1
Level 1
Posts: 31
Joined: Tue May 21, 2013 3:55 pm

Re: Display watching/recording in conky for plex

Post by b2a8r1 » Thu Jun 07, 2018 5:55 am

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
Arch 4.16.8
AMD RYZEN 5 1600 ASUSTeK PRIME B350-PLUS 8gb Mem
XFX Rx 480 os Samsung_SSD_850_500GB Storage 3TB Seagate Mythtv 29.1/fixes
Tuners 1x HVR 1150 1x Quadhd ATSC

User avatar
zcot
Level 3
Level 3
Posts: 135
Joined: Wed Oct 19, 2016 6:08 pm

Re: Display watching/recording in conky for plex

Post by zcot » Thu Jun 07, 2018 2:30 pm

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..

Post Reply

Return to “Compiz, Conky, Docks, & Widgets”