Fetch title and description from Youtube API if none is provided.
This commit is contained in:
parent
30f8f02a56
commit
95b357636c
|
@ -31,6 +31,8 @@ class Embedded_videos_Controller extends Controller {
|
||||||
try {
|
try {
|
||||||
$valid = $form->validate();
|
$valid = $form->validate();
|
||||||
if ($form->add_embedded_video->inputs['video_url']->value != "") {
|
if ($form->add_embedded_video->inputs['video_url']->value != "") {
|
||||||
|
$title = $form->add_embedded_video->inputs['title']->value;
|
||||||
|
$description = $form->add_embedded_video->inputs['description']->value;
|
||||||
$youtubeUrlPattern="youtube";
|
$youtubeUrlPattern="youtube";
|
||||||
$youtubeApiUrl="http://gdata.youtube.com/feeds/api/";
|
$youtubeApiUrl="http://gdata.youtube.com/feeds/api/";
|
||||||
$youtubeThumbnailUrl="http://img.youtube.com/vi/";
|
$youtubeThumbnailUrl="http://img.youtube.com/vi/";
|
||||||
|
@ -49,6 +51,13 @@ class Embedded_videos_Controller extends Controller {
|
||||||
$temp_filename = VARPATH . "tmp/$itemname";
|
$temp_filename = VARPATH . "tmp/$itemname";
|
||||||
if ($content) {
|
if ($content) {
|
||||||
$valid_url = true;
|
$valid_url = true;
|
||||||
|
$sxml = simplexml_load_file("http://gdata.youtube.com/feeds/api/videos/$video_id");
|
||||||
|
if ($title == '') {
|
||||||
|
$title = (string)$sxml->title;
|
||||||
|
}
|
||||||
|
if ($description == '') {
|
||||||
|
$description = (string)$sxml->content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,10 +70,10 @@ class Embedded_videos_Controller extends Controller {
|
||||||
gallery_graphics::composite($temp_filename, $temp_filename, array("file" => "modules/embed_videos/images/embed_video_icon.png", "position" => "center", "transparency" => 95));
|
gallery_graphics::composite($temp_filename, $temp_filename, array("file" => "modules/embed_videos/images/embed_video_icon.png", "position" => "center", "transparency" => 95));
|
||||||
$item->set_data_file($temp_filename);
|
$item->set_data_file($temp_filename);
|
||||||
$item->name = basename($itemname);
|
$item->name = basename($itemname);
|
||||||
$item->title = $form->add_embedded_video->title->value;
|
$item->title = $title;
|
||||||
$item->parent_id = $album->id;
|
$item->parent_id = $album->id;
|
||||||
$item->description = $form->add_embedded_video->description->value;
|
$item->description = $description;
|
||||||
$item->slug = $form->add_embedded_video->slug->value;
|
$item->slug = $form->add_embedded_video->inputs['slug']->value;
|
||||||
$path_info = @pathinfo($temp_filename);
|
$path_info = @pathinfo($temp_filename);
|
||||||
$item->save();
|
$item->save();
|
||||||
//db::query("UPDATE {items} SET `type` = 'embedded_video' WHERE `id` = $item->id")->execute();
|
//db::query("UPDATE {items} SET `type` = 'embedded_video' WHERE `id` = $item->id")->execute();
|
||||||
|
|
Reference in New Issue
Block a user