Permalink
Browse files

download.php can be run for a single addon

  • Loading branch information...
1 parent 8bbd44b commit d635dab7f3b76db1530dc23ef90cfe7bf48185ac @koto committed Mar 27, 2012
Showing with 17 additions and 4 deletions.
  1. +17 −4 chrome-addons/download.php
View
21 chrome-addons/download.php
@@ -1,19 +1,32 @@
<?php
/*
downloads & unpacks addons listed in standard input JSON feed
-Usage: php download.php < addons.json
+Usage:
+
+ php download.php < addons.json
+ php download.php <addon-guid> <addon-name>
+
Req: openssl extension, unzip command line
@author Krzysztof Kotowicz kkotowicz<at>gmail<dot>com
@see http://blog.kotowicz.net
*/
-$f = file_get_contents('php://stdin');
-$addons = json_decode($f);
$output_dir = 'addons';
$skip_existing = true;
+// command line support
+if (count($argv) == 3) {
+ $addons = array($argv[1] => $argv[2]);
+ $skip_existing = false;
+} else {
+ $f = file_get_contents('php://stdin');
+ $addons = json_decode($f);
+}
+
+
+
while (list($k, $v) = each($addons)) {
download($k, $v);
}
@@ -39,6 +52,6 @@ function download($id, $name) {
file_put_contents($dir . DIRECTORY_SEPARATOR . $id. '.crx', $crx);
echo "Saving " . strlen($crx) . " bytes to $dir\n";
echo "Unpacking...";
- shell_exec("unzip $dir/$id.crx -d $dir");
+ shell_exec("unzip -o $dir/$id.crx -d $dir");
}
}

0 comments on commit d635dab

Please sign in to comment.