Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ This Omeka plugin adds the ability to import Youtube videos into Omeka as items

If you use this plugin, please take a moment to submit feedback about your experience, so we can keep making Omeka better: [User Survey](https://docs.google.com/forms/d/1cn-0S5RRJEQirXS8dCmBA_t-q2hrIw7rtQ9n9i_3e0c/viewform?usp=send_form)

### API Key
The plugin requires a free [YouTube Data API V3 key](https://developers.google.com/youtube/v3), which can be configured at `/admin/plugins/config?name=YouTubeImport`.

### Configuring Display Dimensions
The dimensions of the embedded youtube video display default to 640px by 360px. These dimensions can be set in the plugin configuration page, at `/admin/plugins/config?name=YouTubeImport`. Setting these values can fix display problems on some themes. Keep in mind that you should include units in your width and height entries (e.g. "640px" or "100%").
10 changes: 7 additions & 3 deletions YouTubeImportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class YouTubeImportPlugin extends Omeka_Plugin_AbstractPlugin
/**
* @var array Options for the plugin.
*/
protected $_options = array('youtube_width'=>640,'youtube_height'=>360);
protected $_options = array('youtube_width'=>640,'youtube_height'=>360, 'youtube_apikey'=>'');


public function hookInitialize(){
Expand Down Expand Up @@ -71,7 +71,7 @@ public function filterDisplayElements($elementSets){

//if there is no "player" element installed, do nothing
if(!element_exists(ElementSet::ITEM_TYPE_NAME,'Player'))
return $elementSets
return $elementSets;

// if there is no youtube player on this item, do nothing
if(!metadata($item,array('Item Type Metadata','Player')))
Expand Down Expand Up @@ -107,14 +107,16 @@ public function filterDisplayElements($elementSets){
*@return void
*/
public function hookInstall(){
include_once(dirname(__FILE__).'/helpers/import.php');
YoutubeImport_ImportHelper::CreateThumbnailElement;
YoutubeImport_ImportHelper::CreatePlayerElement;
}

public function hookUpgrade($oldVersion,$newVersion){
include_once(dirname(__FILE__).'/helpers/import.php');
if(!element_exists(ElementSet::ITEM_TYPE_NAME,'Imported Thumbnail'))
YoutubeImport_ImportHelper::CreateThumbnailElement;
if(!element_exists(ElementSet::ITEM_TYPE_NAME,'Player'))
if(!element_exists(ElementSet::ITEM_TYPE_NAME,'Player'))
YoutubeImport_ImportHelper::CreatePlayerElement;
}

Expand Down Expand Up @@ -213,6 +215,8 @@ public function hookConfig() {
set_option('youtube_width',$_REQUEST['youtube_width']);
if(isset($_REQUEST['youtube_height']))
set_option('youtube_height',$_REQUEST['youtube_height']);
if(isset($_REQUEST['youtube_apikey']))
set_option('youtube_apikey', $_REQUEST['youtube_apikey']);
}

public function hookConfigForm(){
Expand Down
2 changes: 1 addition & 1 deletion forms/ImportForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private static function _importSingle()

$client = new Google_Client();
$client->setApplicationName("Omeka_Youtube_Import");
$client->setDeveloperKey(YoutubeImport_ImportHelper::$youtube_api_key);
$client->setDeveloperKey(YoutubeImport_ImportHelper::getApiKey());

try{
$service = new Google_Service_YouTube($client);
Expand Down
11 changes: 11 additions & 0 deletions forms/config_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@
<p class = "explanation">Enter the default height for display of videos imported from Youtube</p>
</div>
</div>

<div class="field">
<div id="youtube-apikey-label" class="two columns alpha">
<label for="youtube_height"><?php echo __('YouTube API Key'); ?></label>
</div>
<div class="inputs five columns omega">
<?php echo get_view()->formText('youtube_apikey', get_option('youtube_apikey'),
array()); ?>
<p class = "explanation">Enter a YouTube Data API V3 key, as YouTube rate limits the default key. See <a href="https://developers.google.com/youtube/v3">https://developers.google.com/youtube/v3</a>.</p>
</div>
</div>
6 changes: 4 additions & 2 deletions helpers/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ class YoutubeImport_ImportHelper
{

/**
* @var string Youtube API key for this plugin
* @return $string Youtube API key for this plugin
*/
public static $youtube_api_key = 'AIzaSyDI8ApsA7MBIK4M1Ubs9k4-Rk7_KOeYJ5w';
public function getApiKey(){
return get_option('youtube_apikey');
}

/**
* @var string Google app name associated with this plugin
Expand Down