Skip to content

BF1 - #147

Closed
micasa96 wants to merge 69 commits into
weebzone:masterfrom
micasa96:master
Closed

BF1 #147
micasa96 wants to merge 69 commits into
weebzone:masterfrom
micasa96:master

Conversation

@micasa96

@micasa96 micasa96 commented Sep 8, 2026

Copy link
Copy Markdown

No description provided.

micasa96 and others added 30 commits August 16, 2026 11:45
Lowered TMDB threshold for Spanish/MX titles to avoid discarding valid matches. Added Spanish diacritics detection for better matching.
Added a function to repair garbled accents in text from Telegram or DB storage, handling both mojibake and decomposed accents.
Update filename sanitization to preserve Latin accented letters and Spanish punctuation.
Add a new async function to enrich search results with availability status.
Refactor stream details formatting to include resolution, language, and source tags. Improve handling of codec information and structure of stream title.
Implement requests manager for handling media requests, including search and submission functionalities.
…lability, Telegram season line

- requests_manager: tv_seasons_status/_db_tv_available_seasons/tv_seasons_available
- search_titles_enriched returns availability (missing/partial/complete) + seasons_status
- submit_request accepts season_numbers; 'Disponible' only if all requested seasons in library
- request_notifier caption adds '📺 Temporadas: T1, T3' / 'Serie completa'
- request_public.html: season chips multi-select + availability badges + request selected/whole
- api_routes passes season_numbers to submit_request
…lability; Cinemeta fallback for season list (works without TMDB API key)

- request_public.html: 'Serie completa' is now an ACTION button ('Pedir serie completa') only shown when season list is known; otherwise generic 'Solicitar'
- requests_manager: _cinemeta_tv_seasons fallback derives seasons from Cinemeta episode list; tv_seasons_status accepts imdb_id
…ble' if requested seasons truly in library; auto_fulfill respects requested seasons for TV

- submit_request: existing TV request with specific seasons rechecks tv_seasons_available instead of blanket 'uploaded' flag
- auto_fulfill: TV marks 'uploaded' only when every requested season is present; keeps 'pending' for missing seasons; receiver passes season_number
…hed checks media_exists for movies; remove 'movie' pseudo-availability flag
…ys 'En biblioteca' when available (badge still shows status)
…as affecting movies too); series rely on green-highlighted season chips, movies on the 'En biblioteca'/'Solicitar' button only
- Add external_api_url/external_api_token settings (DB-backed, no hardcode)
- New external_api_notifier module POSTs new requests to the API
  with format {imdb,nombre,tipo,temporada}; movies->tipo movies/temporada 0,
  series->tipo series/temporada N. Logs failures, never blocks the request.
- Wire notify_external_api into submit_request (alongside Telegram notifier)
- Admin panel card + saveSettings payload + api_routes trim validation
Hermes Agent added 10 commits September 11, 2026 03:43
…ode en webhook

- Stream prompt 'Solicitar contenido' con behaviorHints.notWebReady
- Endpoint /{token}/request-stream/{full_stremio_id}
- queue_stream_request parsea imdb:season:episode → submit_request
- Webhook n8n recibe: imdb, nombre, tipo, temporada, episodio
…o WebView

The webhook POST already fires server-side in queue_stream_request.
The JS fetch('/_fire-request/...') was unreliable under Stremio's
WebView (no localStorage/fetch context), causing HTTP 500.
Replaced with plain meta-refresh page — 302-style redirect only.
…ew 500

HTMLResponse caused Stremio's media WebView to choke on the
non-video body → internal HTTP 500. Returning JSON 201
prevents Stremio from invoking its video/ffmpeg pipeline.
…avior

