This may be related to http://drupal.org/node/1922962

Vanilla Drupal 7.20 site, with the following modules enabled:

 Package           Name                                   Version
 Administration    Administration menu (admin_menu)       7.x-3.0-rc4
 Chaos tool suite  Chaos tools (ctools)                   7.x-1.2
 Core              Block (block)                          7.20
 Core              Database logging (dblog)               7.20
 Core              Field (field)                          7.20
 Core              Field SQL storage (field_sql_storage)  7.20
 Core              Field UI (field_ui)                    7.20
 Core              File (file)                            7.20
 Core              Filter (filter)                        7.20
 Core              Image (image)                          7.20
 Core              Node (node)                            7.20
 Core              System (system)                        7.20
 Core              Text (text)                            7.20
 Core              Update manager (update)                7.20
 Core              User (user)                            7.20
 Development       Devel (devel)                          7.x-1.3
 Media             File entity (file_entity)              7.x-2.0-unstable7
 Media             Media (media)                          7.x-2.0-unstable7
 Media             Media Internet Sources                 7.x-2.0-unstable7
                   (media_internet)
 Media             Media: YouTube (media_youtube)         7.x-2.0-rc2
 Other             Job Scheduler (job_scheduler)          7.x-2.0-alpha3
 Other             Module filter (module_filter)          7.x-1.7
 Performance and   CDN (cdn)                              7.x-2.5+13-dev
 scalability
 Views             Views (views)                          7.x-3.5

With the CDN module enabled, but with disabled status, I can save youtube videos as expected.

When I enable serving files via the CDN module, (origin pull, everything else default settings), and I try to save a youtube URL, I get the following error message:
Exception: Error Processing Request. (Error: 404, Not Found) in MediaInternetYouTubeHandler->getOEmbed() (line 116 of /sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc).

That function, for reference is:

  /**
   * 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 {
      throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})");
      return;
    }
  }

I suspect this has to do with the file_create_url function conflicting with the file URL rewriting of the CDN module. What other information can I provide to flesh out presumed bug report? Or is there a config setting that would allow me to bypass this?

Comments

rwinikates’s picture

I should add that it goes back to working fine when I set the CDN status to disabled again (module still enabled, just not serving files via CDN).

Wim Leers’s picture

Can you tell me what the value of $uri is? (As parsed by ->parse() and passed in to file_create_url().)

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
Status: Active » Postponed (maintainer needs more info)
rwinikates’s picture

Status: Postponed (maintainer needs more info) » Active

So that function creates the OEmbed call, as best described in this YT blog post. So to use their example, if I were to try to create a new YouTube media file in Drupal, I would paste in a youtube URL (http://www.youtube.com/watch?v=bDOYN-6gdRE) that would go to $uri, and then $external_url, to create an oembed request url like this: http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3Db..., which returns the following array:

{
provider_url: "http://www.youtube.com/",
thumbnail_url: "http://i3.ytimg.com/vi/bDOYN-6gdRE/hqdefault.jpg",
thumbnail_height: 360,
type: "video",
version: "1.0",
height: 344,
author_name: "schmoyoho",
width: 459,
provider_name: "YouTube",
author_url: "http://www.youtube.com/user/schmoyoho",
html: "<iframe width="459" height="344" src="http://www.youtube.com/embed/bDOYN-6gdRE?feature=oembed" frameborder="0" allowfullscreen></iframe>",
title: "Auto-Tune the News #8: dragons. geese. Michael Vick. (ft. T-Pain)",
thumbnail_width: 480
}

Part of this save process is a call to locally keep a copy of a thumbnail of the youtube video, perhaps that might be another source of investigation?

Apologies if this doesn't answer your question, if it doesn't please let me know how best to find the info you need.

Wim Leers’s picture

Status: Active » Postponed (maintainer needs more info)

It's not a direct answer, but I was able to puzzle the different pieces together, thanks to your explanation + http://drupalcode.org/project/media_youtube.git/blob/refs/heads/7.x-2.x:... :)

So, in your example:

$this->embedCode = 'http://www.youtube.com/watch?v=bDOYN-6gdRE';
//$uri = $this->parse($this->embedCode);
$uri = 'youtube://v/bDOYN-6gdRE';
//$external_url = file_create_url($uri);
$external_url = 'some crappy, non-existent, horribly URL because of the CDN module'

It appears the CDN module is simply unable to deal with custom stream wrappers like the one for YouTube. And if that's the case… I've already solved this! Please give the patch at #1863310: CDN module should know how to deal with custom stream wrappers a try :)

rwinikates’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

That patched worked, thanks for your patience and assistance!