Initial commit
This commit is contained in:
44
shell_kinocheck_get_trailer.sh
Executable file
44
shell_kinocheck_get_trailer.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IMDb-ID hier setzen
|
||||
IMDB_ID="tt6718170"
|
||||
|
||||
# API-Key
|
||||
API_KEY="HsK87bvCQLc0OEihrVoIAJN599XoR4SiPh2s5E6WplTxYfaIFl6CGXDnYZHvPj1N"
|
||||
|
||||
|
||||
|
||||
|
||||
_get_trailer_url() {
|
||||
local imdb_id="$1"
|
||||
local api_key="$2"
|
||||
|
||||
# API-URL zusammenbauen
|
||||
local api_url="https://api.kinocheck.de/movies?imdb_id=${imdb_id}&categories=Trailer"
|
||||
|
||||
# API-Request mit curl und JSON-Parsing mit jq
|
||||
local youtube_id=$(curl -s -X GET "$api_url" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
-H "X-Api-Key: $api_key" \
|
||||
-H "X-Api-Host: api.kinocheck.de" | jq -r '.trailer.youtube_video_id')
|
||||
|
||||
# Prüfen, ob ein Trailer vorhanden ist
|
||||
if [[ "$youtube_id" != "null" && -n "$youtube_id" ]]; then
|
||||
echo "https://www.youtube.com/watch?v=$youtube_id"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Funktion aufrufen und Ergebnis in Variable speichern
|
||||
url=$(_get_trailer_url "$IMDB_ID" "$API_KEY")
|
||||
|
||||
# Falls der Trailer gefunden wurde, ausgeben
|
||||
if [[ -n "$url" ]]; then
|
||||
echo "YouTube Trailer-Link: $url"
|
||||
else
|
||||
echo "Kein Trailer gefunden für IMDb-ID: $IMDB_ID"
|
||||
fi
|
||||
Reference in New Issue
Block a user