Export Schedule of a specific date

Hello,

I am using the week schedule API api/week-info/ to display my schedule on a website with success. It is displaying this week and the next week schedule as expected.

I’d like to display the schedule of two specific weeks, is it possible?
Thanks in advance

Hello nix,
Welcome to the LibreTime community. Unfortunately our API is currently undocumented for the most part so we need to probe the code to answer this question. This is from airtime_mvc/application/controllers/ApiController.php there is also a V2 that is used for the embed widget only currently.

public function weekInfoAction()
{
    if (Application_Model_Preference::GetAllow3rdPartyApi() || $this->checkAuth()) {
        // disable the view and the layout
        $this->view->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $request = $this->getRequest();
        $result = WidgetHelper::getWeekInfo($this->getRequest()->getParam("timezone"));

        //used by caller to determine if the airtime they are running or widgets in use is out of date.
        $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;

        $this->returnJsonOrJsonp($request, $result);
    } else {
        header('HTTP/1.0 401 Unauthorized');
        print _('You are not allowed to access this resource. ');
        exit;
    }
}

So lets look and see the functions inside of airtime_mvc/application/common/WidgetHelper.php

Looking at the V1 code that is used by the API it doesn’t appear to offer any parameters to do anything beyond the current week and next.

Here is the V2 comment

/**
 * Returns a weeks worth of shows in UTC, and an info array of the current week's days.
 * Returns an array of two arrays:
 *
 * The first array is 7 consecutive week days, starting with the current day.
 *
 * The second array contains shows scheduled during the 7 week days in the first array.
 * The shows returned in this array are not in any order and are in UTC.
 *
 * We don't do any timezone conversion in this function on purpose. All timezone conversion
 * and show time ordering should be done on the frontend.
 *
 * *** This function does no HTML encoding. It is up to the caller to escape or encode the data appropriately.
 *
 * @return array
 */
public static function getWeekInfoV2()

So the quick answer is that this isn’t currently supported.

The long answer is that if you can write and edit PHP code then you could probably add this functionality, a very useful project for LibreTime in general would be to document our API so that we could expand it.

Thanks for asking.

Thanks for your fast and precise answer.
The first line of the getWeekInfoV2() function is

$weekStartDateTime = new DateTime("now", new DateTimeZone(Application_Model_Preference::GetTimezone()));

So even if I’m not very good in php, I can try to modify this function to accept a parameter $customWeekStartTime to override now if provided.

But then how I can call this function? I don’t really understand where the translation between api/week-info and the function weekInfoAction is made, and in this case I’d like to add a api/week-info-v2 url.

Thanks again for your answer, and your work on libretime!

Well from what I can tell as someone who didn’t write this code and hasn’t spent much time trying to get the API working. The ApiController needs to be updated to point at V2 or better yet a new action working. I think that Zend 1 MVC translates week-info at the top into WeekInfoAction. And I think that it can pull parameters from the requests object.

It extends ZendControllerAction so you might be able to get more info from the docs at this link.

Let me know if that helps I think you just pass the parameters via the URL call. But I need to spend more time figuring this out as right now I’m not 100% sure.

Right. It seems zend is translating week-info to an action called weekInfoAction() (see here for example). So I only need to define a new function named weekInfoV2Action that manage the new date param and points well to the getWeekInfoV2() and then edit a bit this function …

I will let you know if it works!
Thanks!

Thanks it works as expected!