Can someone please help with API for IMDb or OMDB? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dipstick5000
Posts: 31
Joined: 21 Jan 2020, 22:01

Can someone please help with API for IMDb or OMDB?

Post by dipstick5000 » 23 May 2022, 15:05

I'm having a really hard time getting this to work, and I feel like I'm in over my head. It's disturbing and frustrating because I can usually figure stuff out. My college Fortran courses are useless, and just like AHK, it's been years since I worked with it and therefore I've forgotten most of both languages, just like I forgot most of my 2 years of Spanish, "No comprende." I can achieve my goals (a small bit of movie info) in a ridiculous, convoluted matter (opening an actual browser and counting characters to find the words I need), but now I'm pissed and I want to do it right. I've spent way too much time on this to give up and do it wrong. I don't care if we use JSON or XML, but I've been trying JSON. Oh, and I have tried searching other posts for help.

Here's a link to the relevant page, where you don't even need a key if you can settle for one string of text (but I've been using a key). Feel free to use my key if you decide to help. They're free for up to 1,000 queries per month, and I may need like 10 or 20 per month.

https://omdbapi.com

Here's what I've been trying, and since I sort of gave up I don't even understand most of it. Some of it is copied from someone else doing a weather API, and I get error messages starting in that 3rd line:

Code: Select all

HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HTTP.Open("GET", http//omdbapi.com/?apikey=<myAPIkey>&t=prisoners+of+the+ghostland)
HTTP.SetRequestHeader("Accept","*.*")
HTTP.SetRequestHeader("Accept-Encoding","deflate")
HTTP.SetRequestHeader("Accept-Language","en-US")
HTTP.SetRequestHeader("Connection","keep-alive")
HTTP.SetRequestHeader("Host","omdbapi.com")
HTTP.SetRequestHeader("Upgrade-Insecure-Requests","1")
HTTP.SetRequestHeader("User-Agent","Firefox/99.0")
HTTP.Send()
Clipboard := HTTP.ResponseText
MsgBox, 0, , CLIPBOARD = %clipboard%
[Mod edit: [code][/code] tags added.]

I've also tried a little with Javascript, but I'm having no luck there either. This is probably because I don't know what I'm doing. Any help would be greatly appreciated.

PS. Also if you could help with a quick bit of parsing the info and extracting only certain things, like, actor, year, etc., that would be wonderful and it would make you a good person, and I'm sure you would end up going to Heaven, assuming you believe a Heaven exists.
Last edited by dipstick5000 on 23 May 2022, 18:06, edited 2 times in total.


dipstick5000
Posts: 31
Joined: 21 Jan 2020, 22:01

Re: Can someone please help with API for IMDb or OMDB?

Post by dipstick5000 » 23 May 2022, 17:02

BoBo wrote:
23 May 2022, 16:42
viewtopic.php?p=389124#p389124 :shh:
Um, thank you, but is that German? What language do i need to translate from?

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Can someone please help with API for IMDb or OMDB?

Post by BoBo » 23 May 2022, 17:06

That's German, indeed. But the code of both scripts shouldn't be too tough to grasp. Good luck :mrgreen:

dipstick5000
Posts: 31
Joined: 21 Jan 2020, 22:01

Re: Can someone please help with API for IMDb or OMDB?

Post by dipstick5000 » 23 May 2022, 17:11

"Removed API key from code for known reason. OP might recreate it if it has been set intentionally."

What is the known reason that I don't know? Is it just a common sense thing? I already set it intentionally. Pretty much everything I do is intentional. So how do I reset it intentionally? I don't understand. I thought it might be helpful, and I certainly don't need 1,000 queries per month, and anyone can get one for free. Is this just standard practice, or in the guidelines I read 12 years ago? I understand the issue, then again I sort of don't in this particular case.

dipstick5000
Posts: 31
Joined: 21 Jan 2020, 22:01

Re: Can someone please help with API for IMDb or OMDB?

Post by dipstick5000 » 23 May 2022, 17:13

BoBo wrote:
23 May 2022, 17:06
That's German, indeed. But the code of both scripts shouldn't be too tough to grasp. Good luck :mrgreen:
Okay thank you. It may be worth it for me to figure it out. Plus I suppose there's always Google Translate.

dipstick5000
Posts: 31
Joined: 21 Jan 2020, 22:01

Re: Can someone please help with API for IMDb or OMDB?

Post by dipstick5000 » 23 May 2022, 17:24

BoBo wrote:
23 May 2022, 16:42
viewtopic.php?p=389124#p389124 :shh:
Initially I understand that as well as I understand what I already coded, and that ain't much. I was hoping someone could easily spot a syntax error, or just some stupid thing I did. Maybe I did nothing wrong? No, that can't be right, it's definitely wrong. However, I have gotten an idea from that post, so thank you very much. I'll probably go through it more, but I had not even considered using "UrlDownloadToVar."

gregster
Posts: 8916
Joined: 30 Sep 2013, 06:48

Re: Can someone please help with API for IMDb or OMDB?  Topic is solved

Post by gregster » 23 May 2022, 17:27

Code: Select all

HTTP.Open("GET", http//omdbapi.com/?apikey=<myAPIkey>&t=prisoners+of+the+ghostland)
Something obvious: URLs in expressions should be quoted as they are strings. Also, a : seems to be missing in front of //.

dipstick5000
Posts: 31
Joined: 21 Jan 2020, 22:01

Re: Can someone please help with API for IMDb or OMDB?

Post by dipstick5000 » 23 May 2022, 17:39

gregster wrote:
23 May 2022, 17:27

Code: Select all

HTTP.Open("GET", http//omdbapi.com/?apikey=<myAPIkey>&t=prisoners+of+the+ghostland)
Something obvious: URLs in expressions should be quoted as they are strings. Also, a : seems to be missing in front of //.
Thank you!

dipstick5000
Posts: 31
Joined: 21 Jan 2020, 22:01

Re: Can someone please help with API for IMDb or OMDB?

Post by dipstick5000 » 23 May 2022, 17:57

gregster wrote:
23 May 2022, 17:27
Something obvious: URLs in expressions should be quoted as they are strings. Also, a : seems to be missing in front of //.
Holy cow gregster. So simple, so obvious. That often seems to be the case. Works like a charm now, and I can't believe I wasted a day because of those 2 stupid errors. The people on this forum are awesome and helpful. Thank you everyone, especially gregster.


dipstick5000
Posts: 31
Joined: 21 Jan 2020, 22:01

Re: Can someone please help with API for IMDb or OMDB?

Post by dipstick5000 » 24 May 2022, 15:01

Chunjee wrote:
24 May 2022, 10:48
English OMDB app I wrote. Sounds like you figured it out though

https://github.com/Chunjee/SA-omdbcloner
Thank you. Looks pretty good. More complex than mine, but mine is working perfectly for what I need. I may find the need or desire to study yours more thoroughly though, since I'm not completely done yet. I may have searched wrong before I posted my question. Not sure why I didn't see anything about your script.

Post Reply

Return to “Ask for Help (v1)”