Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image proxy to Kodi media browser #47315

Merged
merged 10 commits into from
Mar 30, 2021
Merged

Conversation

cgtobi
Copy link
Contributor

@cgtobi cgtobi commented Mar 3, 2021

Proposed change

Add the image proxy to the Kodi media browser.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link

Hey there @OnFreund, mind taking a look at this pull request as its been labeled with an integration (kodi) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@cgtobi cgtobi marked this pull request as draft March 3, 2021 17:31
@cgtobi cgtobi added the waiting-for-upstream We're waiting for a change upstream label Mar 4, 2021
@cgtobi
Copy link
Contributor Author

cgtobi commented Mar 4, 2021

This requires OnFreund/PyKodi#9 to be merged and released.

@dshokouhi
Copy link
Member

will this also fix #39873 ? I saw it mentioned in the original issue :)

@OnFreund
Copy link
Contributor

OnFreund commented Mar 5, 2021

@cgtobi I released 0.2.3

@cgtobi cgtobi removed the waiting-for-upstream We're waiting for a change upstream label Mar 5, 2021
@cgtobi
Copy link
Contributor Author

cgtobi commented Mar 5, 2021

will this also fix #39873 ? I saw it mentioned in the original issue :)

I don't have such an instance to test this. I'd kindly ask you to spin up an instance from this branch if possible. Feedback would be greatly appreciated.

@cgtobi cgtobi force-pushed the kodi_image_proxy branch from 74b1d9b to 2e1973c Compare March 5, 2021 21:46
@dshokouhi
Copy link
Member

will this also fix #39873 ? I saw it mentioned in the original issue :)

I don't have such an instance to test this. I'd kindly ask you to spin up an instance from this branch if possible. Feedback would be greatly appreciated.

So yes and no. My TV Show library sometimes loads and sometimes does not. My Movies library never seems to load. Both errors look identical to me when it does not load. I have also included some logs so you can see it is indeed loading and working at one point. One thing I am not sure of if this is a separate error or not. The good news is that it does seem to be working to some extent!

Error when loading TV show or Movies
image

Registered

2021-03-05 16:19:05 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.kodi
2021-03-05 16:19:05 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new media_player.kodi entity: media_player.kodi_436f5f609b8668c5afb42276a4737847

Error when attempting to load Movies

