function jwplayer_media_add_external_source($url, $title = null) { $extension = pathinfo($url, PATHINFO_EXTENSION); $sourceformat = 'mp4'; foreach (json_decode(JWPLAYER_SOURCE_FORMAT_EXTENSIONS) as $format => $extensions) { if (in_array($extension, $extensions, true)) { $sourceformat = $format; break; } } $params = array('sourcetype' => 'url', 'sourceurl' => $url, 'sourceformat' => $sourceformat, 'tags' => 'wp_media'); if (null !== $title) { $params['title'] = $title; } $response = jwplayer_api_call('/videos/create', $params); if (jwplayer_api_response_ok($response)) { return $response['video']['key']; } return null; }
function jwplayer_import_playlists() { if (!current_user_can('manage_options')) { return; } $imported_playlists = get_option('jwplayer_imported_playlists'); if (!$imported_playlists) { $imported_playlists = array(); add_option('jwplayer_imported_playlists', $imported_playlists); } $playlists = jwplayer_import_legacy_playlists(); foreach ($playlists as $playlist) { if (array_key_exists($playlist->ID, $imported_playlists)) { continue; } $media_ids = explode(',', get_post_meta($playlist->ID, 'jwplayermodule_playlist_items', true)); $media_hashes = array(); foreach ($media_ids as $media_id) { $media_hash = jwplayer_media_hash(intval($media_id)); $media_hashes[] = $media_hash; } if (empty($media_hashes)) { continue; } $params = array('title' => $playlist->post_title, 'type' => 'manual'); $response = jwplayer_api_call('/channels/create', $params); if (jwplayer_api_response_ok($response)) { $hash = $response['channel']['key']; $imported_playlists[$playlist->ID] = $hash; foreach ($media_hashes as $media_hash) { $params = array('channel_key' => $hash, 'video_key' => $media_hash); $response = jwplayer_api_call('/channels/videos/create', $params); if (!jwplayer_api_response_ok($response)) { jwplayer_log('ERROR ADDING VIDEO TO PLAYLIST'); jwplayer_log($params, true); jwplayer_log($response, true); } } } else { jwplayer_log('ERROR CREATING NEW PLAYLIST'); jwplayer_log($params, true); jwplayer_log($response, true); } } update_option('jwplayer_imported_playlists', $imported_playlists); jwplayer_import_check_redirect(); }
/** * Verify the API key and secret that the user has given, by making a call to * the API. * * If the credentials are invalid, return false. * * If the API call failed, return NULL. */ function jwplayer_login_verify_api_key_secret($key, $secret) { // require_once 'include/jwplayer-api.class.php'; // Create an API object with the provided key and secret. $api = new JWPlayer_api($key, $secret); $response = $api->call('/accounts/show', $params); return jwplayer_api_response_ok($response); }
/** * Verify the API key and secret that the user has given, by making a call to * the API. * * If the credentials are invalid, return false. * * If the API call failed, return NULL. */ function jwplayer_login_verify_api_key_secret($key, $secret) { // Create an API object with the provided key and secret. $api = new JWPlayer_api($key, $secret); $response = $api->call('/accounts/show'); return jwplayer_api_response_ok($response); }