From 4516e5595a0c7dc77e9e1d1f1199de3aeb67bda2 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Fri, 5 Feb 2021 12:13:25 +0100 Subject: [PATCH] new: [imdb] First version to get IMDB score from a movie title --- REQUIREMENTS | 1 + misp_modules/modules/expansion/imdb.py | 38 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 misp_modules/modules/expansion/imdb.py diff --git a/REQUIREMENTS b/REQUIREMENTS index 86615cd..6be5c6f 100644 --- a/REQUIREMENTS +++ b/REQUIREMENTS @@ -54,6 +54,7 @@ httplib2==0.18.1 idna-ssl==1.1.0; python_version < '3.7' idna==2.10; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' imapclient==2.1.0 +IMDbPY==2020.9.25 isodate==0.6.0 jbxapi==3.14.0 json-log-formatter==0.3.0 diff --git a/misp_modules/modules/expansion/imdb.py b/misp_modules/modules/expansion/imdb.py new file mode 100644 index 0000000..3a1ceb8 --- /dev/null +++ b/misp_modules/modules/expansion/imdb.py @@ -0,0 +1,38 @@ +import json +import imdb + +misperrors = {'error': 'Error'} +mispattributes = {'input': ['text'], 'output': ['text']} + +# possible module-types: 'expansion', 'hover' or both +moduleinfo = {'version': '1', 'author': 'MISP', + 'description': 'Get the IMDB score of the movie title', + 'module-type': ['hover']} + +# config fields that your code expects from the site admin +moduleconfig = [] + +ia = imdb.IMDb() + +def handler(q=False): + if q is False: + return False + request = json.loads(q) + + movieTitle = request['text'] + movies = ia.search_movie(movieTitle) + movieID = movies[0].movieID + movie = ia.get_movie(movieID) + score = movie.get('rating', 'Could not retreive rating') + + r = {'results': [{'types': 'text', 'values': score}]} + return r + + +def introspection(): + return mispattributes + + +def version(): + moduleinfo['config'] = moduleconfig + return moduleinfo