feat: implement caching and redirect endpoints for premium live streams
This commit is contained in:
@@ -501,6 +501,34 @@ class RNScraper:
|
||||
self.db.commit()
|
||||
time.sleep(0.5)
|
||||
|
||||
def update_live_stream_url(self):
|
||||
self.logger("RNŚ: Aktualizacja adresu live stream...")
|
||||
try:
|
||||
html = self._get_html(f"{BASE_URL}/")
|
||||
if html:
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
target_url = None
|
||||
for btn in soup.find_all(class_="rns-stream-tile__btn"):
|
||||
src = btn.get("data-neo-player-src")
|
||||
parent = btn.parent
|
||||
if parent and src:
|
||||
text = parent.get_text(" ", strip=True).lower()
|
||||
if "256" in text or "wysoka" in text:
|
||||
target_url = src
|
||||
break
|
||||
|
||||
if target_url:
|
||||
if not target_url.startswith("http"): target_url = f"{BASE_URL}/{target_url.lstrip('/')}"
|
||||
config_url = self.db.query(Config).filter_by(key="rns_live_url").first()
|
||||
if not config_url:
|
||||
self.db.add(Config(key="rns_live_url", value=target_url))
|
||||
else:
|
||||
config_url.value = target_url
|
||||
self.db.commit()
|
||||
self.logger(f"RNS: Zaktualizowano adres streamu na {target_url}")
|
||||
except Exception as e:
|
||||
self.logger(f"RNS: Błąd aktualizacji streamu: {e}")
|
||||
|
||||
def run_full_sync(self, specific_program_slug=None):
|
||||
if not self.ensure_auth():
|
||||
self.logger("RNŚ: Błąd logowania przed startem!")
|
||||
@@ -511,4 +539,7 @@ class RNScraper:
|
||||
if self.requests_made < self.hard_limit:
|
||||
self.phase_2_backfill(specific_program_slug)
|
||||
|
||||
if not specific_program_slug:
|
||||
self.update_live_stream_url()
|
||||
|
||||
self.logger(f"RNŚ: Koniec. Wysłano zapytania: {self.requests_made}/{self.hard_limit} (w tym backfill ograniczony do {self.backfill_limit}).")
|
||||
|
||||
Reference in New Issue
Block a user