Spaces:
Running on Zero
Running on Zero
feat: integrate Cloudflare R2 Quran translations, add translation endpoints and edge caching
3c6e2f1 Download scripts/check_more_scholars.py from sahihislam/superadmin: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/sahihislam/superadmin/resolve/main/scripts/check_more_scholars.py
- Command line
-
hf download hf://spaces/sahihislam/superadmin/scripts/check_more_scholars.py
-
curl -L -o check_more_scholars.py https://huggingface.co/spaces/sahihislam/superadmin/resolve/main/scripts/check_more_scholars.py
1.44 kB
| import sys | |
| import urllib.request | |
| import urllib.parse | |
| import json | |
| import re | |
| sys.stdout.reconfigure(encoding='utf-8') | |
| def test_collection(coll): | |
| meta_url = f"https://archive.org/metadata/{coll}/files" | |
| try: | |
| req = urllib.request.Request(meta_url, headers={'User-Agent': 'Mozilla/5.0'}) | |
| with urllib.request.urlopen(req, timeout=10) as r: | |
| data = json.loads(r.read()) | |
| files = [f['name'] for f in data.get('result', []) if f['name'].endswith('.mp3')] | |
| return len(files), files[:3] | |
| except Exception as e: | |
| return 0, str(e) | |
| # Let's search for Fi Zilal al-Quran audio | |
| def search(q): | |
| url = f"https://archive.org/advancedsearch.php?q={urllib.parse.quote(q)}&fl[]=identifier,title,mediatype&rows=5&output=json" | |
| req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'}) | |
| try: | |
| with urllib.request.urlopen(req, timeout=10) as r: | |
| return json.loads(r.read())['response']['docs'] | |
| except Exception as e: | |
| return [] | |
| print("=== Fi Zilal al-Quran ===") | |
| for d in search("Fee Zilal il Quran audio"): | |
| print(d.get('identifier'), '|', d.get('title')) | |
| print("\n=== Tafsir Ibn Kathir Arabic ===") | |
| for d in search("تفسير ابن كثير mp3"): | |
| print(d.get('identifier'), '|', d.get('title')) | |
| print("\n=== Tazkirul Quran ===") | |
| for d in search("تذکیر القرآن mp3"): | |
| print(d.get('identifier'), '|', d.get('title')) | |