-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetFA.py
50 lines (40 loc) · 1.63 KB
/
getFA.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests
import json
import re
def clean_icon_name(name):
# Remove 'fa' prefix and '.js' suffix
name = name.replace('fa', '').replace('.js', '')
# Convert to kebab case if it's not already
return name if '-' in name else re.sub(r'(?<!^)(?=[A-Z])', '-', name).lower()
def get_free_icons():
categories = {
'solid': 'free-solid-svg-icons',
'regular': 'free-regular-svg-icons',
'brands': 'free-brands-svg-icons'
}
icons = {}
for category, repo in categories.items():
url = f'https://api.github.com/repos/FortAwesome/Font-Awesome/contents/js-packages/@fortawesome/{repo}'
response = requests.get(url)
data = response.json()
# Filter and clean icon names
icons[category] = [
clean_icon_name(file['name'])
for file in data
if file['name'].endswith('.js')
and file['name'] != 'index.js'
and not file['name'].replace('fa', '').replace('.js', '').isdigit() # Filter out numeric names
]
# Sort alphabetically
icons[category].sort()
return icons
if __name__ == '__main__':
icons = get_free_icons()
# Save as JSON with nice formatting
with open('fa_free_icons.json', 'w', encoding='utf-8') as f:
json.dump(icons, f, indent=2, ensure_ascii=False)
# Print summary
for category, icon_list in icons.items():
print(f"{category}: {len(icon_list)} icons")
# Print first few icons as examples
print(f"Example icons: {', '.join(icon_list[:5])}\n")