Answer the question
In order to leave comments, you need to log in
How to take info by id from movie search?
Hello! I take information about the film from the film search for such a request
function get_kinopoisk_data() {
let kinopoisk_id = document.getElementById("glink").value;
let xhr = new XMLHttpRequest();
xhr.open('GET', `https://kinopoiskapiunofficial.tech/api/v2.1/films...`, false);
xhr.setRequestHeader('X-API-KEY', '05e15730-5d36-4a7b-9cb8-1a9034ed276c');
xhr.send();
fill_other_fields(JSON.parse(xhr.responseText));
}
function fill_other_fields(response) {
console.log(response);
document.getElementById("sfF1 title").value = response.data.nameRu ?? "";
document.getElementById("brief").value = response.data.description ?? "";
document.getElementById("sfF6").value = response.data.ratingAgeLimits ?? "";
document.getElementById("slogan").value = response.data.slogan ?? "";
document.getElementById("sfF13").value = response.data.filmLength ?? "";
document.getElementById("sfF150").value = response.data.nameEn ?? "";
document.getElementById("sfF14").value = response.data.actors ?? "";
document.getElementById("sfF15").value = response.data.budget ?? "";
document.getElementById("sfF8").value = response.data.seasons.length ?? "";
document.getElementById("message").value = response.data.facts ?? "";
document.getElementById("sfF7").value = response.data.premiereRu ?? "";
document.getElementById("distributors").value = response.data.distributors ?? "";
document.getElementById("input_extrafl10").value = response.data.premiereWorld ?? "";
document.getElementById("input_extrafl8").value = response.data.posterUrl ?? "";
document.getElementById("input_extrafl9").value = response.data.posterUrlPreview ?? "";
document.getElementsByClassName("manFlFlt1").value = response.data.country;
let year_options = Array.from(document.querySelectorAll('.manFlFlt1 option'));
year_options.find(c => c.text == response.data.year).selected = true;
Answer the question
In order to leave comments, you need to log in
but it is not possible to get a list of actors, director and number of episodes. Tell me what am I doing wrong?firstly, indicate the language used in the tags to the question, secondly, duplicating your question (already the third one) is a bad tone and is usually punished by moderators, thirdly, all the necessary information can be found in the documentation
#!/usr/bin/env bash
set -o errexit
BASE_URL="https://kinopoiskapiunofficial.tech/api"
API_KEY="05e15730-5d36-4a7b-9cb8-1a9034ed276c"
KEYWORD=$(echo "[email protected]" | jq -Rr '@uri')
# получаем список фильмов по ключевому слову
get_keyword=$(curl -s -X GET "$BASE_URL/v2.1/films/search-by-keyword?keyword=$KEYWORD&page=1" -H "accept: application/json" -H "X-API-KEY: $API_KEY")
# запоминаем id выбранного фильма
FilmID=$(echo "$get_keyword" | jq -r '.films[] | "\(.filmId);\(.year);\(.nameRu);\(.nameEn)"' | column -t -s';' | sk | awk '{print $1}')
&& exit
# получаем данные о фильме по его id
get_film_data=$(curl -s -X GET "$BASE_URL/v2.1/films/$FilmID" -H "accept: application/json" -H "X-API-KEY: $API_KEY")
echo
echo "$get_film_data" | jq -r '.data | "\t*** \(.nameRu) (\(.year)) ***"'
echo "$get_film_data" | jq -r '.data | "\t [ \(.nameEn) ]"'
echo
echo
echo " О фильме"
echo =====================================================
x="Год производства;"$(echo "$get_film_data" | jq -r '.data.year')
x=$x"\nСтрана;"$( echo "$get_film_data" | jq -r '.data.countries[].country' | sed -z 's/\n/, /g' | sed 's/..$//')
x=$x"\nЖанр;"$( echo "$get_film_data" | jq -r '.data.genres[].genre' | sed -z 's/\n/, /g' | sed 's/..$//')
x=$x"\nВремя;"$( echo "$get_film_data" | jq -r '.data.filmLength' | awk -F: '{print $1*60+$2" минут / "$0}')
echo -e "$x" | column -t -s';'
echo
echo
echo
echo " Описание"
echo =====================================================
echo "$get_film_data" | jq -r '.data.description' | par -w 60d
echo
echo
echo
echo " Эпизоды"
echo =====================================================
echo "$get_film_data" | jq -r '.data.seasons[].episodes[] | "\(.seasonNumber);\(.episodeNumber);\(.nameRu);\(.nameEn)"' | column -t -s';'
echo
echo
echo
# получаем информацию о людях работавших над фильмом
get_staff=$(curl -s -X GET "$BASE_URL/v1/staff?filmId=$FilmID" -H "accept: application/json" -H "X-API-KEY: $API_KEY")
echo " Над фильмом работали"
echo =====================================================
echo "$get_staff" | jq -r '.[] | "\(.professionText);\(.nameRu);\(.nameEn)"' | column -t -s';'
echo
echo
echo
exit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question