Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

download.php can be run for a single addon

  • Loading branch information...
commit d635dab7f3b76db1530dc23ef90cfe7bf48185ac 1 parent 8bbd44b
Krzysztof Kotowicz authored

Showing 1 changed file with 17 additions and 4 deletions. Show diff stats Hide diff stats

  1. +17 4 chrome-addons/download.php
21 chrome-addons/download.php
... ... @@ -1,7 +1,11 @@
1 1 <?php
2 2 /*
3 3 downloads & unpacks addons listed in standard input JSON feed
4   -Usage: php download.php < addons.json
  4 +Usage:
  5 +
  6 + php download.php < addons.json
  7 + php download.php <addon-guid> <addon-name>
  8 +
5 9 Req: openssl extension, unzip command line
6 10
7 11 @author Krzysztof Kotowicz kkotowicz<at>gmail<dot>com
@@ -9,11 +13,20 @@
9 13
10 14 */
11 15
12   -$f = file_get_contents('php://stdin');
13   -$addons = json_decode($f);
14 16 $output_dir = 'addons';
15 17 $skip_existing = true;
16 18
  19 +// command line support
  20 +if (count($argv) == 3) {
  21 + $addons = array($argv[1] => $argv[2]);
  22 + $skip_existing = false;
  23 +} else {
  24 + $f = file_get_contents('php://stdin');
  25 + $addons = json_decode($f);
  26 +}
  27 +
  28 +
  29 +
17 30 while (list($k, $v) = each($addons)) {
18 31 download($k, $v);
19 32 }
@@ -39,6 +52,6 @@ function download($id, $name) {
39 52 file_put_contents($dir . DIRECTORY_SEPARATOR . $id. '.crx', $crx);
40 53 echo "Saving " . strlen($crx) . " bytes to $dir\n";
41 54 echo "Unpacking...";
42   - shell_exec("unzip $dir/$id.crx -d $dir");
  55 + shell_exec("unzip -o $dir/$id.crx -d $dir");
43 56 }
44 57 }

0 comments on commit d635dab

Please sign in to comment.
Something went wrong with that request. Please try again.