2021-03-05 16:19:33 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140615827876592] Error handling message: Unknown error
Traceback (most recent call last):
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 128, in wait
    await self._event.wait()
  File "/usr/local/lib/python3.8/asyncio/locks.py", line 309, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 42, in send_message
    response = await pending_message.wait(self._timeout)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 129, in wait
    return self._response
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/async_timeout/__init__.py", line 45, in __exit__
    self._do_exit(exc_type)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/async_timeout/__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/c/dev/home-assistant/homeassistant/components/websocket_api/decorators.py", line 18, in _handle_async_response
    await func(hass, connection, msg)
  File "/mnt/c/dev/home-assistant/homeassistant/components/media_player/__init__.py", line 1068, in websocket_browse_media
    payload = await player.async_browse_media(media_content_type, media_content_id)
  File "/mnt/c/dev/home-assistant/homeassistant/components/kodi/media_player.py", line 904, in async_browse_media
    response = await build_item_response(self._kodi, payload, _get_thumbnail_url)
  File "/mnt/c/dev/home-assistant/homeassistant/components/kodi/browse_media.py", line 67, in build_item_response
    _, title, media = await get_media_info(media_library, search_id, search_type)
  File "/mnt/c/dev/home-assistant/homeassistant/components/kodi/browse_media.py", line 291, in get_media_info
    media = await media_library.get_movies(properties)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/pykodi/kodi.py", line 357, in get_movies
    return await self._server.VideoLibrary.GetMovies(
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 48, in send_message
    raise TransportError('Transport Error', message, exc)
jsonrpc_base.jsonrpc.TransportError: ("Error calling method 'VideoLibrary.GetMovies': Transport Error", TimeoutError())

Some warnings when TV show library loads:

2021-03-05 16:20:15 WARNING (MainThread) [homeassistant.components.media_player] Error retrieving proxied image from http://kodi:kodi@localhost:8080/image/image%3A%2F%2Fhttps%253a%252f%252fartworks.thetvdb.com%252fbanners%252fposters%252f295936-2.jpg%2F
2021-03-05 16:20:24 WARNING (MainThread) [homeassistant.components.media_player] Error retrieving proxied image from http://kodi:kodi@localhost:8080/image/image%3A%2F%2Fhttps%253a%252f%252fartworks.thetvdb.com%252fbanners%252fposters%252f71187-1.jpg%2F

Error when TV shows fails to load:

2021-03-05 16:20:44 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 128, in wait
    await self._event.wait()
  File "/usr/local/lib/python3.8/asyncio/locks.py", line 309, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 42, in send_message
    response = await pending_message.wait(self._timeout)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 129, in wait
    return self._response
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/async_timeout/__init__.py", line 45, in __exit__
    self._do_exit(exc_type)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/async_timeout/__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    with request.match_info.set_current_app(app):
  File "/mnt/c/dev/home-assistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/mnt/c/dev/home-assistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/mnt/c/dev/home-assistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/mnt/c/dev/home-assistant/homeassistant/components/http/auth.py", line 129, in auth_middleware
    return await handler(request)
  File "/mnt/c/dev/home-assistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/mnt/c/dev/home-assistant/homeassistant/components/media_player/__init__.py", line 969, in get
    data, content_type = await player.async_get_browse_image(
  File "/mnt/c/dev/home-assistant/homeassistant/components/kodi/media_player.py", line 915, in async_get_browse_image
    image_url, _, _ = await get_media_info(
  File "/mnt/c/dev/home-assistant/homeassistant/components/kodi/browse_media.py", line 297, in get_media_info
    media = await media_library.get_seasons(
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/pykodi/kodi.py", line 369, in get_seasons
    return await self._server.VideoLibrary.GetSeasons(
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 48, in send_message
    raise TransportError('Transport Error', message, exc)
jsonrpc_base.jsonrpc.TransportError: ("Error calling method 'VideoLibrary.GetSeasons': Transport Error", TimeoutError())

TV show library working
image

@cgtobi
Copy link
Contributor Author

cgtobi commented Mar 6, 2021

@dshokouhi please try the latest changes.

@dshokouhi
Copy link
Member

@dshokouhi please try the latest changes.

The TV show library has been loading every time I choose it now, the movie library is not but I think that is because I have a rather large library lol.

here is the error

2021-03-05 17:00:41 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139817451209392] Error handling message: Unknown error
Traceback (most recent call last):
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 128, in wait
    await self._event.wait()
  File "/usr/local/lib/python3.8/asyncio/locks.py", line 309, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 42, in send_message
    response = await pending_message.wait(self._timeout)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 129, in wait
    return self._response
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/async_timeout/__init__.py", line 45, in __exit__
    self._do_exit(exc_type)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/async_timeout/__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/c/dev/home-assistant/homeassistant/components/websocket_api/decorators.py", line 18, in _handle_async_response
    await func(hass, connection, msg)
  File "/mnt/c/dev/home-assistant/homeassistant/components/media_player/__init__.py", line 1068, in websocket_browse_media
    payload = await player.async_browse_media(media_content_type, media_content_id)
  File "/mnt/c/dev/home-assistant/homeassistant/components/kodi/media_player.py", line 903, in async_browse_media
    response = await build_item_response(self._kodi, payload, _get_thumbnail_url)
  File "/mnt/c/dev/home-assistant/homeassistant/components/kodi/browse_media.py", line 68, in build_item_response
    _, title, media = await get_media_info(media_library, search_id, search_type)
  File "/mnt/c/dev/home-assistant/homeassistant/components/kodi/browse_media.py", line 303, in get_media_info
    media = await media_library.get_movies(properties)
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/pykodi/kodi.py", line 357, in get_movies
    return await self._server.VideoLibrary.GetMovies(
  File "/mnt/c/dev/home-assistant/venv/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 48, in send_message
    raise TransportError('Transport Error', message, exc)
jsonrpc_base.jsonrpc.TransportError: ("Error calling method 'VideoLibrary.GetMovies': Transport Error", TimeoutError())

@cgtobi cgtobi force-pushed the kodi_image_proxy branch 2 times, most recently from afde455 to 9ffd486 Compare March 7, 2021 11:21
@cgtobi cgtobi marked this pull request as ready for review March 7, 2021 11:21
@cgtobi cgtobi force-pushed the kodi_image_proxy branch from 9ffd486 to 5a06ff5 Compare March 25, 2021 23:44
@cgtobi cgtobi added the bugfix label Mar 26, 2021
@balloob balloob merged commit 467bd91 into home-assistant:dev Mar 30, 2021
@cgtobi cgtobi deleted the kodi_image_proxy branch March 30, 2021 07:55
@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media Library no images Kodi media browser fails to load images with a deprecation notice for embedded login
5 participants