From f3e8722b3c33aa0b87d1b4beccca6ff4c5c473d6 Mon Sep 17 00:00:00 2001 From: ekolvah Date: Wed, 19 Aug 2026 22:15:03 +0300 Subject: [PATCH] Fix: fetch reactions for KP-source cards Reactions block (emoji counters under genres) was always empty on KP cards because the engine's reactions call is keyed by TMDB id, which KP cards don't carry. Resolve TMDB id via imdb_id (already returned by getById) and fetch reactions the same way the native tmdb source does, so movie and TV cards show reactions like tmdb/cub-sourced cards do. --- kp_source.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/kp_source.js b/kp_source.js index 6e90792..d673c86 100644 --- a/kp_source.js +++ b/kp_source.js @@ -630,6 +630,32 @@ return loadPart; } + function withReactions(oncomplite) { + return function (result) { + var movie = result && result.movie; + var tmdb = Lampa.Api.sources.tmdb; + var cub = Lampa.Api.sources.cub; + + if (!movie || !movie.imdb_id || !tmdb || !cub) return oncomplite(result); + + tmdb.get('find/' + movie.imdb_id + '?external_source=imdb_id', {}, function (found) { + var matches = found.movie_results && found.movie_results.length ? found.movie_results : found.tv_results; + + if (matches && matches[0]) { + cub.reactionsGet({ + method: movie.type, + id: matches[0].id + }, function (reactions) { + result.reactions = reactions; + oncomplite(result); + }); + } else oncomplite(result); + }, function () { + oncomplite(result); + }); + }; + } + function full() { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var oncomplite = arguments.length > 1 ? arguments[1] : undefined; @@ -648,7 +674,7 @@ if (kinopoisk_id) { getById(kinopoisk_id, params, function (json) { var status = new Lampa.Status(4); - status.onComplite = oncomplite; + status.onComplite = withReactions(oncomplite); status.append('movie', json); status.append('persons', json && json.persons); status.append('collection', json && json.collection);