Fix capitalization of OwnTone integration (#88219)

This commit is contained in:
Brandon Rothweiler 2023-02-16 04:16:32 -05:00 committed by GitHub
parent c83ea297b5
commit 0748e12341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 26 deletions

View File

@ -43,7 +43,7 @@ CAN_EXPAND_TYPE = {
MEDIA_TYPE_DIRECTORY,
}
# The keys and values in the below dict are identical only because the
# HA constants happen to align with the Owntone constants.
# HA constants happen to align with the OwnTone constants.
OWNTONE_TYPE_TO_MEDIA_TYPE = {
"track": MediaType.TRACK,
"playlist": MediaType.PLAYLIST,
@ -58,13 +58,13 @@ MEDIA_TYPE_TO_OWNTONE_TYPE = {v: k for k, v in OWNTONE_TYPE_TO_MEDIA_TYPE.items(
# media_content_id is a uri in the form of SCHEMA:Title:OwnToneURI:Subtype (Subtype only used for Genre)
# OwnToneURI is in format library:type:id (for directories, id is path)
# media_content_type - type of item (mostly used to check if playable or can expand)
# Owntone type may differ from media_content_type when media_content_type is a directory
# Owntone type is used in our own branching, but media_content_type is used for determining playability
# OwnTone type may differ from media_content_type when media_content_type is a directory
# OwnTone type is used in our own branching, but media_content_type is used for determining playability
@dataclass
class MediaContent:
"""Class for representing Owntone media content."""
"""Class for representing OwnTone media content."""
title: str
type: str
@ -87,7 +87,7 @@ class MediaContent:
def create_owntone_uri(media_type: str, id_or_path: str) -> str:
"""Create an Owntone uri."""
"""Create an OwnTone uri."""
return f"library:{MEDIA_TYPE_TO_OWNTONE_TYPE[media_type]}:{quote(id_or_path)}"
@ -113,7 +113,7 @@ def is_owntone_media_content_id(media_content_id: str) -> bool:
def convert_to_owntone_uri(media_content_id: str) -> str:
"""Convert media_content_id to Owntone URI."""
"""Convert media_content_id to OwnTone URI."""
return ":".join(media_content_id.split(":")[2:-1])
@ -231,7 +231,7 @@ def create_browse_media_response(
for item in result:
if item.get("data_kind") == "spotify" or (
"path" in item and cast(str, item["path"]).startswith("spotify")
): # Exclude spotify data from Owntone library
): # Exclude spotify data from OwnTone library
continue
assert isinstance(item["uri"], str)
media_type = OWNTONE_TYPE_TO_MEDIA_TYPE[item["uri"].split(":")[1]]
@ -275,7 +275,7 @@ def create_browse_media_response(
def base_owntone_library() -> BrowseMedia:
"""Return the base of our Owntone library."""
"""Return the base of our OwnTone library."""
children = [
BrowseMedia(
title=name,
@ -290,10 +290,10 @@ def base_owntone_library() -> BrowseMedia:
for name, (media_class, media_type, media_subtype) in TOP_LEVEL_LIBRARY.items()
]
return BrowseMedia(
title="Owntone Library",
title="OwnTone Library",
media_class=MediaClass.APP,
media_content_id=create_media_content_id(
title="Owntone Library", media_type=MediaType.APP
title="OwnTone Library", media_type=MediaType.APP
),
media_content_type=MediaType.APP,
can_play=False,
@ -308,10 +308,10 @@ def library(other: Sequence[BrowseMedia] | None) -> BrowseMedia:
top_level_items = [
BrowseMedia(
title="Owntone Library",
title="OwnTone Library",
media_class=MediaClass.APP,
media_content_id=create_media_content_id(
title="Owntone Library", media_type=MediaType.APP
title="OwnTone Library", media_type=MediaType.APP
),
media_content_type=MediaType.APP,
can_play=False,
@ -323,7 +323,7 @@ def library(other: Sequence[BrowseMedia] | None) -> BrowseMedia:
top_level_items.extend(other)
return BrowseMedia(
title="Owntone",
title="OwnTone",
media_class=MediaClass.DIRECTORY,
media_content_id="",
media_content_type=MEDIA_TYPE_DIRECTORY,

View File

@ -30,7 +30,7 @@ DEFAULT_TTS_PAUSE_TIME = 1.2
DEFAULT_TTS_VOLUME = 0.8
DEFAULT_UNMUTE_VOLUME = 0.6
DOMAIN = "forked_daapd" # key for hass.data
FD_NAME = "Owntone"
FD_NAME = "OwnTone"
HASS_DATA_REMOVE_LISTENERS_KEY = "REMOVE_LISTENERS"
HASS_DATA_UPDATER_KEY = "UPDATER"
KNOWN_PIPES = {"librespot-java"}

View File

@ -1,6 +1,6 @@
{
"domain": "forked_daapd",
"name": "Owntone",
"name": "OwnTone",
"after_dependencies": ["spotify"],
"codeowners": ["@uvjustin"],
"config_flow": true,

View File

@ -3,7 +3,7 @@
"flow_title": "{name} ({host})",
"step": {
"user": {
"title": "Set up Owntone device",
"title": "Set up OwnTone device",
"data": {
"name": "Friendly name",
"host": "[%key:common::config_flow::data::host%]",
@ -13,23 +13,23 @@
}
},
"error": {
"forbidden": "Unable to connect. Please check your Owntone network permissions.",
"websocket_not_enabled": "Owntone server websocket not enabled.",
"forbidden": "Unable to connect. Please check your OwnTone network permissions.",
"websocket_not_enabled": "OwnTone server websocket not enabled.",
"wrong_host_or_port": "Unable to connect. Please check host and port.",
"wrong_password": "Incorrect password.",
"wrong_server_type": "The Owntone integration requires an Owntone server with version >= 27.0.",
"wrong_server_type": "The OwnTone integration requires an OwnTone server with version >= 27.0.",
"unknown_error": "[%key:common::config_flow::error::unknown%]"
},
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"not_forked_daapd": "Device is not an Owntone server."
"not_forked_daapd": "Device is not an OwnTone server."
}
},
"options": {
"step": {
"init": {
"title": "Configure Owntone options",
"description": "Set various options for the Owntone integration.",
"title": "Configure OwnTone options",
"description": "Set various options for the OwnTone integration.",
"data": {
"librespot_java_port": "Port for librespot-java pipe control (if used)",
"max_playlists": "Max number of playlists used as sources",

View File

@ -1739,7 +1739,7 @@
"iot_class": "cloud_polling"
},
"forked_daapd": {
"name": "Owntone",
"name": "OwnTone",
"integration_type": "hub",
"config_flow": true,
"iot_class": "local_push"

View File

@ -177,7 +177,7 @@ async def test_async_browse_media(
"""Browse the children of this BrowseMedia."""
nonlocal msg_id
for child in children:
# Assert Spotify content is not passed through as Owntone media
# Assert Spotify content is not passed through as OwnTone media
assert not (
is_owntone_media_content_id(child["media_content_id"])
and "Spotify" in MediaContent(child["media_content_id"]).title

View File

@ -355,7 +355,7 @@ def test_master_state(hass: HomeAssistant, mock_api_object) -> None:
"""Test master state attributes."""
state = hass.states.get(TEST_MASTER_ENTITY_NAME)
assert state.state == STATE_PAUSED
assert state.attributes[ATTR_FRIENDLY_NAME] == "Owntone server"
assert state.attributes[ATTR_FRIENDLY_NAME] == "OwnTone server"
assert state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORTED_FEATURES
assert not state.attributes[ATTR_MEDIA_VOLUME_MUTED]
assert state.attributes[ATTR_MEDIA_VOLUME_LEVEL] == 0.2
@ -414,7 +414,7 @@ async def test_zone(hass: HomeAssistant, mock_api_object) -> None:
"""Test zone attributes and methods."""
zone_entity_name = TEST_ZONE_ENTITY_NAMES[0]
state = hass.states.get(zone_entity_name)
assert state.attributes[ATTR_FRIENDLY_NAME] == "Owntone output (kitchen)"
assert state.attributes[ATTR_FRIENDLY_NAME] == "OwnTone output (kitchen)"
assert state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORTED_FEATURES_ZONE
assert state.state == STATE_ON
assert state.attributes[ATTR_MEDIA_VOLUME_LEVEL] == 0.5