Skip to content

Commit

Permalink
imports
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Jan 6, 2024
1 parent 64513fe commit c787aa6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 138 deletions.
132 changes: 3 additions & 129 deletions ovos_workshop/decorators/ocp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# backwards compat imports
from ovos_utils.ocp import MediaType, PlayerState, MediaState, MatchConfidence,\
PlaybackType, PlaybackMode, LoopState, TrackState


def ocp_search():
Expand Down Expand Up @@ -124,132 +127,3 @@ def real_decorator(func):

return real_decorator


try:
from ovos_plugin_common_play.ocp.status import MediaType, PlayerState, \
MediaState, MatchConfidence, PlaybackType, PlaybackMode, LoopState, \
TrackState
except ImportError:

# TODO - manually keep these in sync as needed
# apps interfacing with OCP need the enums,
# but they are native to OCP does not make sense for OCP to import them from here,
# therefore we duplicate them when needed
from enum import IntEnum


class MatchConfidence(IntEnum):
EXACT = 95
VERY_HIGH = 90
HIGH = 80
AVERAGE_HIGH = 70
AVERAGE = 50
AVERAGE_LOW = 30
LOW = 15
VERY_LOW = 1


class TrackState(IntEnum):
DISAMBIGUATION = 1 # media result, not queued for playback

PLAYING_SKILL = 20 # Skill is handling playback internally
PLAYING_AUDIOSERVICE = 21 # Skill forwarded playback to audio service
PLAYING_VIDEO = 22 # Skill forwarded playback to gui player
PLAYING_AUDIO = 23 # Skill forwarded audio playback to gui player
PLAYING_MPRIS = 24 # External media player is handling playback
PLAYING_WEBVIEW = 25 # Media playback handled in browser (eg. javascript)

QUEUED_SKILL = 30 # Waiting playback to be handled inside skill
QUEUED_AUDIOSERVICE = 31 # Waiting playback in audio service
QUEUED_VIDEO = 32 # Waiting playback in gui
QUEUED_AUDIO = 33 # Waiting playback in gui
QUEUED_WEBVIEW = 34 # Waiting playback in gui


class MediaState(IntEnum):
# https://doc.qt.io/qt-5/qmediaplayer.html#MediaStatus-enum
# The status of the media cannot be determined.
UNKNOWN = 0
# There is no current media. PlayerState == STOPPED
NO_MEDIA = 1
# The current media is being loaded. The player may be in any state.
LOADING_MEDIA = 2
# The current media has been loaded. PlayerState== STOPPED
LOADED_MEDIA = 3
# Playback of the current media has stalled due to
# insufficient buffering or some other temporary interruption.
# PlayerState != STOPPED
STALLED_MEDIA = 4
# The player is buffering data but has enough data buffered
# for playback to continue for the immediate future.
# PlayerState != STOPPED
BUFFERING_MEDIA = 5
# The player has fully buffered the current media. PlayerState != STOPPED
BUFFERED_MEDIA = 6
# Playback has reached the end of the current media. PlayerState == STOPPED
END_OF_MEDIA = 7
# The current media cannot be played. PlayerState == STOPPED
INVALID_MEDIA = 8


class PlayerState(IntEnum):
# https://doc.qt.io/qt-5/qmediaplayer.html#State-enum
STOPPED = 0
PLAYING = 1
PAUSED = 2


class LoopState(IntEnum):
NONE = 0
REPEAT = 1
REPEAT_TRACK = 2


class PlaybackType(IntEnum):
SKILL = 0 # skills handle playback whatever way they see fit,
# eg spotify / mycroft common play
VIDEO = 1 # Video results
AUDIO = 2 # Results should be played audio only
AUDIO_SERVICE = 3 # Results should be played without using the GUI
MPRIS = 4 # External MPRIS compliant player
WEBVIEW = 5 # GUI webview, render a url instead of media player
UNDEFINED = 100 # data not available, hopefully status will be updated soon..


class PlaybackMode(IntEnum):
AUTO = 0 # play each entry as considered appropriate,
# ie, make it happen the best way possible
AUDIO_ONLY = 10 # only consider audio entries
VIDEO_ONLY = 20 # only consider video entries
FORCE_AUDIO = 30 # cast video to audio unconditionally
# (audio can still play in mycroft-gui)
FORCE_AUDIOSERVICE = 40 # cast everything to audio service backend,
# mycroft-gui will not be used
EVENTS_ONLY = 50 # only emit ocp events, do not display or play anything.
# allows integration with external interfaces


