From 940bb6ad6cbd823ed245577093bd8959e189d43f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 27 Jul 2016 02:27:23 +0200 Subject: Add music-path option to the command line --- helpers/__init__.py | 8 ++++++++ helpers/music_file.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/helpers/__init__.py b/helpers/__init__.py index 534e168..f1a968b 100644 --- a/helpers/__init__.py +++ b/helpers/__init__.py @@ -33,6 +33,10 @@ def parse_args(): default="config.yml", required=False, help="Config file to load") + parser.add_argument("-p", "--music-path", + default=".", + required=False, + help="Folder in which to find the music files") parser.add_argument("-d", "--debug", nargs=0, action=DebugModeAction, @@ -98,6 +102,10 @@ def parse_args(): Config.channels = args.channels Config.sample_width = args.sample_width Config.builtin_mixing = args.builtin_mixing + if args.music_path.endswith("/"): + Config.music_path = args.music_path + else: + Config.music_path = args.music_path + "/" class DebugModeAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): diff --git a/helpers/music_file.py b/helpers/music_file.py index ba86142..916b955 100644 --- a/helpers/music_file.py +++ b/helpers/music_file.py @@ -104,7 +104,7 @@ class MusicFile: debug_print("Reloading « {} »".format(self.name)) initial_db_gain = gain(self.initial_volume_factor * 100) self.audio_segment = pydub.AudioSegment \ - .from_file(self.filename) \ + .from_file(Config.music_path + self.filename) \ .set_frame_rate(Config.frame_rate) \ .set_channels(Config.channels) \ .set_sample_width(Config.sample_width) \ @@ -125,7 +125,7 @@ class MusicFile: self.mixer = self.mapping.mixer or Mixer() initial_db_gain = gain(self.initial_volume_factor * 100) self.audio_segment = pydub.AudioSegment \ - .from_file(self.filename) \ + .from_file(Config.music_path + self.filename) \ .set_frame_rate(Config.frame_rate) \ .set_channels(Config.channels) \ .set_sample_width(Config.sample_width) \ -- cgit v1.2.3