Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion kp_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down