Series Pass by Channel & Time

I've never used CURL before, and I can't figure out from the available posts how to do it. If someone could post a very simple example of a CURL command line and a complete file to feed to it, I'm sure I could progress on my own from there.

I did confirm that my Windows 10 has a copy of CURL installed.

Thanks,

Ken

The following will create a manual recording to start at 24 January 2021 5:00PM PST, for a duration of 1 hour, on channel 123. The program will be recorded with a series title of "Manual recording", and this particular recording will appear as an episode of that series named "Recording title".

$ cat program.json
{
  "Name": "Manual recording",
  "Time": 1611536400,
  "Duration": 3600,
  "Channels": ["123"],
  "Airing": {
    "Source": "manual",
    "Channel": "123",
    "Time": 1611536400,
    "Duration": 3600,
    "Title": "Manual recording",
    "EpisodeTitle": "Recording title",
    "Summary": "Recording description goes here ...",
    "Image": "https://tmsimg.fancybits.co/assets/p9467679_st_h6_aa.jpg",
    "SeriesID": "999999999",
    "Raw": ""
  }
}

$ DVR_IP=10.11.12.13 curl -XPOST --data-binary @program.json "http://${DVR_IP}:8089/dvr/jobs/new"
1 Like

"24 January 2021 5:00PM PST" ??
I have to assume from the context that the date and time are encoded into:
"Time": 1611536400". Is this correct? If so, how is this done.
I'm a Windows user with no experience in these things. Everything else here seems to make sense.

I'm also assuming "$ cat program.json" means create a text file in the current directory named "program.json" with the contents that follow.

The "Time" field is in epoch format. This is the number of seconds since midnight, 1 January 1970 UTC. I use the date command (date -d "desired dated" +%s) to generate this number. I don't know what the Windows equivalent is. I am sure there are myriad sites on the internet or small apps that can handle the conversion. Try searching for epoch time converter or similar.

Basically. When giving command line input/output examples, the input is usually prefixed with $ or #, while the output lines have no prefix. That example was to just output the content of a file called program.json. The name is irrelevant; it is the content that matters. It just needs to be a proper and valid JSON object that gets sent to the DVR server.

If you're on Windows, you might be better served by using Invoke-WebRequest. This is the Windows native client that is built in to Powershell. Look into the -Body and -Method parameters.

(I don't use Windows, so all of my commands are what would be used on Linux/BSD. It's up to you to figure out how to make them work properly in your system. Cut-and-paste scenarios are bad; understanding what the commands are and what is actually happening is what can save you from destroying your system by trying someone else's commands blindly.)

Since you can drag and drop in Windows, I find it easier to use a .json file and drag and drop it onto a Windows .cmd script. I like using a json file as a template and just modify it for each manual recording I do.

I created the template json file and the simple Windows cmd script in a directory (folder) and just drag and drop the json file onto the cmd script. It opens a windows command shell and shows the output, waiting for you to press a key (PAUSE) to exit the cmd shell window.

You just need to change the IP address to that of your Channels DVR Server.
Mine is 192.168.1.4 as shown below.
curl -v "http://192.168.1.4:8089/dvr/jobs/new" --data-binary @%1

Create_a_manual_recording.cmd

@ECHO OFF
REM check if a json file was dropped here and that it exists
IF %1.==. GOTO USAGE
IF NOT %~x1.==.json. GOTO USAGE
IF NOT EXIST %1 GOTO USAGE
ECHO Scheduling job on DVR1 using %1
curl -v "http://192.168.1.4:8089/dvr/jobs/new" --data-binary @%1
GOTO FINISHED

:USAGE
REM Need a fully qualified json filename to schedule
ECHO Drop a json file to be scheduled on this command file

:FINISHED
PAUSE
EXIT
REM
REM %~  removes any surrounding double quotes
REM %~f fully qualified path name
REM %~d drive letter only
REM %~p path only
REM %~n file name only
REM %~x file extension only
REM %~a file attributes of file
REM %~t date/time of file
REM %~z size of file

As far as getting the unix epoch time to put in the json file, I just use https://www.epochconverter.com/ since I don't create many manual recordings. You may be able to find a way to do it in Windows.

YEA!!! It works!

Is there any way to create a series pass to record the same thing every day, or once a week?

No. Series passes rely upon guide information, and manual recordings only supply guide information when they are created.

Ok, I can write some software that does it every day.

Thanks for all your help.

Ken

2 Likes

Since I know I can create a series pass from a computer that is not the server, I have to believe that there is some JSON file that can be sent that will create a new series pass.

Since I also have all of the guide information, I can then believe that I should be able to do this.

All I should need is an example of the JSON file.

Ken

But the problem is the guide data needs to be constantly updated, because the start time will be different for each airing. You need an XMLTV file fed to Channels with a programme element for each date/time you want a recording to happen.

No, this is a different project, having solved the first one. I am all set with manual recordings.

I want to simulate the process of seeing something in the guide and telling it to create a new series pass for that series. Once the series pass is created, I should never have to do anything else on my own.

And to do that, you need to feed Channels guide data. The way to achieve this is with an XMLTV file containing the guide data. This is exactly what the Custom Channel feature is for.

Channels already has the guide data for the programs I want to create a series for. I'm not adding any new channels, I just want to add a new series pass for shows that are already in the existing guide.

So what you are saying is: What is the API endpoint for creating a pass, and what is the required JSON payload?

Sorry, you were not clear. Also, the discussion was muddied because you're posting on your thread about manual recordings without guide data.

If you could, start a new thread, with your question clearly stated. That way, other users who have similar questions can easily find the discussion.

Sorry for the confusion. I'll start a new thread.

I'll post the answer there as well, but for expediency's sake:
The payload is: {"SeriesID":"123456"}, and you PUT /dvr/rules/new. If you only want to record new episodes, set your payload to {"SeriesID":"123456", "Tags": "New"}. (In that example, 123456 is the SeriesID as set by Channels.)

And the follow-up thread for creating a series pass is Remote Creation of Series Pass
(so I don't have to search for it everytime)

Hi @racameron. I'm running on Mac OS Monterey and I am unable to get the date command to do what you did. When I enter this I get a usage error:

bash-3.2$ date -d "24 January 2021 5:00PM PST" +%s
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

What am I doing wrong with the -d parameter?

--Chris

You're not doing anything wrong. The code I posted was for GNU date, and macOS uses BSD date. Because of this, date on a Mac works completely differently. For your use, you would use:

date -j -f "%d %B %Y %l:%M%p %Z" "24 January 2021 5:00PM PST" "+%s"

The command breaks down like this:

  • -j – Do not try to change the system/computer date
  • -f "%d %B %Y %l:%M%p %Z" – This specifies the format of the date you are going to use
  • "24 January 2021 5:00PM PST"– This is the date itself to use as input
  • "+%s" – This is the format to use as the output

To get a full list of all of the format strings you can use for use with date -f, check out the manpage for strftime(3), or see them here.

Thank you so much @racameron. I figured it was something basic. Thanks for the syntax lesson. That really helps.