-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
/
Copy pathconst.py
180 lines (165 loc) · 6.56 KB
/
const.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
"""Constants for the DLNA DMR component."""
from __future__ import annotations
from collections.abc import Mapping
import logging
from typing import Final
from async_upnp_client.profiles.dlna import PlayMode as _PlayMode
from homeassistant.components.media_player import MediaType, RepeatMode
LOGGER = logging.getLogger(__package__)
DOMAIN: Final = "dlna_dmr"
CONF_LISTEN_PORT: Final = "listen_port"
CONF_CALLBACK_URL_OVERRIDE: Final = "callback_url_override"
CONF_POLL_AVAILABILITY: Final = "poll_availability"
CONF_BROWSE_UNFILTERED: Final = "browse_unfiltered"
DEFAULT_NAME: Final = "DLNA Digital Media Renderer"
CONNECT_TIMEOUT: Final = 10
PROTOCOL_HTTP: Final = "http-get"
PROTOCOL_RTSP: Final = "rtsp-rtp-udp"
PROTOCOL_ANY: Final = "*"
STREAMABLE_PROTOCOLS: Final = [PROTOCOL_HTTP, PROTOCOL_RTSP, PROTOCOL_ANY]
# Map UPnP class to media_player media_content_type
MEDIA_TYPE_MAP: Mapping[str, MediaType] = {
"object": MediaType.URL,
"object.item": MediaType.URL,
"object.item.imageItem": MediaType.IMAGE,
"object.item.imageItem.photo": MediaType.IMAGE,
"object.item.audioItem": MediaType.MUSIC,
"object.item.audioItem.musicTrack": MediaType.MUSIC,
"object.item.audioItem.audioBroadcast": MediaType.MUSIC,
"object.item.audioItem.audioBook": MediaType.PODCAST,
"object.item.videoItem": MediaType.VIDEO,
"object.item.videoItem.movie": MediaType.MOVIE,
"object.item.videoItem.videoBroadcast": MediaType.TVSHOW,
"object.item.videoItem.musicVideoClip": MediaType.VIDEO,
"object.item.playlistItem": MediaType.PLAYLIST,
"object.item.textItem": MediaType.URL,
"object.item.bookmarkItem": MediaType.URL,
"object.item.epgItem": MediaType.EPISODE,
"object.item.epgItem.audioProgram": MediaType.EPISODE,
"object.item.epgItem.videoProgram": MediaType.EPISODE,
"object.container": MediaType.PLAYLIST,
"object.container.person": MediaType.ARTIST,
"object.container.person.musicArtist": MediaType.ARTIST,
"object.container.playlistContainer": MediaType.PLAYLIST,
"object.container.album": MediaType.ALBUM,
"object.container.album.musicAlbum": MediaType.ALBUM,
"object.container.album.photoAlbum": MediaType.ALBUM,
"object.container.genre": MediaType.GENRE,
"object.container.genre.musicGenre": MediaType.GENRE,
"object.container.genre.movieGenre": MediaType.GENRE,
"object.container.channelGroup": MediaType.CHANNELS,
"object.container.channelGroup.audioChannelGroup": MediaType.CHANNELS,
"object.container.channelGroup.videoChannelGroup": MediaType.CHANNELS,
"object.container.epgContainer": MediaType.TVSHOW,
"object.container.storageSystem": MediaType.PLAYLIST,
"object.container.storageVolume": MediaType.PLAYLIST,
"object.container.storageFolder": MediaType.PLAYLIST,
"object.container.bookmarkFolder": MediaType.PLAYLIST,
}
# Map media_player media_content_type to UPnP class. Not everything will map
# directly, in which case it's not specified and other defaults will be used.
MEDIA_UPNP_CLASS_MAP: Mapping[MediaType | str, str] = {
MediaType.ALBUM: "object.container.album.musicAlbum",
MediaType.ARTIST: "object.container.person.musicArtist",
MediaType.CHANNEL: "object.item.videoItem.videoBroadcast",
MediaType.CHANNELS: "object.container.channelGroup",
MediaType.COMPOSER: "object.container.person.musicArtist",
MediaType.CONTRIBUTING_ARTIST: "object.container.person.musicArtist",
MediaType.EPISODE: "object.item.epgItem.videoProgram",
MediaType.GENRE: "object.container.genre",
MediaType.IMAGE: "object.item.imageItem",
MediaType.MOVIE: "object.item.videoItem.movie",
MediaType.MUSIC: "object.item.audioItem.musicTrack",
MediaType.PLAYLIST: "object.item.playlistItem",
MediaType.PODCAST: "object.item.audioItem.audioBook",
MediaType.SEASON: "object.item.epgItem.videoProgram",
MediaType.TRACK: "object.item.audioItem.musicTrack",
MediaType.TVSHOW: "object.item.videoItem.videoBroadcast",
MediaType.URL: "object.item.bookmarkItem",
MediaType.VIDEO: "object.item.videoItem",
}
# Translation of MediaMetadata keys to DIDL-Lite keys.
# See https://developers.google.com/cast/docs/reference/messages#MediaData via
# https://www.home-assistant.io/integrations/media_player/ for HA keys.
# See http://www.upnp.org/specs/av/UPnP-av-ContentDirectory-v4-Service.pdf for
# DIDL-Lite keys.
MEDIA_METADATA_DIDL: Mapping[str, str] = {
"subtitle": "longDescription",
"releaseDate": "date",
"studio": "publisher",
"season": "episodeSeason",
"episode": "episodeNumber",
"albumName": "album",
"trackNumber": "originalTrackNumber",
}
# For (un)setting repeat mode, map a combination of shuffle & repeat to a list
# of play modes in order of suitability. Fall back to _PlayMode.NORMAL in any
# case. NOTE: This list is slightly different to that in SHUFFLE_PLAY_MODES,
# due to fallback behaviour when turning on repeat modes.
REPEAT_PLAY_MODES: Mapping[tuple[bool, RepeatMode], list[_PlayMode]] = {
(False, RepeatMode.OFF): [
_PlayMode.NORMAL,
],
(False, RepeatMode.ONE): [
_PlayMode.REPEAT_ONE,
_PlayMode.REPEAT_ALL,
_PlayMode.NORMAL,
],
(False, RepeatMode.ALL): [
_PlayMode.REPEAT_ALL,
_PlayMode.REPEAT_ONE,
_PlayMode.NORMAL,
],
(True, RepeatMode.OFF): [
_PlayMode.SHUFFLE,
_PlayMode.RANDOM,
_PlayMode.NORMAL,
],
(True, RepeatMode.ONE): [
_PlayMode.REPEAT_ONE,
_PlayMode.RANDOM,
_PlayMode.SHUFFLE,
_PlayMode.NORMAL,
],
(True, RepeatMode.ALL): [
_PlayMode.RANDOM,
_PlayMode.REPEAT_ALL,
_PlayMode.SHUFFLE,
_PlayMode.NORMAL,
],
}
# For (un)setting shuffle mode, map a combination of shuffle & repeat to a list
# of play modes in order of suitability. Fall back to _PlayMode.NORMAL in any
# case.
SHUFFLE_PLAY_MODES: Mapping[tuple[bool, str], list[_PlayMode]] = {
(False, RepeatMode.OFF): [
_PlayMode.NORMAL,
],
(False, RepeatMode.ONE): [
_PlayMode.REPEAT_ONE,
_PlayMode.REPEAT_ALL,
_PlayMode.NORMAL,
],
(False, RepeatMode.ALL): [
_PlayMode.REPEAT_ALL,
_PlayMode.REPEAT_ONE,
_PlayMode.NORMAL,
],
(True, RepeatMode.OFF): [
_PlayMode.SHUFFLE,
_PlayMode.RANDOM,
_PlayMode.NORMAL,
],
(True, RepeatMode.ONE): [
_PlayMode.RANDOM,
_PlayMode.SHUFFLE,
_PlayMode.REPEAT_ONE,
_PlayMode.NORMAL,
],
(True, RepeatMode.ALL): [
_PlayMode.RANDOM,
_PlayMode.SHUFFLE,
_PlayMode.REPEAT_ALL,
_PlayMode.NORMAL,
],
}