Skip to content

Instantly share code, notes, and snippets.

@courville
Created February 26, 2021 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save courville/548469b86ae9294f9e98cbb52273a1db to your computer and use it in GitHub Desktop.
Save courville/548469b86ae9294f9e98cbb52273a1db to your computer and use it in GitHub Desktop.
list all tmdb genres traductions and output result as markdown table
#!/bin/sh
# API= your tmdb API key
# all lang except en
LANG=$(curl -s https://api.themoviedb.org/3/configuration/languages\?api_key=${API} | jq | grep iso_639_1 | sed 's/^.*"iso_639_1": "\([a-z][a-z]\).*$/\1/g' | grep -v en | sort -u)
for lang in $LANG
do
curl -s https://api.themoviedb.org/3/genre/movie/list\?api_key=${API}\&language=${lang} | jq | grep \"name\": | grep -v null | sed 's/^.*"name": "\([^"]*\)"/\1/g' > result-$lang
done
# remove empty translations
find . -size 0 -print -delete
# en master of all
curl -s https://api.themoviedb.org/3/genre/movie/list\?api_key=${API}\&language=en | jq | sed 's/^.*"id": //g' | sed 's/^.*"name": "\([^"]*\)"/\1/g' | sed "/[]{}[]/d" | sed 'N;s/,\n/|/' > result
# assemble result
for f in $(ls result-*)
do
paste -d '|' result $f > result-tmp
mv result-tmp result
done
cat result | sed 's/|/ | /g' | sed 's/^ //g' | sed 's/ $//g' > table
LANG=$(ls result-* | sort | sed 's/result-//g')
LANG="en "${LANG}
NB=$(echo $LANG | wc -w)
LINE="| "$(echo $LANG | sed "s/ / | /g")" |"
SEP=$(printf "%${NB}s" | sed 's/ /| --- /g')" |"
echo $LINE > final
echo $SEP >> final
cat table >> final
@courville
Copy link
Author

Note that latest version of the script is available here with some corrections: https://github.com/nova-video-player/aos-MediaLib/tree/v6/script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment