diff --git a/scripts/update_numerique_premium_visibility.php b/scripts/update_numerique_premium_visibility.php new file mode 100644 index 0000000000000000000000000000000000000000..5fc9ceef6a67da9c42af806ee9e7b3941de6f869 --- /dev/null +++ b/scripts/update_numerique_premium_visibility.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +require('console.php'); +setupOpac(); + +$sql = "UPDATE album SET visible = 0 WHERE url_origine LIKE '%numeriquepremium.com%';"; +sqlExecute($sql); + +if ($argc <= 1) { + echo "Usage: $argv[0] URL [URL...]\n"; + exit; +} +array_shift($argv); + +foreach ($argv as $url) { + process_url($url); +} + +function process_url($url) { + file_put_contents('/tmp/marc.mrc', file_get_contents($url)); + exec('yaz-marcdump /tmp/marc.mrc | grep ^073 | cut -c 11-', $output); + + $sql = "UPDATE album SET visible = 1 WHERE id_origine IN (" . implode(',', $output) . ");"; + sqlExecute($sql); +} + +?>