Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a feed (parsed via the simpliepie parser) which provides the the feed information as below.
I would like to be able to map the options->enclosures->video->x-m4v->link
to a custom cck field, but the mapping through the feed element mapper is only giving me options->enclosures->video->x-m4v
.
Is there a way to get the mapping to drill down further into the array?
I'd really appreciate any help available.
Array
(
[title] => The Sketchup Show #50 - Using Antics 3D with SketchUp Models for Previsualization
[description] => Alex brings Brad from Antics Technologies into the studio to discuss how Antics 3D animation software can interface with SketchUp to bring your models to life. If you know us, you know that we ...
[options] => Array
(
[original_url] => http://atotheo.libsyn.com/index.php?post_id=293230
[timestamp] => 1199431260
[guid] => http://atotheo.libsyn.com/index.php?post_id=293230#
[original_author] => Array
(
[name] => School
[link] =>
[email] =>
)
[enclosures] => Array
(
[video] => Array
(
[x-m4v] => Array
(
[0] => Array
(
[bitrate] =>
[captions] =>
[categories] => Array
(
[0] => Array
(
[term] =>
[scheme] => http://www.itunes.com/dtds/podcast-1.0.dtd
[label] => Technology
)
[1] => Array
(
[term] =>
[scheme] => http://www.itunes.com/dtds/podcast-1.0.dtd
[label] => Software How-To
)
[2] => Array
(
[term] =>
[scheme] => http://www.itunes.com/dtds/podcast-1.0.dtd
[label] => Education
)
[3] => Array
(
[term] =>
[scheme] => http://www.itunes.com/dtds/podcast-1.0.dtd
[label] => Training
)
)
[channels] =>
[copyright] =>
[credits] =>
[description] =>
[duration] => 1496
[expression] =>
[framerate] =>
[handler] => quicktime
[hashes] =>
[height] =>
[javascript] => js
[keywords] => Array
(
[0] => Google
[1] => Apple
[2] => SketchUp
[3] => Google Earth
[4] => Film
[5] => production
[6] => Google 3D Warehouse
[7] => Digital
[8] => VFX
[9] => Pixel
[10] => Antics
[11] => Design
[12] => Art
[13] => 3D
)
[lang] =>
[length] => 221901298
[link] => http://media.libsyn.com/media/atotheo/school_tss_041_m4v_640.m4v
[medium] =>
[player] =>
[ratings] => Array
(
[0] => Array
(
[scheme] => urn:itunes
[value] => Clean
)
)
[restrictions] =>
[samplingrate] =>
[thumbnails] =>
[title] =>
[type] => application/octet-stream
[width] =>
)
)
[quicktime] => Array
(
[0] => Array
(
[bitrate] =>
[captions] =>
[categories] => Array
(
[0] => Array
(
[term] =>
[scheme] => http://www.itunes.com/dtds/podcast-1.0.dtd
[label] => Technology
)
[1] => Array
(
[term] =>
[scheme] => http://www.itunes.com/dtds/podcast-1.0.dtd
[label] => Software How-To
)
[2] => Array
(
[term] =>
[scheme] => http://www.itunes.com/dtds/podcast-1.0.dtd
[label] => Education
)
[3] => Array
(
[term] =>
[scheme] => http://www.itunes.com/dtds/podcast-1.0.dtd
[label] => Training
)
)
[channels] =>
[copyright] =>
[credits] =>
[description] =>
[duration] =>
[expression] =>
[framerate] =>
[handler] => quicktime
[hashes] =>
[height] =>
[javascript] => js
[keywords] => Array
(
[0] => Google
[1] => Apple
[2] => SketchUp
[3] => Earth
[4] => Google Earth
[5] => Google Maps
[6] => Google 3D Warehouse
[7] => Digital
[8] => VFX
[9] => Pixel
[10] => Photoshop
[11] => Design
[12] => Art
[13] => 3D
)
[lang] =>
[length] => 143873392
[link] => http://media.libsyn.com/media/atotheo/sksh_cirlcelTool_ipod_04.mov
[medium] =>
[player] =>
[ratings] => Array
(
[0] => Array
(
[scheme] => urn:itunes
[value] => Clean
)
)
[restrictions] =>
[samplingrate] =>
[thumbnails] =>
[title] =>
[type] => video/quicktime
[width] =>
)
)
)
)
[domains] =>
[tags] => Array
(
[0] => Technology
)
[raw] => Array
(
[title] => The Sketchup Show #50 - Using Antics 3D with SketchUp Models for Previsualization
[link] => http://atotheo.libsyn.com/index.php?post_id=396146#
[description] => Alex brings Brad from Antics Technologies into the studio to discuss how Antics 3D animation software can interface with SketchUp to bring your models to life. If you know us, you know that ...
[category] => Technology
[pubDate] => Fri, 24 Oct 2008 19:22:00 GMT
[guid] => http://atotheo.libsyn.com/index.php?post_id=396146#
[enclosure] =>
)
)
)
Comment | File | Size | Author |
---|---|---|---|
#16 | feedapi_enc_link.patch | 625 bytes | kswan |
Comments
Comment #1
benced CreditAttribution: benced commentedI'd like this too am going to look into the code to see why it is restricted to three steps down the heirarchy of the array
Comment #2
benced CreditAttribution: benced commentedFound what's blocking it
These lines here
i.e. anything stuck under an array beginning with
[0] => Array
will not come up as an option
Will try deleting these lines of code and see what happens, I'm sure there is probably a reason why this is there though :S
Comment #3
benced CreditAttribution: benced commentedI'm guessing this was done to save on memory as the element mapper seems to use a lot of memory (esp after selecting the Simplepie Parser)
I've tried removing these lines of code and eventually had to extend my php memory limit to 1024M and there still was not enough memory to run the script, I'm hesitant to try extending it further
I've tried adding the selection using PhpMyAdmin with no luck yet
I've tried a few things including adding a custom default option, which didn't work
I think this may be because it merges all the feed items into one item and if I could find a way to switch that off and for the map to map just one feed item, which breifly looking at the code I can't find a way of doing this despite there being some suggestions that you can, then removing the lines of code might be able to work without taking too long or using too much memory
Anyone else know how to do this?
Comment #4
benced CreditAttribution: benced commentedGoing to try using this method instead -> http://drupal.org/node/170338
Comment #5
benced CreditAttribution: benced commentedProblem solved
In between line 188 and 189 in the simple parser module I added this
$curr_item->enclosure_link = $simplepie_item->get_enclosure()->get_link();
Now I can map this using the mapping interface to map the link to the enclosure item wherever I want to embed in a player, to display, whatever...
Comment #6
benced CreditAttribution: benced commentedChanging to what my settings are,
Perhaps someone can make a version up for Drupal 6
Comment #7
benced CreditAttribution: benced commentedCode now wrapped in an if statement so that the link isn't searched for when it don't exist
Comment #8
bigjim CreditAttribution: bigjim commentedUsing feedapi 6.x.1.6 #7 works except insert it at line 155 in lieu of 188
Comment #9
ball.in.th CreditAttribution: ball.in.th commentedHi,
I think the proper way to do this is for the mapper to handle an array of elements. You can just pick "options->enclosures->video->x-m4v", and the mapper should see that it's an array and maps properly. If it doesn't, perhaps its a bug in the mapper. For example, see the feedapi_mapper_emimage.inc:
Comment #10
alienresident CreditAttribution: alienresident commentedI also had to make this change to map .mp3 enclosure for a feed directly from iTunes itself.
Thanks for the code it worked like a charm.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedAn even better way would be to allow a custom mapping, instead of the fixed dropdown. For example, a textfield to enter:
options->enclosures->image->jpeg->0->link
which can be mapped to a custom cck field.That would accomodate for every possibility...
Comment #12
mickfuzz CreditAttribution: mickfuzz commentedI've got a situation pretty much exactly the same but with an Audio file.
What is the code in #7 that you added supposed to do benced?
I've added it but can't see any extra elements in the mapper. Only as you point out upto the
[0] => Array - point
It would be good to find out what the deal is.
Comment #13
dman CreditAttribution: dman commentedRE #11
FYI, I just found feedapi_parser_exhaustive which exposes every bit of data in the feed in a structured way for you to choose from.
It's not as 'clever' as the other ones like simplepie or FeedAPI Extensible Parser that strictly offer an interpreted subset of the half-dozen feed formats out there. This one just throws all the data back at you. Cherry-pick the field from an exposed array. No code.
Also handy for non-standard 'extensions' to RSS!
Comment #14
whatdoesitwant CreditAttribution: whatdoesitwant commentedThanks dman. I was wondering what was causing all my errors. I did not understand from the documentation that feedapi_parser_exhaustive and simplepie parser are interchangable and not supposed to be used additionally like feedapi_scraper. The activation of feedapi_node results in the suggestion to install parser simplepie. I therefore assumed feedapi_node and parser simplepie to be joined at the hip. I then assumed that feedapi_parser_exhaustive was an add on to parser simplepie. This is a misconception.
Am I correct in stating the following?
Within the feedapi package, in a nutshell you can install:
Comment #15
dman CreditAttribution: dman commentedThat's a pretty good explanation of my understanding ... although the first time I saw the suite at all was yesterday :-)
We need a nice big picture of the jigsaw.
Slightly disconcerting is how feed parsers may not have settings that show up (not all need them) on the feed-nod form so it's tricky to tell when they are enabled and working.
I'm still unsure on the exclusiveness of the base+add-on parsers ... and what effect the weight has when they don't over-write each other anyway, but I've created a recipe that fits for me... for now.
Comment #16
kswan CreditAttribution: kswan commentedI think that the normal use for the "enclosure" tag is to get the file url. The attached patch adds an "enclosure_link" item to the "Feed items" so that you can easily map the enclosure url to a text or link field.
Comment #17
dman CreditAttribution: dman commentedNice, trivial, handy addition.