Can someone help.
Cheers
Code: Select all
$LISEinstance = \cms_utils::get_module('LISEYouTube');
$edit = $LISEinstance->LoadItemByIdentifier('alias', $SaveVideo_id);
// creates an (almost) empty object if item doesn't exist
$url_prefix = $LISEinstance->GetPreference('url_prefix');
$detail_page = $LISEinstance->GetPreference('page_alias');
$url_Setpath = 'video/'.$SaveVideo_id;
if (!isset($edit->item_id))
{
// doesn't exist yet so create new LISE item
$vitem = $LISEinstance->InitiateItem();
$vitem->medium_image = $vdata->items[0]->snippet->thumbnails->medium->url;
$vitem->maxres_image = $vdata->items[0]->snippet->thumbnails->maxres->url;
$vitem->views = number_format_short($vdata->items[0]->statistics->viewCount);
$vitem->duration = YouTube_TimeCode($vdata->items[0]->contentDetails->duration);
$vitem->duration_text = Time_Words($vdata->items[0]->snippet->publishedA);
$vitem->video_id = htmlspecialchars($SaveVideo_id);
$vitem->url = $url_Setpath;
$vitem->date_published = '2020-07-13 21:55:54; // WORKING with custom date field
$vitem->create_time = '2020-07-13 21:55:54'; // NOT WORKING
// added these
$vitem->title = $vdata->items[0]->snippet->title;
$vitem->description = htmlspecialchars($vdata->items[0]->snippet->description);
$vitem->alias = htmlspecialchars($SaveVideo_id);
$vitem->playlist = $category_id;
$LISEinstance->SaveItem($vitem);
}
else
{
// does exist so just edit existing LISE item
$vitem = $LISEinstance->LoadItemByIdentifier('alias', $SaveVideo_id);
$vitem->alias = htmlspecialchars($SaveVideo_id); // alreay exists - don't update
// the following get updated
$vitem->views = number_format_short($vdata->items[0]->statistics->viewCount);
$vitem->create_time = '2020-07-13 21:55:54'; // NOT WORKING
$LISEinstance->SaveItem($vitem);
}


