2011-12-15, 15:20
I'm having some problems retrieving JSON data from a API url.
The url itself opens fine in a internet browser however python returns '404 file not found'
What am i doing wrong?
Log message:
Code:
Code borrowed from Weather Wunderground (hope you won't mind ronie)
The url itself opens fine in a internet browser however python returns '404 file not found'
What am i doing wrong?
Log message:
Quote:14:40:30 T:7124 DEBUG: Artwork Downloader: ########################################################
14:40:30 T:7124 NOTICE: Artwork Downloader: Processing media: 9
14:40:30 T:7124 DEBUG: Artwork Downloader: ID: tt0472033
14:40:30 T:7124 DEBUG: Artwork Downloader: Path: smb://MACHINE-SANCTUM/Media4/Films/Animatie/9 (2009)
14:40:30 T:7124 DEBUG: Artwork Downloader: API: http://api.themoviedb.org/3/movie/tt0472...b80a65a95e
14:40:30 T:7124 DEBUG: Artwork Downloader: Parsed URL:http://api.themoviedb.org/3/movie/tt0472...b80a65a95e
14:40:30 T:488 DEBUG: CWinEventsWin32::WndProcWindow is active
14:40:31 T:7124 DEBUG: Artwork Downloader: Error getting data from TMDB (404: File not found): skipping
14:40:31 T:7124 DEBUG: Artwork Downloader: ########################################################
Code:
PHP Code:
data = self.get_json(self.url %(media_id, self.api_key))
PHP Code:
def get_json(self, url):
try:
log('Parsed URL:%s'% url)
req = urllib2.urlopen(url)
log('Requested data:%s'% req)
json_string = req.read()
req.close()
except HTTPError, e:
if e.code == 404:
raise HTTP404Error(url)
elif e.code == 503:
raise HTTP503Error(url)
else:
raise DownloadError(str(e))
except:
json_string = ''
try:
parsed_json = simplejson.loads(json_string)
except:
parsed_json = ''
return parsed_json