-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_checker.py
33 lines (28 loc) · 1.28 KB
/
image_checker.py
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
import csv
import requests
import logging
# Set up logging to a file
logging.basicConfig(filename='missing_images.log', level=logging.INFO,
format='%(asctime)s - %(message)s')
def check_image_exists(url):
try:
response = requests.head(url)
print(f"Response code: {response.status_code}\n")
return response.status_code == 200
except Exception as e:
logging.info(f"Error checking URL: {url}. Error: {e}")
return False
def process_csv(csv_file):
with open(csv_file, mode='r', newline='', encoding='utf-8') as file:
reader = csv.DictReader(file)
for row in reader:
iiif_ids = row.get('I Tatti file name(s)', '').split(',')
for image_id in iiif_ids:
image_id = image_id.strip() # Clean up extra spaces
iiif_url = f"https://iiif.itatti.harvard.edu/iiif/2/bellegreene-full!{image_id}.jpg/full/full/0/default.jpg"
print(f"Checking image ID: {image_id}")
if not check_image_exists(iiif_url):
logging.info(f"Image not found for ID: {image_id}. URL: {iiif_url}")
if __name__ == "__main__":
csv_file = 'BG to BB Letters_Spreadsheet - Sheet1.csv' # Replace with the path to your CSV file
process_csv(csv_file)