File tree 3 files changed +7
-0
lines changed
3 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ ACCESS_ID=cca
2
2
API_KEY = " secret..."
3
3
HOST = api.summon.serialssolutions.com
4
4
KOHA_DOMAIN = library.cca.edu
5
+ LINKCHECK_LIMIT = 500
5
6
LINKCHECK_LOGFILE = data/linkcheck.log
6
7
LINKCHECK_REPORT = " https://library.cca.edu/cgi-bin/koha/svc/report?id=345"
7
8
LINKCHECK_OPAC_URL = " https://library.cca.edu/cgi-bin/koha/opac-detail.pl?biblionumber={id}"
Original file line number Diff line number Diff line change @@ -42,13 +42,17 @@ def quote(list):
42
42
43
43
44
44
def main () -> None :
45
+ count = 0
45
46
report = httpx .get (config ["LINKCHECK_REPORT" ])
46
47
for bib in report .json ():
47
48
# bibs are arrays like [urls string, title, biblionumber]
48
49
urls , title , id = bib
49
50
# urls are separated by " | "
50
51
urls = urls .split (" | " )
51
52
for url in urls :
53
+ count += 1
54
+ if config .get ("LINKCHECK_LIMIT" ) and count > int (config ["LINKCHECK_LIMIT" ]):
55
+ break
52
56
try :
53
57
r = httpx .get (url , follow_redirects = True )
54
58
status = r .status_code
@@ -108,3 +112,4 @@ def signal_handler(sig, frame) -> None:
108
112
# TODO but the script keeps running
109
113
signal .signal (signal .SIGINT , signal_handler )
110
114
main ()
115
+ summarize ()
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ Takes a public Koha report and checks each URL (`856$u`) to see if they resolve
6
6
7
7
The script uses the same .env file as the root project or it can take environment variables.
8
8
9
+ - ` LINKCHECK_LIMIT ` number of links to check (leave undefined for all of them)
9
10
- ` LINKCHECK_REPORT ` URL to a Koha report that returns item URLs (see [ report.sql] ( ./report.sql ) ). Report must be Public.
10
11
- ` LINKCHECK_OPAC_URL ` catalog link for individual records, should include ` biblionumber={id} ` in it (id is interpolated)
11
12
- ` LINKCHECK_LOGFILE ` path to logged CSV, defaults to the data dir named "YYYY-MM-DD-linkcheck.csv" with today's date
You can’t perform that action at this time.
0 commit comments