install script

This commit is contained in:
tdeerenberg
2023-01-25 02:37:40 +01:00
parent 8d7cd3fe08
commit f3ad5eea1f
3 changed files with 18 additions and 7 deletions

5
install.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
# Make sure to add ~/.local/bin to $PATH
pip3 install -r requirements.txt
cp src/musort.py ~/.local/bin/musort
echo "IF NOT DONE ALREADY, ADD '~/local/bin' TO $ PATH"

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
TinyTag

View File

@ -8,8 +8,9 @@ import os
import sys, getopt import sys, getopt
import logging import logging
version = "Musort v0.1 (c) tdeerenberg"
help=\ help=\
"""Musort © 2023 tdeerenberg (github.com/tdeerenberg) """Musort (c) 2023 tdeerenberg (github.com/tdeerenberg)
DESCRIPTION: DESCRIPTION:
A Python3 program that renames all selected music/audio files in a folder with a specified naming convention A Python3 program that renames all selected music/audio files in a folder with a specified naming convention
@ -27,6 +28,7 @@ OPTIONAL OPTIONS:
-s, --separator Set the separator for the filename (ex. '-s .' -> 01.track.flac and '-s -' -> 01-track.mp3) -s, --separator Set the separator for the filename (ex. '-s .' -> 01.track.flac and '-s -' -> 01-track.mp3)
Default separator ( . ) will be used if none is given Default separator ( . ) will be used if none is given
-r, --recursive Rename files in subdirectories as well -r, --recursive Rename files in subdirectories as well
-v, --version Prints the version number
NAMING CONVENTION: NAMING CONVENTION:
FORMAT_OPTION.FORMAT_OPTION... The amount of format options does not matter. FORMAT_OPTION.FORMAT_OPTION... The amount of format options does not matter.
@ -192,23 +194,26 @@ def main():
"""Runs the whole program""" """Runs the whole program"""
argv = sys.argv[3:] argv = sys.argv[3:]
try: try:
opts, args = getopt.getopt(argv, "s:rh", ["sep=", "recursive=", "help="]) opts, args = getopt.getopt(argv, "s:r", ["sep=", "recursive="])
except getopt.GetoptError as err: except getopt.GetoptError as err:
logging.error(err) logging.error(err)
exit() exit()
music = Music() music = Music()
for opt, arg in opts: for opt, arg in opts:
if opt in ['-h']: if opt in ['-s', '--separator']:
print(help)
exit()
if opt in ['-s']:
logging.info(f"Using {arg} as separator") logging.info(f"Using {arg} as separator")
music.set_separator(arg) music.set_separator(arg)
if opt in ['-r']: if opt in ['-r', '--recursive']:
logging.info("Running recursively") logging.info("Running recursively")
music.get_compatible_recursive(sys.argv[1]) music.get_compatible_recursive(sys.argv[1])
if sys.argv[1] == "-h" or sys.argv[1] == '--help':
print(help)
exit()
if sys.argv[1] == '-v' or sys.argv[1] == '--version':
print(version)
exit()
try: try:
music.compatible music.compatible
except: except: