Esempio n. 1
0
def main():
    debug = '--debug' in sys.argv
    setup_logger(debug=debug)
    logger = logging.getLogger(__name__)
    logger.info('{} mode.'.format('Debug' if debug else 'Release'))

    pubsub_gateway, pubsub_server = run_pubsub()  # runs in another thread

    app = App()
    app.initialize()

    player = app.player

    live_lyric = LiveLyric()
    live_lyric_publisher = LiveLyricPublisher(pubsub_gateway)
    live_lyric.sentence_changed.connect(live_lyric_publisher.publish)
    player.position_changed.connect(live_lyric.on_position_changed)
    player.playlist.song_changed.connect(live_lyric.on_song_changed)

    event_loop = asyncio.get_event_loop()
    event_loop.create_task(run(app, live_lyric))

    try:
        event_loop.run_forever()
    except KeyboardInterrupt:
        # NOTE: gracefully shutdown?
        pubsub_server.close()
        event_loop.close()
Esempio n. 2
0
    def __init__(self):
        live_lyric = LiveLyric()
        live_lyric_publisher = LiveLyricPublisher(self.pubsub_gateway)

        self.live_lyric = live_lyric
        self._live_lyric_publisher = live_lyric_publisher

        live_lyric.sentence_changed.connect(live_lyric_publisher.publish)
        self.player.position_changed.connect(live_lyric.on_position_changed)
        self.playlist.song_changed.connect(live_lyric.on_song_changed)
Esempio n. 3
0
    def __init__(self, player_kwargs=None):
        self.player = Player(app=self, **(player_kwargs or {}))
        self.playlist = self.player.playlist
        self.library = Library()
        self.live_lyric = LiveLyric()

        self.protocol = FuoProcotol(self)

        self.plugin_mgr = PluginsManager(self)
        self.version_mgr = VersionManager(self)
Esempio n. 4
0
    def __init__(self):
        locale.setlocale(locale.LC_NUMERIC, 'C')
        self.player = MpvPlayer()
        self.player.initialize()
        self.playlist = self.player.playlist
        self.library = Library()
        self.live_lyric = LiveLyric()

        self.plugin_mgr = PluginsManager(self)
        self.version_mgr = VersionManager(self)
Esempio n. 5
0
def attach_attrs(app):
    """初始化 app 属性"""
    loop = asyncio.get_event_loop()
    app.library = Library(app.config.PROVIDERS_STANDBY)
    app.live_lyric = LiveLyric()
    player_kwargs = dict(
        audio_device=bytes(app.config.MPV_AUDIO_DEVICE, 'utf-8'))
    app.player = Player(app=app, **(player_kwargs or {}))
    app.playlist = app.player.playlist
    app.plugin_mgr = PluginsManager(app)
    app.request = Request()
    app.task_mgr = TaskManager(app, loop)
    app.fm = FM(app)

    if app.mode & (app.DaemonMode | app.GuiMode):
        app.version_mgr = VersionManager(app)

    if app.mode & app.DaemonMode:
        app.server = FuoServer(app)
        app.pubsub_gateway = PubsubGateway()
        app._ll_publisher = LiveLyricPublisher(app.pubsub_gateway)

    if app.mode & app.GuiMode:
        from feeluown.uimodels.provider import ProviderUiManager
        from feeluown.uimodels.playlist import PlaylistUiManager
        from feeluown.uimodels.my_music import MyMusicUiManager
        from feeluown.uimodels.collection import CollectionUiManager
        from feeluown.collection import CollectionManager

        from .browser import Browser
        from .hotkey import HotkeyManager
        from .image import ImgManager
        from .theme import ThemeManager
        from .tips import TipsManager
        from .ui import Ui
        from .tray import Tray

        # GUI 的一些辅助管理模块
        app.coll_mgr = CollectionManager(app)
        app.theme_mgr = ThemeManager(app)
        app.tips_mgr = TipsManager(app)
        app.hotkey_mgr = HotkeyManager(app)
        app.img_mgr = ImgManager(app)

        # GUI 组件的数据管理模块
        app.pvd_uimgr = ProviderUiManager(app)
        app.pl_uimgr = PlaylistUiManager(app)
        app.mymusic_uimgr = MyMusicUiManager(app)
        app.coll_uimgr = CollectionUiManager(app)

        app.browser = Browser(app)
        app.ui = Ui(app)
        if app.config.ENABLE_TRAY:
            app.tray = Tray(app)
        app.show_msg = app.ui.magicbox.show_msg
