- Add Like button: promotes wave track to permanent library and refills buffer - Add Dislike button: blacklists track in SQLite disliked_tracks, removes audio, refills buffer - Add Delete button in history table for library file removal - Add AI Radio module: wttr.in weather, Qwen 2.5 host monologues, speech synthesis, ID3 tags - Generate interleaved 'AI Радио.m3u8' alongside clean 'Моя Волна.m3u8' - Update Web UI with Radio DJ card, voice selection, and track actions
23 lines
839 B
Python
23 lines
839 B
Python
import urllib.request
|
|
import urllib.parse
|
|
from typing import Optional
|
|
from app.config import settings
|
|
|
|
def get_current_weather() -> Optional[str]:
|
|
"""Fetch current weather report from wttr.in in Russian."""
|
|
city = urllib.parse.quote(settings.WEATHER_CITY) if settings.WEATHER_CITY else ""
|
|
url = f"https://wttr.in/{city}?format=%C,+%t&lang=ru"
|
|
try:
|
|
req = urllib.request.Request(
|
|
url,
|
|
headers={"User-Agent": "curl/7.88.1"}
|
|
)
|
|
with urllib.request.urlopen(req, timeout=3.5) as resp:
|
|
text = resp.read().decode("utf-8").strip()
|
|
# Basic validation
|
|
if text and not text.startswith("<") and len(text) < 60:
|
|
return text
|
|
except Exception as e:
|
|
print(f"[RadioWeather] Warning: unable to fetch weather: {e}")
|
|
return None
|