improved video workflow
This commit is contained in:
parent
b25ebf7ca2
commit
a84067f71f
@ -140,16 +140,30 @@ local function fetch_tmdb_poster(title)
|
|||||||
title = clean_title_common(title)
|
title = clean_title_common(title)
|
||||||
local url = string.format("https://api.themoviedb.org/3/search/movie?api_key=%s&query=%s", TMDB_API_KEY,
|
local url = string.format("https://api.themoviedb.org/3/search/movie?api_key=%s&query=%s", TMDB_API_KEY,
|
||||||
url_encode(title))
|
url_encode(title))
|
||||||
|
log("TMDB Query", url)
|
||||||
|
|
||||||
local res = utils.subprocess({ args = { "curl", "-s", url } })
|
local res = utils.subprocess({ args = { "curl", "-s", url } })
|
||||||
if res.status == 0 then
|
if res.status ~= 0 then
|
||||||
local data = utils.parse_json(res.stdout)
|
log("TMDB Error", "curl failed with status " .. tostring(res.status))
|
||||||
if data and data.results and data.results[1] and data.results[1].poster_path then
|
return nil
|
||||||
return "https://image.tmdb.org/t/p/w500" .. data.results[1].poster_path
|
end
|
||||||
end
|
|
||||||
|
log("TMDB Response", res.stdout)
|
||||||
|
|
||||||
|
local data = utils.parse_json(res.stdout)
|
||||||
|
if not data then
|
||||||
|
log("TMDB Error", "parse_json returned nil")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
if data.results and data.results[1] and data.results[1].poster_path then
|
||||||
|
return "https://image.tmdb.org/t/p/w500" .. data.results[1].poster_path
|
||||||
|
else
|
||||||
|
log("TMDB Error", "No poster found in results")
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function fetch_lastfm_cover(title, artist)
|
local function fetch_lastfm_cover(title, artist)
|
||||||
if not artist or artist == "" then return nil end
|
if not artist or artist == "" then return nil end
|
||||||
title = clean_title_common(title)
|
title = clean_title_common(title)
|
||||||
@ -213,13 +227,27 @@ end
|
|||||||
local function infer_title_with_ollama(title)
|
local function infer_title_with_ollama(title)
|
||||||
if not title or title == "" then return title end
|
if not title or title == "" then return title end
|
||||||
local prompt = string.format([[Archivo: "%s"
|
local prompt = string.format([[Archivo: "%s"
|
||||||
Return only a JSON: { "title": "..." }
|
|
||||||
do NOT explain anything. do NOT return anything else.
|
Devuelve un JSON válido con el título real de la obra. NO incluyas:
|
||||||
|
- Número de capítulo o lista (como "01.", "16.")
|
||||||
|
- Nombre del grupo release (como "newpct", "rarbg", "YTS", etc)
|
||||||
|
- Resolución, calidad o formato ("4K", "HDR", "1080p", etc)
|
||||||
|
|
||||||
|
Ejemplos válidos:
|
||||||
|
Archivo: "16. Licencia para Matar 1985 [newpct]"
|
||||||
|
→ { "title": "Licencia para Matar" }
|
||||||
|
|
||||||
|
Archivo: "300.mkv"
|
||||||
|
→ { "title": "300" }
|
||||||
|
|
||||||
|
NO EXPLIQUES NADA. SOLO devuélvelo como JSON exacto: { "title": "..." }
|
||||||
]], title)
|
]], title)
|
||||||
|
|
||||||
log(" Prompt enviado a Ollama (video)", prompt)
|
log(" Prompt enviado a Ollama (video)", prompt)
|
||||||
local payload = utils.format_json({ model = "gemma2:2b", prompt = prompt, stream = false })
|
local payload = utils.format_json({ model = "gemma2:2b", prompt = prompt, stream = false })
|
||||||
local res = utils.subprocess({ args = { "curl", "-s", "-X", "POST", OLLAMA_URL, "-H", "Content-Type: application/json", "-d", payload } })
|
local res = utils.subprocess({ args = { "curl", "-s", "-X", "POST", OLLAMA_URL, "-H", "Content-Type: application/json", "-d", payload } })
|
||||||
if res.status ~= 0 then return title end
|
if res.status ~= 0 then return title end
|
||||||
|
print("\27[1;34m[OLLAMA VIDEO RAW]\27[0m " .. (res.stdout or "")) -- Color azul, puedes quitarlo
|
||||||
local outer = utils.parse_json(res.stdout)
|
local outer = utils.parse_json(res.stdout)
|
||||||
if outer and outer.response then
|
if outer and outer.response then
|
||||||
local clean = outer.response:gsub("```json", ""):gsub("```", ""):gsub("\n", ""):gsub("\\", "")
|
local clean = outer.response:gsub("```json", ""):gsub("```", ""):gsub("\n", ""):gsub("\\", "")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user