protected function execute(InputInterface $input, OutputInterface $output) { $deps = $this->getApplication()->getDependancies(); $client = $deps['openphoto']; $logger = $deps['logger']; $tag = $input->getArgument('existing-tag'); $hashs = getHashs($client, $logger, $tag); $total = count($hashs); $cpt = 0; $updated = 0; $logger->log(sprintf('%s photos tagged with "%s"', count($hashs), $tag)); foreach (array_keys($hashs) as $idPhoto) { $cpt++; $position = sprintf('[%s/%s]', str_pad($cpt, strlen($total), '0', STR_PAD_LEFT), $total); $response = $client->post(sprintf("/photo/%s/update.json", $idPhoto), $this->getUpdateParameters($input, $idPhoto)); $dResponse = json_decode($response); $logger->log(sprintf('%s Updating photo "%s"...', $position, $idPhoto)); if (false !== $dResponse) { if (false === $dResponse->result) { $logger->log(sprintf('%s [error] Error updating photo', $position)); continue; } } $updated++; $logger->log($this->getEndLog($input, $position, $idPhoto)); } $logger->log(sprintf('%s photos updated', $cpt++)); }
protected function execute(InputInterface $input, OutputInterface $output) { $deps = $this->getApplication()->getDependancies(); $client = $deps['openphoto']; $logger = $deps['logger']; $dir = $input->getArgument('folder'); ini_set('memory_limit', '1G'); $hashs = getHashs($client, $logger); $paths = getPaths($dir); $cpt = 0; $logger->log(sprintf('%s photos on openphoto', count($hashs))); $logger->setTotal(count($paths)); foreach ($paths as $pathName) { $cpt++; $logger->setPosition($cpt); uploadFile($client, $logger, $deps['exiftran.path'], $hashs, $pathName); } $logger->setTotal(null); $newHashs = getHashs($client, $logger); $logger->log(sprintf('%s photos added', count($newHashs) - count($hashs))); $logger->log(sprintf('%s photos now on openphoto', count($hashs))); }