Skip to content

Commit

Permalink
feat: media type
Browse files Browse the repository at this point in the history
  • Loading branch information
martonborzak committed Jul 19, 2023
1 parent ccd5aa0 commit a0fea1d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion driver.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 11 additions & 0 deletions driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a0fea1d

Please sign in to comment.