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.
Request URL
To get the schedule for a specific channel as XML, you can pass the Channel ID, for example:
http://myserver/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/xml/program_schedule_feed/
– Returns one week of data forall channels.http://myserver/xml/program_schedule_feed/?channel_id=1
– Returns one week of data for Channel 1.http://myserver/xml/program_schedule_feed/?channel_id=4
– Returns one week of data for Channel 4.http://myserver/xml/program_schedule_feed/?channel_id=3&start=YYYYMMDD&end=YYYYMMDD
– Returns data from date range specified for Channel 3.http://myserver/xml/program_schedule_feed/?channel_id=3&end=YYYYMMDD
– Returns data from today to end date specified for Channel 3.http://myserver/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/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
$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
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:
Returns
Success
Here is an example RSS feed XML response:
<rss xmlns:psg=”http://192.168.41.126:80/psg_namespace/” version=”2.0″>
<channel>
<title>Channel 1</title>
<description>Broadcast Channel 1</description>
<item>
<title>Ad Council – Energy Efficiency</title>
<pubDate>Thu, 07 Mar 2019 17:00:00 -0500</pubDate>
<psg:eventId>19</psg:eventId>
<psg:duration>30</psg:duration>
<psg:end_datetime>Thu, 07 Mar 2019 17:00:30 -0500</psg:end_datetime>
<psg:programCode/>
<psg:episode>Cliff</psg:episode>
<psg:episodeCode/>
<psg:thumbnail>http://192.168.41.126/thumbnails/16.jpg?1551989877</psg:thumbnail>
<psg:mediumId/>
<vodURL/>
<description>
New PSAs released in 2011 encourage homeowners to save energy by taking actions around the home. The PSAs offer practical ideas for reducing household energy consumption, and saving money in the process.
</description>
<link>http://10.10.10.10</link>
<guid>AC1F6B49B180-19</guid>
</item>
</channel>
</rss>
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″?>
<hash>
<errors>There were problems with your schedule query parameters. An invalid channel was specified.</errors>
</hash>
History
Introduced | |
---|---|
Princeton Server | 3.6.5 |