Get Channel Schedule as RSS (REST)

Overview

The Schedule RSS feed, linked from the dashboard, provides information about a channel’s upcoming schedule in RSS (XML) format. There are a few options about how much data to have this service return.

If you are using a version earlier than 3.6.5, please refer to the older Program Schedule RSS feed documentation.

Request URL

There is one optional parameter that can be passed to the URL: Channel ID. URL format is:

http://myserver:3000/xml/program_schedule_feed/[?channel_id=1-20]

Substitute your server’s hostname, domain, or IP address for myserver. Optional parameters are show in brackets [].

Parameters

Parameter Type Required Format Description
channel_id Integer Range from 1 to 20 (depending on your server) Channel ID. If omitted, the schedule for all channels is displayed.
start DataTime YYYYMMDD Filter results to exclude everything prior to this date. If omitted, today’s date is used.
end DataTime YYYYMMDD Filter results to exclude everything after this date. If omitted, range ends one week from today.

Examples of valid URL parameters and what they return:

  • http://myserver:3000/xml/program_schedule_feed/ – Returns one week of data forall channels.
  • http://myserver:3000/xml/program_schedule_feed/?channel_id=1 – Returns one week of data for Channel 1.
  • http://myserver:3000/xml/program_schedule_feed/?channel_id=4 – Returns one week of data for Channel 4.
  • http://myserver:3000/xml/program_schedule_feed/?channel_id=3&start=YYYYMMDD&end=YYYYMMDD – Returns data from date range specified for Channel 3.
  • http://myserver:3000/xml/program_schedule_feed/?channel_id=3&end=YYYYMMDD – Returns data from today to end date specified for Channel 3.
  • http://myserver:3000/xml/program_schedule_feed/?channel_id=1&start=YYYYMMDD – Returns data from today to one week from now for Channel 1.

Code Examples

Testing

Testing different feed parameters can be done with a web browser. The /xml/program_schedule_feed URL displays a basic RSS 2.0 feed of the channel schedule.

In your browser, go to http://myserver:3000/xml/program_schedule_feed/ (substitute the hostname of your server).

Parsing Date Field

The date is presented in RFC 2822 format, commonly used in email formatting. This format contains both relative time (that is, modified by time zone), and the timezone information (represented as +/- Greenwich Mean Time). The example below uses GMT -5, or Eastern Standard Time. The timezone information is placed at the end of the title string after a ” – ” separator.

In all programming languages, to get the desired date format:

  • Parse it from the pubDate field.
  • Use the language’s date-parsing features to get the RFC representation into a Date object.

PHP

function parsePsgRss($pubDate) {
  $timestamp = strtotime($pubDate);
  $hr_date = date("g:i A", $timestamp);
 
  return $hr_date;
}
 
echo parsePsgRss("Sample Program Two - Tue, 13 Jan 2009 22:00:00 -0500");

PHP’s strtotime() function can read RFC2822 directly. That converts it to a Unix timestamp (seconds since the epoch). Other PHP date functions then take that timestamp directly. For example, Date takes a date format string to return just “10:00 PM” in this example string.

JavaScript

function getDateObject(pub_date) {
   return new Date(pubDate);
}
 
// Given a Javascript date object, return time in friendly format (8:00 AM).
function getHHMM(date) {
  // Accepts JS Date and returns time as H:MM AM/PM.
  hours = (date.getHours() > 12) ? (date.getHours() - 12) : date.getHours();
  minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  time = hours + ":" + minutes + " " + ((date.getHours() > 11) ? 'PM' : 'AM');
  return time;
}

The first function parses off the RFC time and turns it into a Javascript Date object, a built-in object in Javascript. The second function takes a date object, and returns just “10:00 PM”.

One way to call the two Javascript functions is:

getHHMM(getDateObject("Tue, 13 Jan 2009 22:00:00 -0500");

Returns

Success

Here is an example snippet from the RSS feed XML response:

    TelVue Princeton Broadcast Channel 1
 
      Tue, 06 Jul 2010 17:30:00 -0400
      29
      1800
      <psg:end_datetime xmlns:psg="http://192.168.1.2/psg_namespace/">Tue, 06 Jul 2010 18:00:00 -0400
      http://192.168.1.2/images/123.png
      A weekly roundup of the latest local sports news.
      			http://10.10.10.10
 
      00:30:48:B1:37:58-29
 
      Tue, 06 Jul 2010 18:00:00 -0400
      49
      1800
      <psg:end_datetime xmlns:psg="http://192.168.1.2/psg_namespace/">Tue, 06 Jul 2010 18:30:00 -0400
      http://192.168.1.2/images/123.png
      A weekly roundup of the latest local sports news.
      			http://10.10.10.10
 
      00:30:48:B1:37:58-29
 
    TelVue Princeton Broadcast Channel 2
 
      Tue, 06 Jul 2010 19:30:00 -0400
      102
      1800
      <psg:end_datetime xmlns:psg="http://192.168.1.2/psg_namespace/">Tue, 06 Jul 2010 20:00:00 -0400
      http://192.168.1.2/images/192.png
      A daily TV/radio news program, hosted by Amy Goodman and Juan
        Gonzalez, airing on over 800 stations, pioneering the largest community media
        collaboration in the U.S.
      			http://10.10.10.10
 
      00:30:48:B1:37:58-102

Several key fields of the content metadata are made available, including the Program field (in the title element), the description, the thumbnail, and duration.

A Note on What “Title” Contains in the RSS. For each content file, if you fill in the “Program” metadata field, then “Program” is the string presented as “title” in the RSS. Otherwise, the filename is presented in the RSS. The fields Program Code, Episode, and Episode Code have no impact here. The RSS title will be “Program” or, if Program is blank, the filename.

Failure

Invalid Channel

< ?xml version="1.0" encoding="UTF-8"?>
 
  There were problems with your schedule query parameters.
  An invalid channel was specified.

History

Introduced
Princeton Server 3.6.5
Facebooktwittergoogle_pluslinkedin

3 Comments

  1. Sean Snyder says:

    Why have you removed the start and end date/time found in the deprecated version of “Get Channel Schedule as RSS”?

    These features are still very useful for parsing schedule info beyond a week

    Will they return, or will we be able to reliably use the deprecated version without fear of it being completely removed?

    Please advise
    Thanks
    -Sean

  2. admin says:

    Sean, a date range feature is coming to that new feed.

  3. Douglas Finn says:

    Thanks for this info. As relatively new users of a B3400 server, it’ll be useful as we work to integrate the RSS feeds with our website.

    Can you tell me if there are any other parameters that can be made use of at this point? Is there any further development of the RSS feeds?

    Thanks!