class MediaType(IntEnum):
GENERIC = 0
AUDIO = 1
MUSIC = 2
VIDEO = 3
AUDIOBOOK = 4
GAME = 5
PODCAST = 6
RADIO = 7
NEWS = 8
TV = 9
MOVIE = 10
TRAILER = 11
VISUAL_STORY = 13
BEHIND_THE_SCENES = 14
DOCUMENTARY = 15
RADIO_THEATRE = 16
SHORT_FILM = 17
SILENT_MOVIE = 18
BLACK_WHITE_MOVIE = 20
CARTOON = 21

ADULT = 69
HENTAI = 70
2 changes: 1 addition & 1 deletion ovos_workshop/skills/active.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class ActiveSkill(OVOSSkill):
def bind(self, bus):
super(ActiveSkill, self).bind(bus)
super().bind(bus)
if bus:
""" insert skill in active skill list on load """
self.make_active()
Expand Down
4 changes: 2 additions & 2 deletions ovos_workshop/skills/common_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, *args, **kwargs):
"https://github.com/OpenVoiceOS/ovos-ocp-audio-plugin/raw/master/" \
"ovos_plugin_common_play/ocp/res/ui/images/ocp.png"

self.ocp_matchers = {l: KeywordFeatures() for l in self.native_langs}
self.ocp_matchers = {l: KeywordFeatures(l) for l in self.native_langs}

def bind(self, bus):
"""Overrides the normal bind method.
Expand Down Expand Up @@ -191,7 +191,7 @@ def register_ocp_keyword(self, label: str, samples: List, langs: List[str] = Non
langs = langs or self.native_langs
for l in langs:
if l not in self.ocp_matchers:
self.ocp_matchers[l] = KeywordFeatures()
self.ocp_matchers[l] = KeywordFeatures(l)
self.ocp_matchers[l].register_entity(label, samples)

self.bus.emit(
Expand Down
4 changes: 2 additions & 2 deletions ovos_workshop/skills/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _remove_registered_handler(cls, wrapper_to_del: callable) -> bool:
del cls.fallback_handlers[priority]

if not found_handler:
LOG.warning('No fallback matching {}'.format(wrapper_to_del))
LOG.warning(f'No fallback matching {wrapper_to_del}')
return found_handler

@classmethod
Expand Down Expand Up @@ -439,7 +439,7 @@ def remove_fallback(self, handler_to_del: Optional[callable] = None) -> bool:
del self._fallback_handlers[i]

if not found_handler:
LOG.warning('No fallback matching {}'.format(handler_to_del))
LOG.warning(f'No fallback matching {handler_to_del}')
if len(self._fallback_handlers) == 0:
self.bus.emit(Message("ovos.skills.fallback.deregister",
{"skill_id": self.skill_id}))
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ovos-utils < 0.1.0, >=0.0.35
ovos-utils >= 0.1.0a7, < 0.2.0
ovos_config < 0.1.0,>=0.0.10
ovos-lingua-franca~=0.4,>=0.4.6
ovos-bus-client < 0.1.0, >=0.0.5
ovos-bus-client < 0.1.0, >=0.0.9a2
ovos_backend_client~=0.0,>=0.0.6
rapidfuzz
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def package_files(directory):

def required(requirements_file):
""" Read requirements file and remove comments and empty lines. """
with open(os.path.join(BASEDIR, requirements_file), 'r') as f:
with open(os.path.join(BASEDIR, requirements_file)) as f:
requirements = f.read().splitlines()
if 'MYCROFT_LOOSE_REQUIREMENTS' in os.environ:
print('USING LOOSE REQUIREMENTS!')
Expand All @@ -50,7 +50,7 @@ def required(requirements_file):


def get_description():
with open(os.path.join(BASEDIR, "README.md"), "r") as f:
with open(os.path.join(BASEDIR, "README.md")) as f:
long_description = f.read()
return long_description

Expand Down

0 comments on commit c787aa6

Please sign in to comment.