From a0fea1de88d2ee7bdf27b58c6b5a8eaeb4a6fa04 Mon Sep 17 00:00:00 2001 From: Marton Date: Wed, 19 Jul 2023 09:49:38 +0200 Subject: [PATCH] feat: media type --- .github/workflows/build.yml | 2 +- driver.json | 2 +- driver.py | 11 +++++++++++ tv.py | 4 +++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a75d615..2274222 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,7 @@ jobs: docker run --name builder --platform=aarch64 -v ${GITHUB_WORKSPACE}:/io -d ubuntu:focal tail -f /dev/null docker exec builder bash -c "apt-get update && apt-get install -y python3-pip" - docker exec builder bash -c "cd /io/integration-python-library && python3 setup.py bdist_wheel && pip3 install -I dist/ucapi-0.0.6-py3-none-any.whl" + docker exec builder bash -c "cd /io/integration-python-library && python3 setup.py bdist_wheel && pip3 install -I dist/ucapi-0.0.7-py3-none-any.whl" docker exec builder bash -c "pip3 install pyinstaller -r /io/requirements.txt" docker exec builder bash -c "cd /io && pyinstaller --clean --onefile --name intg-appletv driver.py" diff --git a/driver.json b/driver.json index d1965b2..4c0ab9c 100644 --- a/driver.json +++ b/driver.json @@ -1,6 +1,6 @@ { "driver_id": "uc_appletv_driver", - "version": "0.8.0", + "version": "0.8.1", "min_core_api": "0.7.0", "name": { "en": "Apple TV" }, "icon": "custom:appletv.png", diff --git a/driver.py b/driver.py index 363adbe..02cbeaf 100644 --- a/driver.py +++ b/driver.py @@ -171,6 +171,7 @@ async def onError(message): entities.media_player.FEATURES.MEDIA_ARTIST, entities.media_player.FEATURES.MEDIA_ALBUM, entities.media_player.FEATURES.MEDIA_IMAGE_URL, + entities.media_player.FEATURES.MEDIA_TYPE, entities.media_player.FEATURES.HOME, entities.media_player.FEATURES.CHANNEL_SWITCHER, entities.media_player.FEATURES.DPAD, @@ -425,6 +426,15 @@ async def handleAppleTvUpdate(entityId, update): attributes[entities.media_player.ATTRIBUTES.SOURCE] = update['source'] if 'sourceList' in update: attributes[entities.media_player.ATTRIBUTES.SOURCE_LIST] = update['sourceList'] + if 'media_type' in update: + if update['media_type'] == pyatv.const.MediaType.Music: + attributes[entities.media_player.ATTRIBUTES.MEDIA_TYPE] = entities.media_player.MEDIA_TYPE.MUSIC + elif update['media_type'] == pyatv.const.MediaType.TV: + attributes[entities.media_player.ATTRIBUTES.MEDIA_TYPE] = entities.media_player.MEDIA_TYPE.TVSHOW + elif update['media_type'] == pyatv.const.MediaType.Video: + attributes[entities.media_player.ATTRIBUTES.MEDIA_TYPE] = entities.media_player.MEDIA_TYPE.VIDEO + elif update['media_type'] == pyatv.const.MediaType.Unknown: + attributes[entities.media_player.ATTRIBUTES.MEDIA_TYPE] = "" api.configuredEntities.updateEntityAttributes(entityId, attributes) @@ -461,6 +471,7 @@ async def main(): entities.media_player.FEATURES.MEDIA_ARTIST, entities.media_player.FEATURES.MEDIA_ALBUM, entities.media_player.FEATURES.MEDIA_IMAGE_URL, + entities.media_player.FEATURES.MEDIA_TYPE, entities.media_player.FEATURES.HOME, entities.media_player.FEATURES.CHANNEL_SWITCHER, entities.media_player.FEATURES.DPAD, diff --git a/tv.py b/tv.py index 9270607..fe5fe05 100644 --- a/tv.py +++ b/tv.py @@ -302,8 +302,10 @@ async def _processUpdate(self, data): else: update['album'] = "" + if data.media_type is not None: + update['media_type'] = data.media_type + # TODO: data.genre - # TODO: data.media_type: Music, Tv, Unknown, Video # TODO: data.repeat: All, Off, Track # TODO: data.shuffle