JSON 201 response caused Stremio WebView to misinterpret the body as a
media resource, triggering internal ffmpeg 500. dev uses HTMLResponse
with client-side fetch + meta-refresh, which Stremio discards cleanly.
Align master to dev's proven response shape.
master's submit_request lacked the episode_num kwarg that
queue_stream_request passes — caused TypeError -> HTTP 500.
Now persists episode_num so external_api_notifier webhook sends the
correct season/episode to n8n. Aligns master to dev behavior.
quote() encoded 'tt0944947:1:5' -> 'tt0944947%3A1%3A5', causing
FastAPI to receive a mangled media_id that _parse_stremio_id could
not split into season/episode. The fetch JS + manifest redirect_url
now pass media_id verbatim (colons preserved) so series requests
finally reach the n8n webhook with temporada+episodio.
_master_: tv_seasons_available(tmdb_id, seasons) called
_db_tv_available_seasons(tmdb_id) which did int(None) when Cinemeta
gave a tv hit with no tmdb_id (e.g. Rick & Morty tt0944947) ->
TypeError: int() argument must be a string... -> HTTP 500 for SERIES.
Fixed: _db_tv_available_seasons now accepts imdb_id fallback; passes
through tv_seasons_status -> tv_seasons_available -> submit_request.
Movies unaffected (skip tv branch). Aligns _db_tv_available_seasons/
_tv_seasons_status/tv_seasons_available signatures to dev. Fixes the
"no hace nada" + 500 on series requests from Stremio.
…-complete path)

Second missed call site. Now all tv_seasons_available calls pass
imdb_id fallback — consistent with dev. This covers the upload-detect
path in tv_upload_complete where tmdb_id can be None for Cinemeta-only
titles, which would TypeError on int(None).
The DB may store media_type as 'tv' or raw 'series' from Cinemeta.
_build_payload now normalizes both values to is_tv=True so the
webhook ALWAYS sends tipo='series' for TV content — previously
sent 'movies' when media_type=='series' (not 'tv'), causing
n8n workflows keyed on tipo='series' to silently drop the request.
Previously notify_external_api only fired when `new_seasons` was truthy.
Re-requesting an already-stored serie/episode (e.g. Lanterns T1E1 when
T1 already exists in DB) hit existing-path with new_seasons=[] and
silently skipped the n8n webhook. Now fires notify_external_api on
EVERY existing-request hit so Stremio episode requests always reach
the webhook with temporada + episodio.
@micasa96
micasa96 force-pushed the master branch 2 times, most recently from f045150 to 674c4f1 Compare September 11, 2026 05:24
Hermes Agent added 6 commits September 11, 2026 05:29
Stremio's WebView retries the stream GET with exponential backoff (~7x
in 5s), so queue_stream_request + fetch-JS fired the n8n webhook up to 7
veces for one click. Added a module-level _RECENT_NOTIFY cache keyed by
(imdb, season_str, episode) with 5s TTL. Duplicate calls are skipped +
logged as SKIPPED. No DB change — in-memory only. Fixes the webhook spam
for both new and existing requests.
Stremio's WebView retries the stream GET 7x in ~5s, so notify_new_request
was firing 8 Telegram messages for one click. Added the SAME _is_recently_sent
dedupe cache (shared instance with external_api_notifier so webhook + Telegram
stay in sync) keyed by (imdb, season, episode). Duplicate calls are logged +
skipped. Only ONE Telegram message per request per ~5s window.
Was 5s — Stremio retries the stream GET ~6-8s after first fire,
which is OUTSIDE the 5s TTL → webhook + telegram fired twice.
15s TTL covers Stremio's full ~10s retry cycle so the 2nd request
is deduped. Single notification guaranteed per Stremio click.
Android TV retries the stream GET every ~15s during playback failure,
firing the full queue_stream_request pipeline (webhook + Telegram) each
time. Added a module-level cache keyed by (token, media_id) with 120s
TTL so only ONE notification fires per Stremio stream-click.

Also moved HTMLResponse import to module top (was inline between comments).
…dently

Shared _notify_key caused notify_new_request (Telegram) to register the
cache key BEFORE notify_external_api (webhook) → webhook was SKIPPED on
its very first fire. Added 'namespace' param so Telegram='telegram' and
webhook='webhook' keys dont collide. Both still dedupe within their own
scope (120s TTL).
…ries)

These were two default catalogs I added (Popular) that show up alongside
Latest and custom catalogs. Removed from manifest catalog list so Stremio
no longer displays them. Only 'Latest' + custom catalogs (hidden via token
config) remain. No route removal needed — top_movies/top_series had no
handler endpoints (the catalog is purely manifest-declared); removing
them from the manifest hides them entirely.
@weebzone weebzone closed this Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants