The Movie Database Support

import gzip
import json    

with gzip.open("collection_ids_07_01_2023.json.gz", "rb") as f:
    data = json.loads(f.read().decode("utf-8"))

i get an error :

    data = json.loads(f.read().decode("utf-8"))
  File "C:\Program Files\Python311\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files\Python311\Lib\json\decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 40)

by chance does anyone know the encoding to use with a json.gz fron TMDB

1 reply (on page 1 of 1)

Jump to last post

Hi @999sbo999, my python is a little rusty but I believe "f.read()" reads the entire file.

From the docs:

Data Structure

These files themselves are not a valid JSON object. Instead, each line is. Most systems, tools and languages have easy ways of scanning lines in files (skipping and buffering) without having to load the entire file into memory. The assumption here is that you can read every line easily, and you can expect each line to contain a valid JSON object.

So you are feeding the json decoder the entire file which is not a valid json object. You need to decode the json line by line.

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login