Closed (fixed)
Project:
Media: YouTube
Version:
7.x-2.0-rc1
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Feb 2013 at 07:56 UTC
Updated:
2 Oct 2014 at 06:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
aaron commentedhttp://www.youtube.com/oembed?url=http%3A//youtube.com/watch%3Fv%3DhBzx4... returns 401 Unauthorized. I am not certain why, as testing against other urls appears to work fine. Maybe the video is private?
Comment #2
aaron commentedhttp://www.youtube.com/oembed?url=http%3A//youtube.com/watch%3Fv%3DhBzx4... returns 401 Unauthorized. I am not certain why, as testing against other urls appears to work fine. Maybe the video is private?
Comment #3
aaron commentedhttp://www.youtube.com/oembed?url=http%3A//youtube.com/watch%3Fv%3DhBzx4... returns 401 Unauthorized. I am not certain why, as testing against other urls appears to work fine. Maybe the video is private?
Comment #4
davisbenI was having this issue as well. It's happening on videos that have embedding disabled. Here's a patch that adds a specific error message for this case.
Comment #5
yuchuan1 commentedThis happens to my installation as well. However it works fine when I tried it from home where there's no proxy or any firewall blocking the network. It happens only when I tried the same thing from a corporate environment.
Note: I have enabled and configured http_proxy module and my installation is able to perform module update running under corporate environment.
Comment #6
dave reidCommitted to 7.x-2.x and 7.x-1.x:
http://drupalcode.org/project/media_youtube.git/commit/559e60b
http://drupalcode.org/project/media_youtube.git/commit/7c7482b
Comment #8
AMit commentedreplace this file sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc
from this
.*?v=([^"\& ]+)@i',
'@youtube\.com/embed/([^"\&\? ]+)@i',
'@youtube\.com/v/([^"\&\? ]+)@i',
'@youtube\.com/\?v=([^"\& ]+)@i',
'@youtu\.be/([^"\&\? ]+)@i',
'@gdata\.youtube\.com/feeds/api/videos/([^"\&\? ]+)@i',
);
foreach ($patterns as $pattern) {
preg_match($pattern, $embedCode, $matches);
// @TODO: Parse is called often. Refactor so that valid ID is checked
// when a video is added, but not every time the embedCode is parsed.
if (isset($matches[1]) && self::validId($matches[1])) {
return file_stream_wrapper_uri_normalize('youtube://v/' . $matches[1]);
}
}
}
public function claim($embedCode) {
if ($this->parse($embedCode)) {
return TRUE;
}
}
public function getFileObject() {
$uri = $this->parse($this->embedCode);
$file = file_uri_to_object($uri, TRUE);
if (empty($file->fid) && $info = $this->getOEmbed()) {
$file->filename = truncate_utf8($info['title'], 255);
}
return $file;
}
/**
* Returns information about the media. See http://video.search.yahoo.com/mrss.
*
* @return
* If ATOM+MRSS information is available, a SimpleXML element containing
* ATOM and MRSS elements, as per those respective specifications.
*
* @todo Would be better for the return value to be an array rather than a
* SimpleXML element, but media_retrieve_xml() needs to be upgraded to
* handle namespaces first.
*/
public function getMRSS() {
$uri = $this->parse($this->embedCode);
$video_id = arg(1, file_uri_target($uri));
$rss_url = url('http://gdata.youtube.com/feeds/api/videos/' . $video_id, array('query' => array('v' => '2')));
// @todo Use media_retrieve_xml() once it's upgraded to include elements
// from all namespaces, not just the document default namespace.
$request = drupal_http_request($rss_url);
if (!isset($request->error)) {
$entry = simplexml_load_string($request->data);
}
else {
throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})");
//if request wasn't successful, create object for return to avoid errors
$entry = new SimpleXMLElement();
}
return $entry;
}
/**
* Returns information about the media. See http://www.oembed.com/.
*
* @return
* If oEmbed information is available, an array containing 'title', 'type',
* 'url', and other information as specified by the oEmbed standard.
* Otherwise, NULL.
*/
public function getOEmbed() {
$uri = $this->parse($this->embedCode);
$external_url = file_create_url($uri);
$oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json')));
$response = drupal_http_request($oembed_url);
if (!isset($response->error)) {
return drupal_json_decode($response->data);
}
else {
// commented out because caused migrate to stop when encountered an error -- throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})");
return ;
}
}
}