# # Copyright (c) 2024 bartholin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # from flask import current_app from requests import get from kinolist import posters base_url = "http://www.omdbapi.com/" def params(k,v): return { "apikey": current_app.config["OMDB_KEY"], k: v, "type": "movie" } def imdbid(imdbid): data = get(base_url, params=params("i", imdbid)).json() if data['Response'] == 'True': movie = { "title": data["Title"], "year": data["Year"], "language": data["Language"], "plot": data["Plot"] } poster = data["Poster"] if poster != "N/A": img = get(poster) if img.status_code == 200: movie["poster"] = posters.save(poster, img.content) return movie else: return None def title(name): data = get(base_url, params=params("s", name)).json() if data["Response"] == "True": return data["Search"] else: return None