Skip to content

Instantly share code, notes, and snippets.

@jeffam
Last active August 29, 2015 14:19
Show Gist options
  • Save jeffam/41d4e9fbf322bdac6002 to your computer and use it in GitHub Desktop.
Save jeffam/41d4e9fbf322bdac6002 to your computer and use it in GitHub Desktop.
Drupal Atom Feed w/ Media Importer
// Use with feeds-7.x-2.x-dev
// Tested with http://feeds.feedburner.com/TechCrunch/Greentech?format=xml
$feeds_importer = new stdClass();
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'atom_with_media';
$feeds_importer->config = array(
'name' => 'Atom Feed w/ Media',
'description' => '',
'fetcher' => array(
'plugin_key' => 'FeedsHTTPFetcher',
'config' => array(
'auto_detect_feeds' => FALSE,
'use_pubsubhubbub' => FALSE,
'designated_hub' => '',
'request_timeout' => NULL,
'auto_scheme' => 'http',
'accept_invalid_cert' => FALSE,
),
),
'parser' => array(
'plugin_key' => 'FeedsXPathParserXML',
'config' => array(
'sources' => array(
'xpathparser:0' => 'guid',
'xpathparser:1' => 'title',
'xpathparser:2' => 'description',
'xpathparser:3' => '*[name()=\'media:thumbnail\']/@url',
),
'rawXML' => array(
'xpathparser:0' => 0,
'xpathparser:1' => 0,
'xpathparser:2' => 0,
'xpathparser:3' => 0,
),
'context' => '//item',
'exp' => array(
'errors' => 1,
'tidy' => 0,
'tidy_encoding' => 'UTF8',
'debug' => array(
'context' => 0,
'xpathparser:0' => 0,
'xpathparser:1' => 0,
'xpathparser:2' => 0,
'xpathparser:3' => 0,
),
),
'allow_override' => 1,
),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'expire' => '-1',
'author' => 0,
'authorize' => 1,
'mappings' => array(
0 => array(
'source' => 'xpathparser:0',
'target' => 'guid',
'unique' => 1,
),
1 => array(
'source' => 'xpathparser:1',
'target' => 'title',
'unique' => FALSE,
),
2 => array(
'source' => 'xpathparser:2',
'target' => 'body',
'unique' => FALSE,
),
3 => array(
'source' => 'xpathparser:3',
'target' => 'field_image:uri',
'unique' => FALSE,
),
),
'update_existing' => '1',
'input_format' => 'plain_text',
'skip_hash_check' => 0,
'bundle' => 'article',
'update_non_existent' => 'skip',
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
'process_in_background' => 0,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment