From db35ea171e147ed3d65bdab0e2f14caaf96582f9 Mon Sep 17 00:00:00 2001 From: kaliko Date: Thu, 10 Feb 2022 18:12:18 +0100 Subject: [PATCH] Add positional argument random, a random mode shortcut --- doc/Changelog | 7 +++++++ doc/source/index.rst | 7 +++++++ doc/source/man/mpd-sima.1.rst | 6 ++++++ sima/launch.py | 6 +++++- sima/utils/startopt.py | 6 +++++- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index b352718..4232d77 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,10 @@ +MPD_sima v0.18.2 + + * Add positional argument: + "random", a short cut to start in random mode + + -- kaliko UNRELEASED + MPD_sima v0.18.1 * Remove bad heuristic to infer artist aliases diff --git a/doc/source/index.rst b/doc/source/index.rst index a098a5a..b3dc0d8 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -30,6 +30,13 @@ suggestions but there are other possibilities, see :ref:`configuration-examples` mpd-sima --host mpd.example.org +**To start in random queuing mode:** + +.. code-block:: sh + + # Adds 5 tracks at random when there is only 1 track in the queue + mpd-sima random 5 + ##################### User's documentation ##################### diff --git a/doc/source/man/mpd-sima.1.rst b/doc/source/man/mpd-sima.1.rst index 5877bde..29d10f3 100644 --- a/doc/source/man/mpd-sima.1.rst +++ b/doc/source/man/mpd-sima.1.rst @@ -27,6 +27,8 @@ SYNOPSYS ``mpd-sima bl-delete id`` +``mpd-sima random [nbtracks]`` + DESCRIPTION ----------- @@ -154,6 +156,10 @@ Command arguments Remove blocklist entry referenced by its id. Use bloclist view command to get the id. +``random [nbtracks]`` + Starts in random mode overriding internal plugin configuration. If + `nbtracks` is provided, as many tracks will be queued (defaults to one). + ENVIRONMENT ----------- diff --git a/sima/launch.py b/sima/launch.py index 9c31397..179f1c4 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, 2014, 2015, 2020, 2021 kaliko +# Copyright (c) 2013, 2014, 2015, 2020-2022 kaliko # # This file is part of sima # @@ -136,6 +136,10 @@ def start(sopt, restart=False): sys.exit(1) SimaDB(db_path=db_file).purge_history(duration=0) sys.exit(0) + if cmd == 'random': + config['sima']['internal'] = 'Crop, Random' + if sopt.options.get('nbtracks'): + config['random']['track_to_add'] = str(sopt.options.get('nbtracks')) logger.info('Starting (%s)...', info.__version__) sima = core.Sima(config) diff --git a/sima/utils/startopt.py b/sima/utils/startopt.py index 7f3a5fe..c3fb161 100644 --- a/sima/utils/startopt.py +++ b/sima/utils/startopt.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2009-2015, 2021 kaliko +# Copyright (c) 2009-2015, 2022 kaliko # # This file is part of sima # @@ -114,6 +114,10 @@ CMDS = [ {'name': 'id', 'type': int, 'nargs': '?', 'help': 'blocklist ID to suppress (use bl-view to list IDs)'} ], 'help': 'Remove entries from the blocklist'}, + {'random': [ + {'name': 'nbtracks', 'type': int, 'nargs': '?', + 'help': 'Number of tracks to add'} + ], 'help': 'Start in random auto queuing'}, ] -- 2.39.5