-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Improved logging and printing messages - Logging logs to a file in ~/.baet (or equiv on Windows) - Fixed bugs preventing jobs from running correctly and some command line options from working as expected
- Loading branch information
TimeTravelPenguin
authored and
TimeTravelPenguin
committed
Jan 5, 2024
1 parent
b389460
commit ec4717c
Showing
11 changed files
with
503 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,71 @@ | ||
# Bulk Audio Extract Tool | ||
|
||
<img src="./images/help-preview.svg" alt="baet help screen" style="display: block; margin: auto; max-height: 500px"> | ||
|
||
## About | ||
|
||
Bulk Audio Extract Tool (BAET) is a commandline tool to bulk export audio tracks from within a single directory. | ||
|
||
## Install | ||
|
||
### Requirements | ||
|
||
BAET will run on Windows, macOS, and Linux. Listed below the pre-installation requirements: | ||
|
||
- FFmpeg ([website](https://ffmpeg.org)) | ||
- Python v3.11+ ([website](https://www.python.org)) | ||
|
||
### Installing BAET | ||
|
||
Installation is done via `pip`. | ||
Depending on your platform, to call python, you may need to use the command `python` or `python3`. | ||
Typing `python3 --version` or `python --version` should display the currently installed python environment your PATH. | ||
For the remainder of this document, replace instances of `python3` with the appropriate alias on your machine. | ||
For the remainder of this document, replace instances of `python` with the appropriate alias on your machine. | ||
|
||
To install the most recent stable release, use: | ||
|
||
```bash | ||
python -m pip install baet | ||
``` | ||
|
||
For pre-releases, use: | ||
|
||
```bash | ||
python -m pip install baet --pre | ||
``` | ||
|
||
To update/upgrade to a new version, use: | ||
|
||
```bash | ||
python -m pip install baet -U [--pre] | ||
``` | ||
|
||
To verify your install, call | ||
|
||
To install the requirements: | ||
```bash | ||
python3 -m pip install -r requirements.txt | ||
baet --version | ||
``` | ||
|
||
Then, call `./main.py --help` to see application information. | ||
## Usage | ||
|
||
## Add to Path | ||
Once installed, calling `baet --help` will display the general help screen, showing a list of options you can use. | ||
|
||
To simply extract the audio tracks of all videos in a directory `~/inputs`, | ||
and extract each into a subdirectory of `~/outputs`, call | ||
|
||
On Linux/MacOS, locate your `~/.bashrc` or `~/.zshrc` file and edit it, adding: | ||
```bash | ||
BAET_PATH="/path/to/BulkAudioExtractTool/main.py" | ||
alias baet="python3 $(BAET_PATH)" | ||
baet -i "~/inputs" -o "~/outputs" | ||
``` | ||
Restart your terminal and enter `baet --help`. The application's help screen should now show from any directory. | ||
|
||
Unless you add the option `--no-subdirs`, a video `~/inputs/my_video.mp4` will have each audio track individually | ||
exported to an audio file located in `./outputs/my_video/`. | ||
|
||
### Note on the help screen | ||
|
||
Currently, the help screen contains descriptions starting with `[TODO]`. | ||
This indicates that the associated option may or may not be implemented fully or at all. | ||
|
||
## Known issues | ||
|
||
- The option `--no-subdirs` may cause BAET to misbehave if two files are generated with the same name, | ||
unless the option `--overwrite` is given, in which case one file will be overwritten. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from ._console import app_console | ||
from ._logging import create_logger | ||
from ._logging import configure_logging, create_logger | ||
from ._theme import app_theme | ||
|
||
__all__ = ["app_console", "create_logger", "app_theme"] | ||
__all__ = ["app_console", "configure_logging", "create_logger", "app_theme"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import subprocess | ||
from os import PathLike | ||
|
||
from ._console import error_console | ||
from ._logging import create_logger | ||
|
||
logger = create_logger() | ||
|
||
|
||
def which_ffmpeg() -> str | PathLike[str] | None: | ||
from shutil import which | ||
|
||
return which("ffmpeg") | ||
|
||
|
||
def get_ffmpeg_version() -> str | None: | ||
try: | ||
ffmpeg = which_ffmpeg() | ||
|
||
if not ffmpeg: | ||
return None | ||
|
||
proc = subprocess.run([ffmpeg, "-version"], capture_output=True) | ||
|
||
if proc.returncode != 0: | ||
err = proc.stderr.decode("utf-8") | ||
raise RuntimeError(f"FFmpeg returned non-zero exit code when getting version:\n{err}") | ||
|
||
output = proc.stdout.decode("utf-8") | ||
return output[14 : output.find("Copyright")].strip() | ||
|
||
except RuntimeError as e: | ||
logger.critical("%s: %s", type(e).__name__, e) | ||
error_console.print_exception() | ||
raise e | ||
|
||
|
||
class FFmpegVersionInfo: | ||
def __init__(self) -> None: | ||
self._version: str | None = None | ||
|
||
@property | ||
def version(self) -> str: | ||
if not self._version: | ||
self._version = get_ffmpeg_version() | ||
|
||
return self._version or "None" | ||
|
||
def __str__(self) -> str: | ||
return self.version | ||
|
||
|
||
ffmpeg_version_info = FFmpegVersionInfo() | ||
|
||
if __name__ == "__main__": | ||
version_info = FFmpegVersionInfo() | ||
print("Version:", version_info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.