omdbapi / OMDb-API

The Open Movie Database Bug Tracking
420 stars 21 forks source link

JSONDecodeError: Expecting value: line 1 column 1 (char 0) #67

Open sandeepmohan opened 6 years ago

sandeepmohan commented 6 years ago

There seems to be problem while requesting with imdb ID.

Using Python 3.x and the requests package. Here is my code:

wrong_dates = df.query('release_year > 2018')

wd_imdb = list(wrong_dates.imdb_id)

#level = "&plot=full"
search_path = "http://www.omdbapi.com/?apikey=<<myapikey>>"
missing_keys = []

for key in wd_imdb:
    r = requests.get(search_path+key)
    response = r.json()["Response"]
    print(key+": "+response)
    if r.json()['Response']=='True':
        rdate = r.json()["Released"]
        wrong_dates.release_date[wrong_dates.imdb_id == key] = rdate
        wrong_dates['release_date'] = pd.to_datetime(wrong_dates['release_date'])
    else:
        missing_keys.append(key)

print(missing_keys)

I put in the print (key+": "+response) bit to sort of keep track of what response I was getting or which imdb id it might be choking at but no dice. At different times, I get 2 or 4 of 6 results before the error in the title shows up.

Has anyone else encountered this and if so have you got a work around?

Thanks in advance.

Almenon commented 6 years ago

I got the same error.

But when I replaced the apikey with my working apiKey, the error went away. You did replace <> with a working apiKey right?

sandeepmohan commented 6 years ago

Yes I did. I didnt want to post my API key publicly tough. I thought it may be a limits issue but I have the subscription so it shouldn't overflow...