Merge branch 'main' into narl.io

This commit is contained in:
nvrl committed 2026-02-19 18:50:20 +01:00
commit 7ecc1a3949
4 files changed
+13 -19

No files matched your search

@@ -1,6 +1,6 @@
import json
import os
import urllib.request
import requests
from django.core.management.base import BaseCommand
from django.core.files import File
from django.conf import settings
@@ -24,18 +24,14 @@ class Command(BaseCommand):
os.makedirs(os.path.dirname(filepath), exist_ok=True)
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
with urllib.request.urlopen(req, timeout=10) as response:
content = response.read()
if not content:
return None
response = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'}, timeout=10)
response.raise_for_status()
if os.path.exists(filepath):
os.remove(filepath)
with open(filepath, 'wb') as f:
f.write(content)
f.write(response.content)
return f"flavors/{filename}"
except Exception as e:
@@ -1,5 +1,5 @@
import json
import urllib.request
import requests
import re
import os
from django.core.management.base import BaseCommand
@@ -32,18 +32,14 @@ class Command(BaseCommand):
os.makedirs(os.path.dirname(filepath), exist_ok=True)
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
with urllib.request.urlopen(req, timeout=10) as response:
content = response.read()
response = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'}, timeout=10)
response.raise_for_status()
if not content:
return None
if os.path.exists(filepath):
os.remove(filepath)
with open(filepath, 'wb') as f:
f.write(content)
f.write(response.content)
return f"flavors/{filename}"
except Exception as e:
@@ -55,9 +51,9 @@ class Command(BaseCommand):
self.stdout.write(f"Fetching from {url}...")
try:
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
with urllib.request.urlopen(req) as response:
data = json.loads(response.read().decode())
response = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'}, timeout=15)
response.raise_for_status()
data = response.json()
except Exception as e:
self.stdout.write(self.style.ERROR(f"Failed to fetch data: {e}"))
return
+1
View File
@@ -9,3 +9,4 @@ whitenoise>=6.6.0
gunicorn>=21.2.0
django-ratelimit>=4.1.0
django-compression-middleware>=0.5.0
requests>=2.31.0
+1
View File
@@ -43,6 +43,7 @@ services:
command: python manage.py worker
restart: unless-stopped
networks:
- narl
- internal
dns:
- 8.8.8.8