Esempio n. 6
0
async def test_no_song_changed():
    song = FakeSong()
    live_lyric = LiveLyric()
    live_lyric.on_song_changed(song)
    await asyncio.sleep(0.1)
    live_lyric.on_position_changed(60)
    assert live_lyric.current_sentence == '互いのすべてを 知りつくすまでが'
Esempio n. 7
0
 def test_all(self):
     song = FakeSong()
     live_lyric = LiveLyric()
     live_lyric.on_song_changed(song)
     live_lyric.on_position_changed(60)
     self.assertEqual(live_lyric.current_sentence,
                      '互いのすべてを 知りつくすまでが')
Esempio n. 8
0
def attach_attrs(app):
    """初始化 app 属性"""
    app.library = Library()
    app.live_lyric = LiveLyric()
    player_kwargs = dict(
        audio_device=bytes(app.config.MPV_AUDIO_DEVICE, 'utf-8')
    )
    app.player = Player(app=app, **(player_kwargs or {}))
    app.playlist = app.player.playlist
    app.plugin_mgr = PluginsManager(app)
    app.request = Request()
    app._g = {}

    if app.mode & (app.DaemonMode | app.GuiMode):
        app.version_mgr = VersionManager(app)

    if app.mode & app.GuiMode:
        from feeluown.widgets.collections import CollectionsModel
        from feeluown.uimodels.provider import ProviderUiManager
        from feeluown.uimodels.playlist import PlaylistUiManager
        from feeluown.uimodels.my_music import MyMusicUiManager
        from feeluown.collection import CollectionManager

        from .browser import Browser
        from .hotkey import HotkeyManager
        from .image import ImgManager
        from .theme import ThemeManager
        from .tips import TipsManager
        from .ui import Ui

        # GUI 的一些辅助管理模块
        app.coll_mgr = CollectionManager(app)
        app.theme_mgr = ThemeManager(app)
        app.tips_mgr = TipsManager(app)
        app.hotkey_mgr = HotkeyManager(app)
        app.img_mgr = ImgManager(app)

        # GUI 组件的数据管理模块
        app.pvd_uimgr = ProviderUiManager(app)
        app.pl_uimgr = PlaylistUiManager(app)
        app.mymusic_uimgr = MyMusicUiManager(app)

        app.collections = CollectionsModel(parent=app)

        app.browser = Browser(app)
        app.ui = Ui(app)
        app.show_msg = app.ui.magicbox.show_msg
Esempio n. 9
0
def attach_attrs(app, **player_kwargs):
    """初始化 app 属性"""
    app.library = Library()
    app.live_lyric = LiveLyric()
    app.protocol = FuoProcotol(app)
    app.plugin_mgr = PluginsManager(app)
    app.version_mgr = VersionManager(app)
    app.request = Request()
    app._g = {}

    app.player = Player(app=app, **(player_kwargs or {}))
    app.playlist = app.player.playlist

    if app.mode & app.GuiMode:
        from feeluown.widgets.collections import CollectionsModel
        from feeluown.uimodels.provider import ProviderUiManager
        from feeluown.uimodels.playlist import PlaylistUiManager
        from feeluown.uimodels.my_music import MyMusicUiManager
        from feeluown.protocol import CollectionManager

        from .browser import Browser
        from .hotkey import HotkeyManager
        from .image import ImgManager
        from .theme import ThemeManager
        from .tips import TipsManager
        from .ui import Ui

        # GUI 的一些辅助管理模块
        app.coll_mgr = CollectionManager(app)
        app.theme_mgr = ThemeManager(app)
        app.tips_mgr = TipsManager(app)
        app.hotkey_mgr = HotkeyManager(app)
        app.img_mgr = ImgManager(app)

        # GUI 组件的数据管理模块
        app.pvd_uimgr = ProviderUiManager(app)
        app.pl_uimgr = PlaylistUiManager(app)
        app.mymusic_uimgr = MyMusicUiManager(app)

        app.collections = CollectionsModel(parent=app)

        app.browser = Browser(app)
        app.ui = Ui(app)
        app.show_msg = app.ui.magicbox.show_msg