Last active
January 3, 2024 15:30
-
-
Save se7enack/91eb858cc4fe311a7e8cfe6fc37d7d22 to your computer and use it in GitHub Desktop.
Displays artwork for a given motion picture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import json | |
import sys | |
import urllib.request as ur | |
from PIL import Image | |
movie = sys.argv[1].replace(" ","%20") | |
filename = sys.argv[1].replace(" ","_") + ".jpg" | |
def call(url): | |
req = ur.Request(url, headers={'User-Agent': 'Mozilla/5.0'}) | |
r = ur.urlopen(req).read() | |
body = json.loads(r.decode().replace("#","")) | |
return(body) | |
initailcall = call('https://search.imdbot.workers.dev/?q=' + movie) | |
fullcall = call('https://search.imdbot.workers.dev/?tt='+ initailcall['description'][0]['IMDB_ID']) | |
image = fullcall['short']['image'] | |
ur.urlretrieve( | |
image, | |
filename | |
) | |
img = Image.open(filename) | |
img.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment