Skip to content

Instantly share code, notes, and snippets.

@akky
Created August 22, 2019 01:19
Show Gist options
  • Save akky/e0eb75db902798c9b3c1ab3dee70d551 to your computer and use it in GitHub Desktop.
Save akky/e0eb75db902798c9b3c1ab3dee70d551 to your computer and use it in GitHub Desktop.
convert exported scuttle data to WordPress delicious import xml
<?php
// exported scuttle data by qstode-scuttle-export tool
$url = 'scuttle-export.json';
$json = file_get_contents($url);
$scuttleData = json_decode($json, true);
//var_dump($scuttleData);
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
// I only have one user on scuttle so this code does not handle multiple users import
$username = $scuttleData['users'][0]['name'];
$bookmarks = $scuttleData['users'][0]['bookmarks'];
$num_of_bookmarks = count($bookmarks);
echo '<posts tag="" total="' . $num_of_bookmarks . '" user="' . $username . '">' . PHP_EOL;
foreach ($bookmarks as $index => $bookmark) {
$createdAt = $bookmark['created_at'];
$href = htmlspecialchars($bookmark['url'], ENT_COMPAT, 'UTF-8');
$description = htmlspecialchars($bookmark['title'], ENT_COMPAT, 'UTF-8');
$extended = htmlspecialchars($bookmark['description'], ENT_COMPAT, 'UTF-8');
$hash = $bookmark['hash'];
$tags = htmlspecialchars(implode(' ', $bookmark['tags']), ENT_COMPAT, 'UTF-8');
echo "<post description=\"$description\" extended=\"$extended\" hash=\"$hash\" href=\"$href\" private=\"no\" shared=\"yes\" tag=\"$tags\" time=\"$createdAt\" />";
}
echo '</posts>' . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment