Topic: Tip: Delicious-TaggedFrog-import
(Hope thats ok for you, Andrei)
Here's a litte approach to map delicious tagged bookmarks into a TaggedFrog import csv file. The script runs on php and uses the public rss feed of delicious (no login needed, only the delicious account name to create the rss lookup path). It will create a csv import format (and sends it, if you set $bDownload = true; , otherwise it will show the content in the browser window).
1. You need a webserver/hosting with php5 or a local php installation like xampp.
2. fopen wrappers must be enabled to allow DOMDocument to read your Delicious feed directly
3. if local - your firewall must allow PHP to make a outgoing connection
4. you need to configure your delicious user name and - if needed - more data in the script below
5. not sure if somethings missing - if it fails (e.g. problems with charsets) please leave a message
6. all without guarantee
Hope it will make it.. It works for me
One more tip: TaggedFrog doesn't support titles for bookmarks in the current import format. It will try to connect all imported urls directly and extract its titles from the HTML.
If you like to use your own titles out of Delicious,
Please support my feature request about it:
http://taggedfrog.uservoice.com/forums/ ?ref=titleuse the following workaround (inconvenient for large bookmark collections):
1. Open your Delicious Account or its RSS Feed
2. Drag the first Bookmark onto the TaggedFrog window. The add dialog will appear.
3. Use a tag - e.g. "*" to specify at least one needed Tag (all others you'll get by the import)
4. Drag all other tags into the list of the add dialog
5. Do the export/import as written above.
6. Rename or delete the given Tag ("*"). Be sure, every Bookmark has at least one more tag or it will be deleted with the last one.
You only need to d'n'd that bookmarks with user customized titles. All others will get its titles by the HTML-based title.
<?php
header ('Content-Type:text/html;charset=utf-8');
// specify your delicious username here (uses feed as input)
$sName = 'myBkmrks'; // for http://www.delicious.com/myBkmrks/
// specify your feed item maximum here
$iMax = 1500;
// specify here, if you want to get the "download dialog" from your browser
$bDownload = true;
// specify your mapping here
// replace delicious_tag => by_taggedfrog_tag
// you can setup tag deleting by add mappings like delicious_tag => NULL
$aTagMapping
= array (
'lang:en' => '[en]' ,
'boring' => NULL ,
);
// add your replacements here, characters or full strings are possible
// replace string => by_string
$aReplacements
= array (
',' => '/' ,
';' => '/' ,
'·' => ' ' ,
);
// specify tags that you want to add for every bookmark here
// e.g. the name of the feed
$aAdditionalTags
= array (
'delicious.myBkmrks' ,
'online' ,
);
/*
Tagging works in that order:
read feed -> mapping -> replacements -> additional
So make sure, you have
1. specified replacement for comma and semicolon - delicious allows comma in
tag names, csv uses semicolon as field separator
2. none of that characters in the addional tags
*/
$sFile = 'http://feeds.delicious.com/v2/rss/' . $sName . '?count=' . (int) $iMax;
$oDocument = new DOMDocument;
// uses remote files
// make sure fopen wrappers have been enabled
if (false === @ $oDocument->load ($sFile))
{
die ('file i/o error');
}
$oXPath = new DOMXPath ($oDocument);
$sQuery = '//channel/item';
if (false !== $aItems = $oXPath->query ($sQuery))
{
$aImport = array ();
foreach ($aItems as $oNode)
{
$aNode = array (
// maybe someday :)
// 'title' => $oNode->getElementsByTagName ('title')->item(0)->nodeValue ,
'url' => $oNode->getElementsByTagName ('link')->item(0)->nodeValue ,
'tags' => $aAdditionalTags ,
);
foreach ($oNode->getElementsByTagName ('category') as $oTagNode)
{
$sTag = $oTagNode->nodeValue;
if (array_key_exists ($sTag , $aTagMapping))
{
$sTag = $aTagMapping[$sTag];
}
$aNode['tags'][] = strtr ($sTag , $aReplacements);
}
$aNode['tags'] = array_filter ($aNode['tags']);
$aImport[] = $aNode;
}
}
if (isset ($bDownload) && true === $bDownload)
{
$sName = preg_replace ('/[^\w\d]/' , '_' , $sName);
header('Content-Disposition: attachment; filename="delicious_import_' . $sName . '.csv"');
}
foreach ($aImport as $aEntry)
{
printf (
"url;%s;%s\n" ,
$aEntry['url'] ,
implode (';' , $aEntry['tags'])
);
}


