Created
February 22, 2017 14:45
-
-
Save davidmz/1a1a0e7d3f32a6be23e113d43e1efc37 to your computer and use it in GitHub Desktop.
Short link extractor for Friendfeed archives
This file contains 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 | |
if ($argc !== 2) { | |
echo "Usage:\n"; | |
echo "php collect-links.php /ARCHIVES/FOLDER > links.txt\n"; | |
exit; | |
} | |
$archFolder = realpath($argv[1]); | |
if (!is_dir($archFolder)) { | |
echo "Usage:\n"; | |
echo "php collect-links.php /ARCHIVES/FOLDER > links.txt\n"; | |
exit; | |
} | |
$dirNames = scandir($archFolder); | |
foreach ($dirNames as $dirName) { | |
if ($dirName === ".." || $dirName === ".") { | |
continue; | |
} | |
$linksDir = $archFolder."/".$dirName."/links/ff.im"; | |
if (!file_exists($linksDir)) { | |
continue; | |
} | |
foreach (scandir($linksDir) as $file) { | |
if (!preg_match('/^(\w+)\.json$/', $file, $m)) { | |
continue; | |
} | |
$json = json_decode(file_get_contents($linksDir."/".$file)); | |
if ($json->errorCode) { | |
continue; | |
} | |
echo $m[1]."\t".substr($json->id, 2, 8)."\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment