# MfGames Media: Getting information about a movie
=> .. Up a Level
# USAGE: get-tmdb-json.sh *.mkv
## This attempts to download the TMDB information for a given file. If
## the file exists, it will not be downloaded. This assumes there is
## only a single period in the filename.
## Go through the input files.
for file in “$@” do # Figure out the basename of the file and relative directory path. dir=$(dirname “$file”) base=$(basename “$file” | sed 's@.\w*$@@')
```
echo "Processing: $base"
# First check to see if we need the JSON file.
json="$dir/$base.tmdb"
if [ ! -f "$json" ]
then
# We need to download the file.
echo " Downloading TMDB JSON"
# Try to get the TMDB ID for the file.
tmdb_id=$(mfgames-tmdb id "$base")
if [ "x$tmdb_id" != "x" ]
then
# Taking our time...
echo " Sleeping..."
sleep 7
# Download the file.
echo " TMDB ID: $tmdb_id"
mfgames-tmdb json $tmdb_id "--output=$json"
# Check to see if this appears to be an HTML file.
if grep "
" "$json" > /dev/null
then
echo " File could not be downloaded"
rm -f "$json"
fi
else
echo " Could not identify ID file"
fi
# Throttle slightly so TMDB doesn't hate us.
echo " Sleeping..."
sleep 7
else
# Just identify that we have the file already.
echo " TMDB JSON already downloaded: $json"
fi
```
done
# Metadata
Categories:
=> /categories/programming/ Programming
=> /categories/technology/ Technology
Tags:
=> /tags/bash/ Bash
=> /tags/mfgames-media/ mfgames-media
=> /tags/python/ Python
# Footer
Below are various useful links within this site and to related sites (not all have been converted over to Gemini).
=> /now/ Now
=> /contact/ Contact
=> /bio/ Biography
=> /bibliography/ Bibliography
=> /support/ Support
=> /fiction/ Fiction
=> //fedran.com/ Fedran
=> https://mfgames.com/ Coding
=> https://moonfire.us/ The Moonfires
=> /categories/ Categories
=> /tags/ Tags
=> /privacy/ Privacy
=> /colophon/ Colophon
=> /license/ License
=> https://lists.typewriter.press/subscription?f=RDQ6f3AFHXnX2o763d5TgUmaYP7N763gR6FjZyGUUFWhyRkpgZF9I35ySICDBEdFFtgG Mailing List
=> https://d.moonfire.us/blog/2012/07/01/mfgames-media-getting-information-about-a-movie/