-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.py
More file actions
48 lines (36 loc) · 1.19 KB
/
list.py
File metadata and controls
48 lines (36 loc) · 1.19 KB
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
import os
INPUT_FILE = "found_urls.txt"
IMAGE_DIR = "images"
OUTPUT_FILE = "README.md"
header = """\
scrape every fuckin BMA traffic camera
I don’t get their fuckass camera IDs, so I'm just gonna brute-force that shit.
these are photos:
"""
table_header = "| Image | URL |\n|-------|-----|"
def get_filename_from_url(url):
return url.strip().split("/")[-1]
def generate_row(image_filename, url):
return f"|  | [{url}]({url}) |"
def main():
if not os.path.exists(INPUT_FILE):
print("No found_urls.txt found.")
return
rows = []
with open(INPUT_FILE, "r") as f:
for line in f:
url = line.strip()
if not url:
continue
filename = get_filename_from_url(url)
local_path = os.path.join(IMAGE_DIR, filename)
if os.path.exists(local_path):
rows.append(generate_row(filename, url))
with open(OUTPUT_FILE, "w") as out:
out.write(header + "\n")
out.write(table_header + "\n")
for row in rows:
out.write(row + "\n")
print(f"README.md generated with {len(rows)} images.")
if __name__ == "__main__":
main()