Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/OCP_plugins_loading #103

Merged
merged 3 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ovos_plugin_common_play/ocp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ovos_workshop import OVOSAbstractApplication
from padacioso import IntentContainer
from threading import Event, Lock
from ovos_plugin_common_play.ocp.utils import ocp_plugins


class OCP(OVOSAbstractApplication):
Expand Down Expand Up @@ -75,6 +76,7 @@ def __init__(self, bus=None, lang=None, settings=None, skill_id=OCP_ID):
create_desktop_file()
except: # permission errors and stuff
pass
ocp_plugins() # trigger a load + caching of OCP plugins

def handle_ping(self, message):
"""
Expand Down
2 changes: 1 addition & 1 deletion ovos_plugin_common_play/ocp/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def extract_stream(self):
video = True
else:
video = False
meta = ocp_plugins.extract_stream(uri, video)
meta = ocp_plugins().extract_stream(uri, video)
# update media entry with new data
if meta:
LOG.info(f"OCP plugins metadata: {meta}")
Expand Down
6 changes: 2 additions & 4 deletions ovos_plugin_common_play/ocp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from os import makedirs
from os.path import expanduser, isfile, join, dirname, exists
from typing import List
from ovos_utils.system import module_property

from ovos_plugin_manager.ocp import StreamHandler
from ovos_plugin_common_play.ocp.status import TrackState, PlaybackType
Expand All @@ -12,8 +11,7 @@
_plugins = None


@module_property
def _ocp_plugins():
def ocp_plugins():
global _plugins
_plugins = _plugins or StreamHandler()
return _plugins
Expand Down Expand Up @@ -41,7 +39,7 @@ def available_extractors() -> List[str]:
@return: List of supported SEI prefixes
"""
return ["/", "http:", "https:", "file:"] + \
[f"{sei}//" for sei in _ocp_plugins().supported_seis]
[f"{sei}//" for sei in ocp_plugins().supported_seis]


def extract_metadata(uri):
Expand Down
4 changes: 0 additions & 4 deletions test/unittests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@


class TestUtils(unittest.TestCase):
def test_plugins_init(self):
from ovos_plugin_common_play.ocp.utils import ocp_plugins
from ovos_plugin_manager.ocp import StreamHandler
self.assertIsInstance(ocp_plugins, StreamHandler)

def test_available_extractors(self):
from ovos_plugin_common_play.ocp.utils import available_extractors
Expand Down
Loading