Page 1 of 1

How to POST to AddRecordSchedule

Posted: Mon Jan 11, 2016 10:18 am
by misiming
Hello all:

I trying to work a way watch a Live broadcast now. But I can seem to figure out how or what to post to /Dvr/AddRecordSchedule.

In order to work out the the details I'm just using curl

I'm trying to do something like:

curl --data "Station=${STATION}&ChanId=${CHAN}&Title=\"${TITLE}\"&StartTime=${START}&EndTime=${ENDTIME}&Type=\"Single Record\"" "http://${SERVER}:${PORT}/Dvr/AddRecordSchedule"

But it's returning:

<?xml version="1.0" encoding="utf-8"?>
<errorDescription>Invalid parentID/override.</errorDescription>

I'm not sure what the parentId should be.

Is there anyone that can give an example of what I should put in the POST envelope?


Re: How to POST to AddRecordSchedule

Posted: Mon Jan 11, 2016 3:10 pm
by bill6502

These are pretty old, but they worked. Set ParentId to 0 unless you're attempting
to override an existing rule. Also you can watch the backend logs after typing:
mythbackend --setverbose upnp (and add: ,http if running 0.28-pre.)

Code: Select all

# Not all of the following are required to schedule a show, see the
# manual.add.recording.curl script in this directory.

curl --trace --request POST \
    --data Title="The Tonight Show With Jay Leno" \
    --data Subtitle="" \
    --data Description=""\
    --data Category=Talk \
    --data StartTime=2013-10-26T03:34:00 \
    --data EndTime=2013-10-26T04:36:00 \
    --data SeriesId=EP00004397 \
    --data ProgramId=EP000043975089 \
    --data ChanId=1051 \
    --data Station="CBS2 HD" \
    --data FindDay=3 \
    --data FindTime="10:34:00" \
    --data ParentId=0 \
    --data Inactive=false \
    --data Season=0 \
    --data Episode=0 \
    --data Inetref= \
    --data Type=4 \
    --data SearchType=0 \
    --data RecPriority=99 \
    --data PreferredInput=0 \
    --data StartOffset=0 \
    --data EndOffset=0 \
    --data DupMethod=6 \
    --data DupIn=15 \
    --data Filter=1024 \
    --data RecProfile=Default \
    --data RecGroup=Default \
    --data StorageGroup=Default \
    --data PlayGroup=Default \
    --data AutoExpire=true \
    --data MaxEpisodes=0 \
    --data MaxNewest=false \
    --data AutoCommflag=false \
    --data AutoTranscode=false \
    --data AutoMetaLookup=false \
    --data AutoUserJob1=false \
    --data AutoUserJob2=false \
    --data AutoUserJob3=false \
    --data AutoUserJob4=false \
    --data Transcoder=0  \

Code: Select all

# Minimum REST for a Manual Record. Don't forget to set the FindTime
# as localtime, not UTC.
# Station =

curl \
    --data Title="0000000023" \
    --data Subtitle="Services API Subtitle Test" \
    --data StartTime=2014-05-28T18:13:00 \
    --data EndTime=2014-05-28T18:16:00 \
    --data ChanId=1021 \
    --data Station="CBS2-HD" \
    --data FindDay=1 \
    --data FindTime="18:13:00" \
    --data ParentId=0 \
    --data Type="Single" \
    --data SearchType="Manual Search" \

Re: How to POST to AddRecordSchedule

Posted: Tue Jan 12, 2016 12:21 am
by misiming
Worked Perfectly. Thank you so much

Now to teach myself how to make all the pieces work in python.

If anyone cares, this is what I threw in a quick shell script

Code: Select all



if [ -z "${1}" ] ; then
echo "No Channel Provided"
exit 0


MINUTES=`date +%M | bc`
if [ "${MINUTES}" -gt 29 ] ; then
NOW=`date -u +%F'T'%H':30:00'`

NOW=`date -u +%F'T'%H':00:00'`

TITLE=`curl -vs "http://${SERVER}:6544/Guide/GetProgramDetails?StartTime=${NOW}&ChanId=${CHAN}" | xml2 | grep "/Program/Title=" | awk -F "=" '{print $2}'`
STARTTIME=`curl -vs "http://${SERVER}:6544/Guide/GetProgramDetails?StartTime=${NOW}&ChanId=${CHAN}"| xml2 | grep "/Program/StartTime=" | awk -F "=" '{print $2}' | sed -e 's/Z//g'`
ENDTIME=`curl -vs "http://${SERVER}:6544/Guide/GetProgramDetails?StartTime=${NOW}&ChanId=${CHAN}"| xml2 | grep "/Program/EndTime=" | awk -F "=" '{print $2}' | sed -e 's/Z//g'`
STATION=`curl -vs "http://${SERVER}:6544/Guide/GetProgramDetails?StartTime=${NOW}&ChanId=${CHAN}"| xml2 | grep "/Program/Channel/CallSign=" | awk -F "=" '{print $2}'`

curl \
    --data Title="${TITLE}" \
    --data StartTime=${STARTTIME} \
    --data EndTime=${ENDTIME} \
    --data ChanId=${CHAN} \
    --data Station="${STATION}" \
    --data FindDay=1 \
    --data FindTime="00:00:00" \
    --data ParentId=0 \
    --data Type="Single Record" \
    --data SearchType="Manual Search" \

Re: How to POST to AddRecordSchedule

Posted: Tue Jan 12, 2016 12:44 am
by bill6502
There's a module here that handles the communications. There are also
a few examples that could be used as templates for Python programs that
use the Services API. The instructions on how to use the help feature
should help. Note that in your case, you'd create a Python dict with
all of the postdata. It also shows you how to parse the received data
which will also be in a dict. Or you can write your own ;)

Re: How to POST to AddRecordSchedule

Posted: Tue Jan 12, 2016 2:45 am
by misiming

The ultimate goal for me is to get LiveTV into Plex.

I've use to access my recordings.
and to watch live streams I start through mythweb (and a system Event)

But I kind of want to merge things together.

I now have proof positive it's possible

I just have the python learning curve to overcome :)


Re: How to POST to AddRecordSchedule

Posted: Tue Mar 01, 2016 7:37 am
by sfatula
I use Mythrecordings also. A little late to your thread, but, you CAN get live TV into Plex. If you are using a HDHomerun, use the HDHR Viewer 2 plugin. Beautiful. This then means you can watch live tv on virtually any Plex client, if not all of them.

If you don't have a HDHomerun tuner, then, there is the IPTV plugin which lets you define a list of streaming channels that may work for you, albeit, without guide data.

I know it's not within mythrecordings, but, it's still in Plex.