Skip to content

Commit

Permalink
Added support for setting art mode mats
Browse files Browse the repository at this point in the history
  • Loading branch information
Farzad E committed May 28, 2022
1 parent a111f21 commit 8867c7a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
34 changes: 34 additions & 0 deletions example/art_remove_mats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys
import logging

sys.path.append('../')

from samsungtvws import SamsungTVWS

# Increase debug level
logging.basicConfig(level=logging.INFO)

# Normal constructor
tv = SamsungTVWS('192.168.xxx.xxx')

# Set all mats to this type
target_matte_type = 'none'

# Is art mode supported?
if not tv.art().supported():
logging.error('Art mode not supported')
sys.exit(1)

# List available mats for displaying art
matte_types = [matte_type for elem in tv.art().get_matte_list() for matte_type in elem.values()]
if target_matte_type not in matte_types:
logging.error('Invalid matte type: {}'.format(target_matte_type))
sys.exit(1)

# List the art available on the device
available_art = tv.art().available()

for art in available_art:
if art['matte_id'] != target_matte_type:
logging.info("Setting matte to %s for %s", target_matte_type, art['content_id'])
tv.art().change_matte(art['content_id'], target_matte_type)
19 changes: 19 additions & 0 deletions samsungtvws/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,22 @@ def set_photo_filter(self, content_id, filter_id):
"filter_id": filter_id,
}
)

def get_matte_list(self):
response = self._send_art_request(
{"request": "get_matte_list"},
wait_for_event=D2D_SERVICE_MESSAGE_EVENT,
)
assert response
data = json.loads(response["data"])

return json.loads(data["matte_type_list"])

def change_matte(self, content_id, matte_id):
self._send_art_request(
{
"request": "change_matte",
"content_id": content_id,
"matte_id": matte_id,
}
)

0 comments on commit 8867c7a

Please sign in to comment.