jsoncurlthemoviedb-api

filter TMDB API json response live


I have a lot of movies to which I am adding extensive metadata, as well as a poster image. One of the features I'd like to add is the original_title in the original _language character set. For example, Seven Samurai by Akira Kurosawa would be: 七人の侍 The formatted json data returned in a call to the API is: '''

{

.

"original_language": "ja",

"original_title": "七人の侍",

.

}

'''

Both keys will be added to the metadata. I'll be adding the data to movie files uisng mkvtoolnix, sed, and rip-grep. By live, I mean I want to process the data as soon as it arrives and not store any large amounts of data on disk. I'm using curl on Windows to make the API call:

'curl "https://api.themoviedb.org/3/movie/346?api_key" '

The data returned is:

''' {"adult":false,"backdrop_path":"/qvZ91FwMq6O47VViAr8vZNQz3WI.jpg","belongs_to_collection":null,"budget":2000000,"genres":[{"id":28,"name":"Action"},{"id":18,"name":"Drama"}],"homepage":"","id":346,"imdb_id":"tt0047478","original_language":"ja","original_title":"七人の侍","overview":"A samurai answers a village's request for protection after he falls on hard times. The town needs protection from bandits, so the samurai gathers six others to help him teach the people how to defend themselves, and the villagers provide the soldiers with food.","popularity":37.353,"poster_path":"/8OKmBV5BUFzmozIC3pPWKHy17kx.jpg","production_companies":[{"id":882,"logo_path":"/iDw9Xxok1d9WAM2zFicI8p3khTH.png","name":"TOHO","origin_country":"JP"}],"production_countries":[{"iso_3166_1":"JP","name":"Japan"}],"release_date":"1954-04-26","revenue":346300,"runtime":207,"spoken_languages":[{"english_name":"Japanese","iso_639_1":"ja","name":"日本語"}],"status":"Released","tagline":"The Mighty Warriors Who Became the Seven National Heroes of a Small Town","title":"Seven Samurai","video":false,"vote_average":8.454,"vote_count":3421} '''

The question: how do I extract the two pieces of data mentioned, original_language and original_title for offline use. I do not have any json code since I'm not familiar with json and work with python and bash primarily. My call to the API is included. I'd like to work in python but bash is also acceptable.


Solution

  • Rather than wait on a possibly, more elegant library solution, I've decided to slog through using grep from within a python script. Update: I located a powershrell script on github that fills my need. I just needed to install pshell7 in Windows WSL/Ubuntu using bash. https://github.com/patrickenfuego/matroska-tag-generator