#!/usr/bin/env php 2) { die("Usage: lilybin [-adm] file [file]\n"); } $all = isset($opts['a']); $download = isset($opts['d']); $midi = isset($opts['m']); if ($midi) { $ext = '.midi'; } else { $ext = '.pdf'; } if ($all || !$download) { $url = 'https://7icpm9qr6a.execute-api.us-west-2.amazonaws.com/prod/prepare_preview/stable'; $result = json_decode(do_curl($url, [ CURLOPT_HTTPHEADER => ['Content-Type: application/json'], CURLOPT_POST => 1, CURLOPT_POSTFIELDS => json_encode(['code' => file_get_contents($files[0])]), CURLOPT_RETURNTRANSFER => true, ])); if (!$result->id) { echo "ERROR:\n", $result->stderr; exit(1); } if ($all) { $files[0] = $result->id . $ext; } else { echo $argv[0], ' -d ', $result->id, $ext . "\n"; exit; } } if ($all || $download) { $url = 'https://s3-us-west-2.amazonaws.com/lilybin-scores/' . $files[0]; $file = fopen(@$files[1] ?: $files[0], 'w'); do_curl($url, [CURLOPT_FILE => $file]); fclose($file); }