diff --git a/openlp/core/common/json.py b/openlp/core/common/json.py index 6f815aefa..4a54e41b3 100644 --- a/openlp/core/common/json.py +++ b/openlp/core/common/json.py @@ -23,7 +23,6 @@ from contextlib import suppress from json import JSONDecoder, JSONEncoder from pathlib import Path - _registered_classes = {} diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 59cb1cdcf..eee11b970 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -589,7 +589,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): """ Add this item to the current service. - :param item: Item to be processed + :param QtWidgets.QListWidgetItem | QtWidgets.QTreeWidgetItem | None item: Item to be processed :param replace: Replace the existing item :param remote: Triggered from remote :param position: Position to place item @@ -627,7 +627,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): def build_service_item(self, item=None, remote=False, context=ServiceItemContext.Live): """ Common method for generating a service item - :param item: Service Item to be built. + :param QtWidgets.QListWidgetItem | QtWidgets.QTreeWidgetItem | None item: Service Item to be built. :param remote: Remote triggered (False) :param context: The context on which this is called """ diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 4cb2a8e79..4f4400f81 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -44,7 +44,7 @@ from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui import DisplayControllerType from openlp.core.ui.media import MediaState, ItemMediaInfo, MediaType, parse_optical_path from openlp.core.ui.media.endpoint import media_endpoint -from openlp.core.ui.media.vlcplayer import VlcPlayer, get_vlc +from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT, VlcPlayer, get_vlc log = logging.getLogger(__name__) @@ -65,11 +65,6 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): current_media_players is an array of player instances keyed on ControllerType. """ - def __init__(self, parent=None): - """ - Constructor - """ - super(MediaController, self).__init__(parent) def setup(self): self.vlc_player = None @@ -95,26 +90,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): Registry().register_function('songs_hide', self.media_hide) Registry().register_function('songs_blank', self.media_blank) Registry().register_function('songs_unblank', self.media_unblank) - Registry().register_function('mediaitem_suffixes', self._generate_extensions_lists) register_endpoint(media_endpoint) - def _generate_extensions_lists(self): - """ - Set the active players and available media files - """ - suffix_list = [] - self.audio_extensions_list = [] - for item in self.vlc_player.audio_extensions_list: - if item not in self.audio_extensions_list: - self.audio_extensions_list.append(item) - suffix_list.append(item[2:]) - self.video_extensions_list = [] - for item in self.vlc_player.video_extensions_list: - if item not in self.video_extensions_list: - self.video_extensions_list.append(item) - suffix_list.append(item[2:]) - self.service_manager.supported_suffixes(suffix_list) - def bootstrap_initialise(self): """ Check to see if we have any media Player's available. @@ -129,7 +106,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): else: State().missing_text('media_live', translate('OpenLP.SlideController', 'VLC or pymediainfo are missing, so you are unable to play any media')) - self._generate_extensions_lists() + self.service_manager.supported_suffixes(ext[2:] for ext in AUDIO_EXT) + self.service_manager.supported_suffixes(ext[2:] for ext in VIDEO_EXT) return True def bootstrap_post_set_up(self): @@ -379,7 +357,7 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): if file.is_file: suffix = '*%s' % file.suffix.lower() file = str(file) - if suffix in self.vlc_player.video_extensions_list: + if suffix in VIDEO_EXT: if not controller.media_info.is_background or controller.media_info.is_background and \ self.vlc_player.can_background: self.resize(display, self.vlc_player) @@ -387,7 +365,7 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): self.current_media_players[controller.controller_type] = self.vlc_player controller.media_info.media_type = MediaType.Video return True - if suffix in self.vlc_player.audio_extensions_list: + if suffix in AUDIO_EXT: if self.vlc_player.load(display, file): self.current_media_players[controller.controller_type] = self.vlc_player controller.media_info.media_type = MediaType.Audio diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 9eb186665..3c0b7e873 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -42,8 +42,6 @@ class MediaPlayer(RegistryProperties): self.can_folder = False self.state = {0: MediaState.Off, 1: MediaState.Off} self.has_own_widget = False - self.audio_extensions_list = [] - self.video_extensions_list = [] def check_available(self): """ diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 6ba27998b..3f7deac75 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -109,8 +109,6 @@ class VlcPlayer(MediaPlayer): self.display_name = '&VLC' self.parent = parent self.can_folder = True - self.audio_extensions_list = AUDIO_EXT - self.video_extensions_list = VIDEO_EXT def setup(self, output_display, live_display): """ diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 0dfb53aab..7394409fa 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -32,7 +32,6 @@ from openlp.core.common.mixins import RegistryProperties from openlp.core.common.registry import Registry from openlp.core.lib.theme import BackgroundGradientType, BackgroundType from openlp.core.lib.ui import critical_error_message_box -# TODO: Fix this. Use a "get_video_extensions" method which uses the current media player from openlp.core.ui.media.vlcplayer import VIDEO_EXT from openlp.core.ui.themelayoutform import ThemeLayoutForm from openlp.core.ui.themewizard import Ui_ThemeWizard diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 658773b99..2d66eabe9 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -38,7 +38,7 @@ from openlp.core.lib.serviceitem import ItemCapabilities from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.icons import UiIcons from openlp.core.ui.media import parse_optical_path, format_milliseconds -from openlp.core.ui.media.vlcplayer import get_vlc +from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT, get_vlc if get_vlc() is not None: @@ -233,8 +233,8 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): # self.populate_display_types() self.on_new_file_masks = translate('MediaPlugin.MediaItem', 'Videos ({video});;Audio ({audio});;{files} ' - '(*)').format(video=' '.join(self.media_controller.video_extensions_list), - audio=' '.join(self.media_controller.audio_extensions_list), + '(*)').format(video=' '.join(VIDEO_EXT), + audio=' '.join(AUDIO_EXT), files=UiStrings().AllFiles) def on_delete_click(self): @@ -301,9 +301,9 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): media_file_paths = Settings().value(self.settings_section + '/media files') media_file_paths.sort(key=lambda file_path: get_natural_key(file_path.name)) if media_type == MediaType.Audio: - extension = self.media_controller.audio_extensions_list + extension = AUDIO_EXT else: - extension = self.media_controller.video_extensions_list + extension = VIDEO_EXT # TODO: Rename extension to extensions extension = [x[1:] for x in extension] media = [x for x in media_file_paths if x.suffix in extension] return media diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index 311bfa711..37a64162f 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -43,7 +43,7 @@ class OpenLyricsExport(RegistryProperties): """ def __init__(self, parent, songs, save_path): """ - Initialise the export. + Initialise the export :param pathlib.Path save_path: The directory to save the exported songs in :rtype: None diff --git a/tests/functional/openlp_core/common/test_path.py b/tests/functional/openlp_core/common/test_path.py index 55b5b70de..5b983bc20 100644 --- a/tests/functional/openlp_core/common/test_path.py +++ b/tests/functional/openlp_core/common/test_path.py @@ -22,7 +22,6 @@ """ Package to test the openlp.core.common.path package. """ -# TODO: fix patches import os from pathlib import Path from unittest import TestCase diff --git a/tests/functional/openlp_core/ui/media/test_mediacontroller.py b/tests/functional/openlp_core/ui/media/test_mediacontroller.py index a1a1122a1..2389d8a34 100644 --- a/tests/functional/openlp_core/ui/media/test_mediacontroller.py +++ b/tests/functional/openlp_core/ui/media/test_mediacontroller.py @@ -43,25 +43,6 @@ class TestMediaController(TestCase, TestMixin): Registry.create() Registry().register('service_manager', MagicMock()) - def test_generate_extensions_lists(self): - """ - Test that the extensions are create correctly - """ - # GIVEN: A MediaController and an active player with audio and video extensions - media_controller = MediaController() - media_controller.vlc_player = VlcPlayer(None) - media_controller.vlc_player.audio_extensions_list = ['*.mp3', '*.wav', '*.wma', '*.ogg'] - media_controller.vlc_player.video_extensions_list = ['*.mp4', '*.mov', '*.avi', '*.ogm'] - - # WHEN: calling _generate_extensions_lists - media_controller._generate_extensions_lists() - - # THEN: extensions list should have been copied from the player to the mediacontroller - assert media_controller.video_extensions_list == media_controller.video_extensions_list, \ - 'Video extensions should be the same' - assert media_controller.audio_extensions_list == media_controller.audio_extensions_list, \ - 'Audio extensions should be the same' - def test_resize(self): """ Test that the resize method is called correctly diff --git a/tests/functional/openlp_core/ui/media/test_vlcplayer.py b/tests/functional/openlp_core/ui/media/test_vlcplayer.py index d3de03758..75828de8d 100644 --- a/tests/functional/openlp_core/ui/media/test_vlcplayer.py +++ b/tests/functional/openlp_core/ui/media/test_vlcplayer.py @@ -95,8 +95,6 @@ class TestVLCPlayer(TestCase, TestMixin): assert '&VLC' == vlc_player.display_name assert vlc_player.parent is None assert vlc_player.can_folder is True - assert AUDIO_EXT == vlc_player.audio_extensions_list - assert VIDEO_EXT == vlc_player.video_extensions_list @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.is_macosx')