The Movie Database Подршка

Hi , I am using python code to retrieve the json information from themoviedb.org. But not getting the json data in response. I am receiving response code ( 200 : success) but i am not able to get the json data

import requests import json

headers = {'Accept': 'application/json'}
payload = {'api_key': 'Giving a proper key'}

response = requests.get("http://api.themoviedb.org/3/configuration", params=payload, headers=headers) print (response) print (response.json())

Output:


JSONDecodeError Traceback (most recent call last) in () 9 print (response) 10 print (response.url) ---> 11 print (response.json()) 12 13 #response = json.loads(response.text)

C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs) 810 # used. 811 pass --> 812 return complexjson.loads(self.text, **kwargs) 813 814 @property

C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\json_init_.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 317 parse_int is None and parse_float is None and 318 parse_constant is None and object_pairs_hook is None and not kw): --> 319 return _default_decoder.decode(s) 320 if cls is None: 321 cls = JSONDecoder

C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\json\decoder.py in decode(self, s, _w) 337 338 """ --> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 340 end = _w(s, end).end() 341 if end != len(s):

C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\json\decoder.py in raw_decode(self, s, idx) 355 obj, end = self.scan_once(s, idx) 356 except StopIteration as err: --> 357 raise JSONDecodeError("Expecting value", s, err.value) from None 358 return obj, end

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

1 одговор (на страни 1 од 1)

Jump to last post

Hi shobhit,

I'm not sure, I have tested this with many JSON parsers and never had a problem. I'm not familiar with the lib you're using, I would double check the documentation and make sure everything is being used properly.

Here's a simple example in Ruby that is working.

require 'rest_client'
api_key = "###"
request = RestClient.get 'http://api.themoviedb.org/3/configuration', { :accept => 'application/json', :params => { :api_key => api_key } }
JSON.parse(request)

2.1.5 :009 > require 'rest_client'
=> true
2.1.5 :010 > api_key = "###"
=> "###"
2.1.5 :011 > request = RestClient.get 'http://api.themoviedb.org/3/configuration', { :accept => 'application/json', :params => { :api_key => api_key } }
=> "{\"images\":{\"base_url\":\"http://image.tmdb.org/t/p/\",\"secure_base_url\":\"https://image.tmdb.org/t/p/\",\"backdrop_sizes\":[\"w300\",\"w780\",\"w1280\",\"original\"],\"logo_sizes\":[\"w45\",\"w92\",\"w154\",\"w185\",\"w300\",\"w500\",\"original\"],\"poster_sizes\":[\"w92\",\"w154\",\"w185\",\"w342\",\"w500\",\"w780\",\"original\"],\"profile_sizes\":[\"w45\",\"w185\",\"h632\",\"original\"],\"still_sizes\":[\"w92\",\"w185\",\"w300\",\"original\"]},\"change_keys\":[\"adult\",\"air_date\",\"also_known_as\",\"alternative_titles\",\"biography\",\"birthday\",\"budget\",\"cast\",\"certifications\",\"character_names\",\"created_by\",\"crew\",\"deathday\",\"episode\",\"episode_number\",\"episode_run_time\",\"freebase_id\",\"freebase_mid\",\"general\",\"genres\",\"guest_stars\",\"homepage\",\"images\",\"imdb_id\",\"languages\",\"name\",\"network\",\"origin_country\",\"original_name\",\"original_title\",\"overview\",\"parts\",\"place_of_birth\",\"plot_keywords\",\"production_code\",\"production_companies\",\"production_countries\",\"releases\",\"revenue\",\"runtime\",\"season\",\"season_number\",\"season_regular\",\"spoken_languages\",\"status\",\"tagline\",\"title\",\"translations\",\"tvdb_id\",\"tvrage_id\",\"type\",\"video\",\"videos\"]}"
2.1.5 :012 > JSON.parse(request)
=> {"images"=>{"base_url"=>"http://image.tmdb.org/t/p/", "secure_base_url"=>"https://image.tmdb.org/t/p/", "backdrop_sizes"=>["w300", "w780", "w1280", "original"], "logo_sizes"=>["w45", "w92", "w154", "w185", "w300", "w500", "original"], "poster_sizes"=>["w92", "w154", "w185", "w342", "w500", "w780", "original"], "profile_sizes"=>["w45", "w185", "h632", "original"], "still_sizes"=>["w92", "w185", "w300", "original"]}, "change_keys"=>["adult", "air_date", "also_known_as", "alternative_titles", "biography", "birthday", "budget", "cast", "certifications", "character_names", "created_by", "crew", "deathday", "episode", "episode_number", "episode_run_time", "freebase_id", "freebase_mid", "general", "genres", "guest_stars", "homepage", "images", "imdb_id", "languages", "name", "network", "origin_country", "original_name", "original_title", "overview", "parts", "place_of_birth", "plot_keywords", "production_code", "production_companies", "production_countries", "releases", "revenue", "runtime", "season", "season_number", "season_regular", "spoken_languages", "status", "tagline", "title", "translations", "tvdb_id", "tvrage_id", "type", "video", "videos"]}

Не можеш да нађеш филм или серију? Пријави се да додаш.

Глобално

s фокусирај траку за претрагу
p отворите мени профила
esc затворити отворени прозор
? отвори прозор пречице на тастатури

На страницама медија

b вратити се назад (или родитељу кад је то применљиво)
e иди на страницу за уређивање

На страницама ТВ сезона

(стрелица надесно) пређите на следећу сезону
(лева стрелица) иди на претходну сезону

На страницама ТВ епизода

(стрелица надесно) пређите на следећу епизоду
(лева стрелица) иди на претходну епизоду

На свим страницама са сликама

a отвори прозор за додавање слике

На свим страницама за уређивање

t отвори селектор превода
ctrl+ s пошаљи образац

На страницама за дискусију

n отвори нову дискусију
w мења статус гледања
p мења јавно/приватно
c мења отвори/затвори
a отвори активност
r одговор на дискусију
l иди на последњи одговор
ctrl+ enter пошаљи поруку
(стрелица надесно) следећа страница
(лева стрелица) претходна страница

Подешавања

Желите ли да оцените или додате ову ставку у листу?

Пријави се