How to POST to AddRecordSchedule

Post Reply
misiming
Newcomer
Posts: 6
Joined: Mon Jan 11, 2016 9:50 am
United States of America

How to POST to AddRecordSchedule

Post 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"?>
<detail>
<errorCode>501</errorCode>
<errorDescription>Invalid parentID/override.</errorDescription>
</detail>


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?

Thanks
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: How to POST to AddRecordSchedule

Post by bill6502 »

Hi,

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  \
    hostnameHere:6544/Dvr/AddRecordSchedule

Code: Select all

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

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" \
    mc0:6544/Dvr/AddRecordSchedule 
misiming
Newcomer
Posts: 6
Joined: Mon Jan 11, 2016 9:50 am
United States of America

Re: How to POST to AddRecordSchedule

Post 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


#!/bin/bash

SERVER="10.10.10.10"
PORT="6544"

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

CHAN="$1"


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

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

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" \
    ${SERVER}:${PORT}/Dvr/AddRecordSchedule

User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: How to POST to AddRecordSchedule

Post 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 ;)

https://www.mythtv.org/wiki/Python_API_Examples
misiming
Newcomer
Posts: 6
Joined: Mon Jan 11, 2016 9:50 am
United States of America

Re: How to POST to AddRecordSchedule

Post by misiming »

Thanks.

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

I've use https://github.com/tschaumburg/MythRecordings.bundle to access my recordings.
and
https://github.com/Cigaras/IPTV.bundle 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 :)

-m
sfatula
Senior
Posts: 163
Joined: Sun Aug 09, 2015 3:51 am
Location: Calera, OK
United States of America

Re: How to POST to AddRecordSchedule

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