Release 2.3.2

- Added checks for log file and path
- Added command-line option for log file
- Added title metadata correction
- Added end_script function for more consistent ending of script
- Fixed metadata key case insensitive match
- Resolves TheCaptain989/lidarr-flac2mp3#42
- Update README.md
This commit is contained in:
TheCaptain989
2023-12-17 10:47:46 -06:00
parent 7c16d430d4
commit f9088e2451
2 changed files with 118 additions and 39 deletions
+46 -14
View File
@@ -16,11 +16,32 @@ Development Container info:
2. Configure the Docker container with all the port, volume, and environment settings from the *original container documentation* here:
**[linuxserver/lidarr](https://hub.docker.com/r/linuxserver/lidarr "Docker container")**
1. Add a **DOCKER_MODS** environment variable to the `docker run` command, as follows:
- Stable release: `-e DOCKER_MODS=linuxserver/mods:lidarr-flac2mp3`
- Dev/test release: `-e DOCKER_MODS=thecaptain989/lidarr-flac2mp3:latest`
1. Add a **DOCKER_MODS** environment variable to your `compose.yml` file or `docker run` command, as follows:
- Stable release: `DOCKER_MODS=linuxserver/mods:lidarr-flac2mp3`
- Dev/test release: `DOCKER_MODS=thecaptain989/lidarr-flac2mp3:latest`
*Example Docker CLI Configuration*
*Example Docker Compose YAML Configuration*
```yaml
version: "2.1"
services:
lidarr:
image: lscr.io/linuxserver/lidarr
container_name: lidarr
environment:
- PUID=1000
- PGID=1000
- TZ=America/Chicago
- DOCKER_MODS=linuxserver/mods:lidarr-flac2mp3
volumes:
- /path/to/appdata/config:/config
- /path/to/music:/music
- /path/to/downloads:/downloads
ports:
- 8686:8686
restart: unless-stopped
```
*Example Docker Run Command*
```shell
docker run -d \
--name=lidarr \
@@ -34,10 +55,10 @@ Development Container info:
-v /path/to/downloads:/downloads \
--restart unless-stopped \
lscr.io/linuxserver/lidarr
```
```
*Example Synology Configuration*
![flac2mp3](.assets/lidarr-synology.png "Synology container settings")
![flac2mp3](.assets/lidarr-synology.png "Synology container settings")
2. Start the container.
@@ -66,13 +87,12 @@ To supply arguments to the script, you **must** either use one of the **[include
The script may be called with optional command line arguments.
The syntax for the command line is:
`flac2mp3 [{-d|--debug} [<level>]] [{-b|--bitrate} <bitrate> | {-v|--quality} <quality> | {-a|--advanced} "<options>" {-e|--extension} <extension>] [{-f|--file} <audio_file>] [{-k|--keepfile}] [{-o|--output} <directory>] [{-r|--regex} '<regex>'] [{-t|--tags} <taglist>]`
`flac2mp3 [{-b|--bitrate} <bitrate> | {-v|--quality} <quality> | {-a|--advanced} "<options>" {-e|--extension} <extension>] [{-f|--file} <audio_file>] [{-k|--keep-file}] [{-o|--output} <directory>] [{-r|--regex} '<regex>'] [{-t|--tags} <taglist>] [{-l|--log} <log_file>] [{-d|--debug} [<level>]]`
Where:
Option|Argument|Description
---|---|---
-d, --debug|\[\<level\>\]|Enables debug logging. Level is optional.<br/>Default of 1 (low).<br/>2 includes JSON and FFmpeg output.<br/>3 contains even more JSON output.
-b, --bitrate|\<bitrate\>|Sets the output quality in constant bits per second (CBR).<br/>Examples: 160k, 240k, 300000<br/>**Note:** May not be specified with `-v`, `-a`, or `-e`.
-v, --quality|\<quality\>|Sets the output variable bit rate (VBR).<br/>Specify a value between 0 and 9, with 0 being the highest quality.<br/>See the [FFmpeg MP3 Encoding Guide](https://trac.ffmpeg.org/wiki/Encode/MP3) for more details.<br/>**Note:** May not be specified with `-b`, `-a`, or `-e`.
-a, --advanced|\"\<options\>\"|Advanced ffmpeg options.<br/>The specified `options` replace all script defaults and are sent directly to ffmpeg.<br/>The `options` value must be enclosed in quotes.<br/>See [FFmpeg Options](https://ffmpeg.org/ffmpeg.html#Options) for details on valid options, and [Guidelines for high quality audio encoding](https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio) for suggested usage.<br/>**Note:** Requires the `-e` option to also be specified. May not be specified with `-v` or `-b`.<br/>![warning] **WARNING:** You must specify an audio codec (by including a `-c:a <codec>` ffmpeg option) or the resulting file will contain no audio!<br/>![warning] **WARNING:** Invalid `options` could result in script failure!
@@ -81,7 +101,9 @@ Option|Argument|Description
-o, --output|\<directory\>|Converted audio file(s) are saved to `directory` instead of being located in the same directory as the source audio file.<br/>The path will be created if it does not exist.
-k, --keep-file| |Do not delete the source file or move it to the Lidarr Recycle bin.<br/>**Note:** This also disables importing the new files into Lidarr after conversion.
-r, --regex|'\<regex\>'|Sets the regular expression used to select input files.<br/>The `regex` value should be enclosed in single quotes and escaped properly.<br/>Defaults to `[.]flac$`.
-l, --log|\<log_file\>|The log filename<br/>Default of /config/log/flac2mp3.txt
-t, --tags|\<taglist\>|Comma separated list of metadata tags to apply automated corrections to.<br/>See [Metadata Corrections](./README.md#metadata-corrections) section.
-d, --debug|\[\<level\>\]|Enables debug logging. Level is optional.<br/>Default of 1 (low).<br/>2 includes JSON and FFmpeg output.<br/>3 contains even more JSON output.
--help| |Display help and exit.
--version| |Display version and exit.
@@ -159,7 +181,7 @@ Then put `/config/flac2mp3-custom.sh` in the **Path** field in place of `/usr/lo
### Environment Variable
The `flac2mp3.sh` script also allows the use of arguments provided by the `FLAC2MP3_ARGS` environment variable. This allows advanced use cases without having to provide a custom script.
For example, the following value would convert any .mp3 to Opus:
For example, the following value in your `docker run` command would convert any .mp3 to Opus:
```
-e FLAC2MP3_ARGS='-a "-vn -c:a libopus -b:a 192k" -e .opus -r "[.]mp3$"'
```
@@ -186,7 +208,7 @@ Using this function, you can easily process all of your audio files in any subdi
#### Script Execution Differences in Batch Mode
Because the script is not called from within Lidarr, expect the following behavior while in Batch Mode:
* *The file name must be specified on the command line*<br/>(The `-f` option places the script in Batch Mode)
* *The filename must be specified on the command line*<br/>(The `-f` option places the script in Batch Mode)
* *Lidarr APIs are not called and its database is not updated.*<br/>This may require a manual import of converted music files or an artist rescan.
* *Original audio files are deleted.*<br/>The Recycle Bin function is not available. (Modifiable using the `-k` option.)
@@ -197,22 +219,23 @@ find /music/ -type f -name "*.flac" | while read file; do /usr/local/bin/flac2mp
```
### Logs
A log file is created for the script activity called:
By default, a log file is created for the script activity called:
`/config/logs/flac2mp3.txt`
This log can be downloaded from Lidarr under *System* > *Log Files*
This log can be downloaded from Lidarr under *System* > *Log Files*. The log filename can be modified with the `--log` command-line option.
Log rotation is performed, with 5 log files of 1MB each kept, matching Lidarr's log retention.
>![danger] **NOTE:** If debug logging is enabled with a level above 1, the log file can grow very large very quickly and is much more likely to be rotated. *Do not leave high-level debug logging enabled permanently.*
#### Metadata Corrections
This feature is not meant for general purpose use. It is only documented for completeness.
This feature is not meant for general purpose use. It is only documented here for completeness.
List of supported tags and metadata corrections that are applied:
|Tag|Original|Correction
|---|---|---
|title|Parenthesis for live\|remix, etc. "()"|Square brackets "\[]"
|disc|1|1/1
|genre|/Pop/|"Pop"
| |/Indie/|"Alternative & Indie"
@@ -221,7 +244,16 @@ List of supported tags and metadata corrections that are applied:
| |/Punk\|Alternative/|"Alternative & Punk"
| |/Rock/|"Rock"
## Credits
# Uninstall
To completely remove the mod:
1. Delete the custom script from Lidarr's *Settings* > *Connect* screen that you created in the [Installation](./README.md#installation) section above.
2. Stop and delete the Lidarr container.
3. Exclude the **DOCKER_MODS** environment variable from your `compose.yaml` file or the `docker run` command when re-creating the Lidarr container.
___
# Credits
This would not be possible without the following:
[Lidarr](https://lidarr.audio/ "Lidarr homepage")