andy29485 / embypy

python wrapper for the emby rest api
GNU Lesser General Public License v3.0
16 stars 7 forks source link

sys:1: RuntimeWarning: coroutine 'Emby.movies' was never awaited #6

Closed rajil closed 4 years ago

rajil commented 4 years ago

Can you post a basic example how to fetch a movie list?

I tried the following but it gave an error:

import embypy
server = embypy.Emby('http://myemby:8096',api_key='000',device_id='script',userid='me')
result = server.movies

$ python code.py 
sys:1: RuntimeWarning: coroutine 'Emby.movies' was never awaited

My intention is to modify Tags of the movies.

andy29485 commented 4 years ago

tl;dr: line 3 of your example code should be: result = server.movies_sync

I wanted to use this api in a project that was already using asyncio, so by default most calls use async.

The docs aren't the best, but: https://embypy.readthedocs.io/en/latest/embypy.html#embypy.Emby.movies This function is a coroutine. append `_sync` to run outside of an event loop

I am considering making the async/sync stuff a constructor parameter, but I haven't really been working on this project recently.

rajil commented 4 years ago

Thanks with server.movies_sync, I get the following error, aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://myemby:8096/Users/me/Items?format=json&Recursive=true&IncludeItemTypes=Movie&Fields=Path,ParentId,Overview,Genres,Tags&SortBy=SortName&SortOrder=Ascending&api_key=000&deviceId=script')

andy29485 commented 4 years ago

So, this library is a really basic wrapper around emby/jellyfin's API. There is quite a bit missing (like error reporting/passing). To debug this, try just putting that URL into a browser and see what it returns (http://myemby:8096/Users/me/Items?format=json&Recursive=true&IncludeItemTypes=Movie&Fields=Path,ParentId,Overview,Genres,Tags&SortBy=SortName&SortOrder=Ascending&api_key=000&deviceId=script)