I've been using the FeedAPI in a couple sites, and have done a couple writeups about it on my blog over at OpenAcademic -- this, along with the FeedAPI, is some amazing code.

I've been looking at how delicious tags are imported -- given that delicious uses spaces and not commas to separate their terms, delicious feeds get imported as one long series of words.

How difficult would it be to set up a condition that treated feeds from delicious differently than feeds from other sources? Would this be best implemented as a helper module to the Feed Element Mapper, or as a patch to the FEMP?

If this is a patch you would want to include, let me know -- if we get some free time over the next few days/weeks, we could take a shot at this.

Cheers,

Bill

Comments

yellek’s picture

Someone already implemented this for simplepie. If someone can figure out how to include the proper inc file this could be fixed very quickly: http://simplepie.org/wiki/addons/del.icio.us.

Can someone tell me where to add the include for this file in the current feedapi module?

alex_b’s picture

Title: Delicious feeds » Tags from delicious feeds
Project: Feed Element Mapper » FeedAPI
Version: 5.x-1.0-beta4 » 5.x-1.x-dev

Hey Bill,

This issue should be solved on the FeedAPI level. The tags in (I hope I remember the location correctly) ->options->tags should be always split up correctly.

I haven't experimented with delicious feeds yet. Maybe the solution that yellek points to just works. Not knowing how exactly to include simple pie add ons, FeedAPI's parser_simplepie.module would be the place to include it in.

I would appreciate any experiences/feedback here. I will push this issue to FeedAPI.

Thanks for your help,

Alex

bonobo’s picture

Hello, Alex,

I'll experiment with this a bit more, and try to isolate things down a bit -- I think it has to do with delicious tags being separated with a space, and not a comma --

At least, that's the only difference I've seen so far -- on the various test sites where I've set up the feedapi and the mapper, the only site I've had these issues with is delicious, and I've pulled in tags from a few hundred different feeds in various testing scenarios.

I'll hammer on the delicious issue in a more systematic way, and report back here.

Thanks,

Bill

yellek’s picture

I did some experimentation with this and managed to get it to work. As this is the first time I have ever written PHP please let me know if I am making beginner mistakes.

Steps required:

  1. Create a simplepie_delicious.inc file in the feedapi/parser_simplepie directory
  2. Copy the PHP code from http://simplepie.org/wiki/addons/del.icio.us#add-on_source_code into the file and save it
  3. Edit feedapi/parser_simplepie/simplepie.module (edited source shown below)
  4. After line 181 add the line require_once(drupal_get_path('module', 'parser_simplepie') .'/simplepie_delicious.inc');
  5. Add the line $parser->set_item_class('SimplePie_Item_Delicious');

The complete modified function is below:

/**
 * Set SimplePie setting
 * @param $url
 *  The feed's url
 * @return
 *  SimplePie object
 */
function _parser_simplepie_get_parser($url) {
  require_once(drupal_get_path('module', 'parser_simplepie') .'/simplepie.inc');
  require_once(drupal_get_path('module', 'parser_simplepie') .'/simplepie_delicious.inc');
  $parser = new SimplePie();
  $parser->set_feed_url($url);
  $parser->set_timeout(15);
  $parser->set_stupidly_fast(TRUE);
  $parser->encode_instead_of_strip(FALSE);
  $cache_location = _parser_simplepie_sanitize_cache();
  $parser->enable_cache($cache_location !== FALSE ? TRUE : FALSE);
  $parser->set_cache_location($cache_location);
  $parser->set_item_class('SimplePie_Item_Delicious');
  $parser->init();
  return $parser;
}

This works for me but I will leave it to more experienced PHP coders to tidy it up for inclusion in the source.

jgraham’s picture

yellek

At a quick glance this seems it would interpret all simplepie feeds as though they were delicious feeds ie. spaced instead of commas.

I think this is a very good first step but I believe it needs a bit more work on the internals so that feeds are optionally (and appropriately) interpreted in the 'delicious' format. I'm not sure what the best method for that is; right now all that is coming to mind is a whitelist by type/url, or a select choice when the user sets the feed. I think the user selectable option is better as it is more extensible, but hiding unnecessary options from users is always good too.

I'm digging to see if there is a way to appropriately detect the format on the backend and optionally include 'simplepie_delicious.inc' and call $parser->set_item_class('SimplePie_Item_Delicious'); this would avoid exposing an unnecessary option to the user.

From a quick look the only obvious thing I'm seeing is the url, but that is a kludgey way to do it that would suggest a user option is much better.

Will post back as new info becomes available.

SamRose’s picture

Status: Active » Needs review
StatusFileSize
new870 bytes
new1.08 KB

Well, just for the heck of it, attached are patch and the simplepie_delicious.inc files to build off of

SamRose’s picture

The funny thing is, I can't actually get this to *work*...