Created
August 22, 2019 01:19
-
-
Save akky/e0eb75db902798c9b3c1ab3dee70d551 to your computer and use it in GitHub Desktop.
convert exported scuttle data to WordPress delicious import xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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