advplyr / audiobookshelf

Self-hosted audiobook and podcast server
https://audiobookshelf.org
GNU General Public License v3.0
5.75k stars 395 forks source link

[Bug]: "Library Item" schema returned by "Get a Library's Items" endpoint response is different from API docs #2507

Closed funkey7dan closed 5 months ago

funkey7dan commented 5 months ago

Describe the issue

The "libraryFiles" attribute is expected in each item in the 'results' attribute array returned from "Get a Library's Items" endpoint, but it's missing. I also checked to see if maybe the results were minified, but they are not.

P.S I'm trying to search all my library audio files (relPath) to find the id of a corresponding book, if there is an easier way than trying to iterate over all of the item like i'm attempting, i'll be glad to hear.

Steps to reproduce the issue

python code used to test:

r = requests.Session()
r.headers.update({"Authorization": f"Bearer {TOKEN}"})

def try_to_get_lib_files():
    out = r.get(f"{ABS_PATH}/api/libraries")
    if out.status_code == 200:
        lib_arr = json.loads(out.text)["libraries"]
        for lib in lib_arr:
            """
            Get a Library's Items
            This endpoint returns a library's items, optionally sorted and/or filtered.

            GET https://abs.example.com/api/libraries/<ID>/items

            Expected Response:
            results: Array of Library Item
            """
            out = r.get(
                f"{ABS_PATH}/api/libraries/{lib['id']}/items",
            )
            if out.status_code == 200:
                res = json.loads(out.text)
                item_arr = res["results"]
                """
                Expected: each item in item_arr should contain a libraryFiles attribute - 
                libraryFiles : Array of Library File

                Actual: item does not contain a libraryFiles attribute
                """
                if any("libraryFiles" in x for x in item_arr):
                    print("libraryFiles found")
                else:
                    print("libraryFiles not found")
                print(f"minified Attribute status: {res['minified']}")

Audiobookshelf version

v2.7.1

How are you running audiobookshelf?

Docker

advplyr commented 5 months ago

This is a duplicate of #2123. I never added the expanded items back in after the database update. You could use the search endpoint to find items.

advplyr commented 5 months ago

Duplicate of #2123