This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtestURL.php
83 lines (68 loc) · 1.79 KB
/
testURL.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
// testURL.php
require_once('SharedShelfService.php');
require_once('SharedShelfToSolrLogger.php');
function usage() {
global $argv;
echo PHP_EOL;
echo "Usage: php " . $argv[0] . " [--help] [-a NNN]" . PHP_EOL;
echo "--help - show this info" . PHP_EOL;
echo "-a - process SharedShelf asset ID NNN (NNN must be numeric)" . PHP_EOL;
exit (0);
}
$log = FALSE;
try {
$options = getopt("a:",array("help"));
if ($options === false || isset($options['help'])) {
usage();
}
$ss_id = 3317772;
if (isset($options['a'])) {
if (is_numeric($options['a'])) {
$ss_id = $options['a'];
}
else {
usage();
}
}
// batch process information
$task = parse_ini_file("sharedshelf-to-solr.ini", TRUE);
if ($task === FALSE) {
echo "Need sharedshelf-to-solr.ini\n";
exit (1);
}
// open log
if (empty($task['process']['log_file_prefix'])) {
echo "Need log_file_prefix\n";
exit (1);
}
$log = new SharedShelfToSolrLogger($task['process']['log_file_prefix']);
$log->task('ssUser');
// sharedshelf user
$user = parse_ini_file('ssUser.ini');
if ($user === FALSE) {
throw new Exception("Need to create ssUser.ini. See README.md", 1);
}
if (!isset($task['process']['cookie_jar_path'])) {
throw new Exception("Expecting cookie_jar_path in .ini file", 1);
}
$log->task('SharedShelfService');
$ss = new SharedShelfService($user['email'], $user['password'], $task['process']['cookie_jar_path']);
echo $url, "\n";
$iiif_info = $ss->media_iiif_info($ss_id);
print_r($iiif_info);
$url = $ss->media_url($ss_id);
echo $url, "\n";
echo "\n\n";
}
catch (Exception $e) {
$error = 'Caught exception: ' . $e->getMessage() . "\n";
if ($log !== FALSE) {
$log->error($error);
}
else {
echo $error;
}
exit (1);
}
exit (0);