diff --git a/platypush/entities/alarm.py b/platypush/entities/alarm.py index fe68ed0d7d..6a93c3345b 100644 --- a/platypush/entities/alarm.py +++ b/platypush/entities/alarm.py @@ -28,6 +28,7 @@ if not is_defined('alarm'): snooze_interval = Column(Integer, nullable=True) actions = Column(JSON, nullable=True) static = Column(Boolean, nullable=False, default=False) + condition_type = Column(String, nullable=False) __table_args__ = {'extend_existing': True} __mapper_args__ = { diff --git a/platypush/utils/media.py b/platypush/utils/media.py index 2a6cde1e7b..bc1d8749b2 100644 --- a/platypush/utils/media.py +++ b/platypush/utils/media.py @@ -5,9 +5,17 @@ from platypush.context import get_plugin from platypush.plugins.media import MediaPlugin -def get_default_media_plugin() -> MediaPlugin: +audio_plugins = [ + 'sound', + 'music.mpd', +] + + +def get_default_media_plugin(video: bool = False) -> MediaPlugin: """ Get the default media plugin based on the current configuration. + + :param video: If True then the plugin must support video playback. """ enabled_plugins: List[MediaPlugin] = [] @@ -26,8 +34,20 @@ def get_default_media_plugin() -> MediaPlugin: if local_plugins: return local_plugins[0] - assert ( - enabled_plugins - ), f'No media plugin is enabled. Supported plugins: {MediaPlugin.supported_media_plugins}' + if enabled_plugins: + return enabled_plugins[0] - return enabled_plugins[0] + assert not video, ( + 'No media plugin with video support is enabled. ' + f'Supported plugins: {MediaPlugin.supported_media_plugins}' + ) + + for plugin_name in audio_plugins: + try: + plugin = get_plugin(plugin_name) + if plugin and plugin_name in cfg and not cfg[plugin_name].get('disabled'): + return plugin + except Exception: + pass + + raise AssertionError('No media plugin is enabled')