Skip to content

Commit e9cc0a2

Browse files
committed
Release 2.3.5
1 parent a3e79f3 commit e9cc0a2

File tree

2 files changed

+105
-56
lines changed

2 files changed

+105
-56
lines changed

README.md

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Development Container info:
2121
- Dev/test release: `DOCKER_MODS=thecaptain989/lidarr-flac2mp3:latest`
2222

2323
*Example Docker Compose YAML Configuration*
24+
2425
```yaml
2526
version: "2.1"
2627
services:
@@ -42,6 +43,7 @@ Development Container info:
4243
```
4344
4445
*Example Docker Run Command*
46+
4547
```shell
4648
docker run -d \
4749
--name=lidarr \
@@ -70,23 +72,21 @@ Development Container info:
7072

7173
This will use the defaults to create a 320Kbps MP3 file.
7274

73-
*For any other setting, you **must** use one of the supported methods to pass arguments to the script. See the [Syntax](./README.md#syntax) section below.*
75+
*For any other setting, you **must** use one of the supported methods to pass arguments to the script. See the [Command-Line Syntax](./README.md#command-line-syntax) section below.*
7476

75-
## Usage
76-
New file(s) will be placed in the same directory as the original FLAC file(s) (unless redirected with the `--output` option below) and have the same owner and permissions. Existing files with the same track name will be overwritten.
77+
# Usage
78+
New file(s) will be placed in the same directory as the original FLAC file(s) (unless redirected with the `--output` option below) with permissions preserved. Existing files with the same track name will be overwritten. Owner is preserved if the script is executed as root.
7779

7880
By default, if you've configured Lidarr's **Recycle Bin** path correctly, the original audio file will be moved there.
7981
![danger] **NOTE:** If you have *not* configured the Recycle Bin, the original FLAC audio file(s) will be deleted and permanently lost. This behavior may be modified with the `--keep-file` option.
8082

81-
### Syntax
82-
>**Note:** The _Arguments_ field for Custom Scripts was removed in Lidarr release [v0.7.0.1347](https://github.com/lidarr/Lidarr/commit/b9d240924f8965ebb2c5e307e36b810ae076101e "Lidarr commit notes") due to security concerns.
83-
84-
To supply arguments to the script, you **must** either use one of the **[included wrapper scripts](./README.md#included-wrapper-scripts)**, create a **[custom wrapper script](./README.md#example-wrapper-script)**, or set the `FLAC2MP3_ARGS` **[environment variable](./README.md#environment-variable)**.
83+
## Command-Line Syntax
84+
>**Note:** The *Arguments* field for Custom Scripts was removed in Lidarr release [v0.7.0.1347](https://github.com/lidarr/Lidarr/commit/b9d240924f8965ebb2c5e307e36b810ae076101e "Lidarr commit notes") due to security concerns.
8585

86-
#### Command Line Options and Arguments
87-
The script may be called with optional command line arguments.
86+
### Options and Arguments
87+
The script may be called with optional command-line arguments.
8888

89-
The syntax for the command line is:
89+
The syntax for the command-line is:
9090
`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>]]`
9191

9292
Where:
@@ -95,7 +95,7 @@ Option|Argument|Description
9595
---|---|---
9696
-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`.
9797
-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`.
98-
-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!
98+
-a, --advanced<!-- markdownlint-disable-line MD013 -->|\"\<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!
9999
-e, --extension|\<extension\>|Sets the output file extension.<br/>The extension may be prefixed by a dot (".") or not.<br/>Example: .ogg<br/>**Note:** Requires the `-a` option to also be specified. May not be specified with `-v` or `-b`.
100100
-f, --file|<audio_file>|If included, the script enters **[Batch Mode](./README.md#batch-mode)** and converts the specified audio file.<br/>![warning] **WARNING:** Do not use this argument when called from Lidarr!
101101
-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.
@@ -110,29 +110,36 @@ Option|Argument|Description
110110
If neither `-b`, `-v`, `-a`, or `-e` options are specified, the script will default to a constant 320Kbps MP3.
111111

112112
#### Technical notes on advanced options
113-
The `-a` option effectively makes the script a generic wrapper for ffmpeg. FFmpeg is executed once per track with only the loglevel, input filename, and output filename being set. All other options are passed unparsed to the command line.
113+
The `-a` option effectively makes the script a generic wrapper for ffmpeg. FFmpeg is executed once per track with only the loglevel, input filename, and output filename being set. All other options are passed unparsed to the command-line.
114114

115115
The exact format of the executed ffmpeg command is:
116-
```
116+
117+
```shell
117118
ffmpeg -loglevel error -nostdin -i "input.flac" ${options} "output.${extension}"
118119
```
119120

120-
#### Technical notes on regex
121-
By default, the script only matches and interacts with FLAC files (specifically, files ending in ".flac"). The `-r` option allows the script to match on a user specified regular expression (i.e. "regex") pattern.
121+
#### Technical notes on regular expressions
122+
<!-- textlint-disable terminology -->
122123

123-
Files are passed to the script with the full Linux path intact. (Ex: `/path/to/audio/a-ha/Hunting High and Low/01 Take on Me.mp3`). Craft your regex with this in mind.
124+
By default, the script only matches and interacts with FLAC files (specifically, files ending in ".flac"). The `-r` option allows the script to match on a user specified regular expression (i.e. "regex") pattern.
124125

125-
![warning] **NOTE:** Escaping special regex characters (like a dot `.`) requires a double backslash or a character class. A character class (i.e. `[.]`) is recommended because backslashes can be stripped by the bash shell and getting this right can be confusing.
126+
<!-- textlint-enable -->
127+
128+
Files are passed to the script with the full Linux path intact. (Ex: `/path/to/audio/a-ha/Hunting High and Low/01 Take on Me.mp3`). Craft your regular expression with this in mind.
129+
130+
![warning] **NOTE:** Escaping special regular expression characters (like a dot `.`) requires a double backslash or a character class. A character class (i.e. `[.]`) is recommended because backslashes can be stripped by the bash shell and getting this right can be confusing.
126131

127132
For example, to convert all audio files to AAC audio files, use the following options:
128-
```
133+
134+
```shell
129135
-a "-y -map 0 -c:a aac -b:a 240k -c:v copy" -e m4a --regex '[.][^.]*$'
130136
```
131137

132-
Regular expression syntax is beyond the scope of this document. See this [tutorial](https://www.regular-expressions.info/tutorial.html "Regular Expressions Tutorial") for more information. Regex patterns may be tested [here](http://regexstorm.net/tester "regex tester").
138+
Regular expression syntax is beyond the scope of this document. See this [tutorial](https://www.regular-expressions.info/tutorial.html "Regular Expressions Tutorial") for more information. Regular expression patterns may be tested [here](http://regexstorm.net/tester "regex tester").
133139

134-
### Examples
135-
```
140+
## Examples
141+
142+
```shell
136143
-b 320k # Output 320 kbit/s MP3 (non-VBR; same as default behavior)
137144
-v 0 # Output variable bitrate MP3, VBR 220-260 kbit/s
138145
-d -b 160k # Enable debugging level 1, and output a 160 kbit/s MP3
@@ -150,26 +157,32 @@ Regular expression syntax is beyond the scope of this document. See this [tutor
150157
# Place the converted file(s) in the specified directory and do not delete the original audio file(s)
151158
```
152159

153-
#### Included Wrapper Scripts
160+
## Wrapper Scripts
161+
To supply arguments to the script, you must either use one of the included wrapper scripts, create a custom wrapper script, or set the `FLAC2MP3_ARGS` [environment variable](./README.md#environment-variable).
162+
163+
### Included Wrapper Scripts
154164
For your convenience, several wrapper scripts are included in the `/usr/local/bin/` directory.
155165
You may use any of these scripts in place of the `flac2mp3.sh` mentioned in the [Installation](./README.md#installation) section above.
156166

157-
```
167+
```shell
158168
flac2mp3-debug.sh # Enable debugging, level 1
159169
flac2mp3-debug-2.sh # Enable debugging, level 2
160170
flac2mp3-vbr.sh # Use variable bit rate MP3, quality 0
161171
flac2opus.sh # Convert to Opus format using .opus extension, 192 kbit/s, no covert art
162172
flac2alac.sh # Convert to Apple Lossless using an .m4a extension
163173
```
164174

165-
#### Example Wrapper Script
175+
### Example Wrapper Script
166176
To configure an entry from the [Examples](./README.md#examples) section above, create and save a file called `flac2mp3-custom.sh` to `/config` containing the following text:
177+
167178
```shell
168179
#!/bin/bash
169180
170181
. /usr/local/bin/flac2mp3.sh -d -b 160k
171182
```
183+
172184
Make it executable:
185+
173186
```shell
174187
chmod +x /config/flac2mp3-custom.sh
175188
```
@@ -178,16 +191,18 @@ Then put `/config/flac2mp3-custom.sh` in the **Path** field in place of `/usr/lo
178191

179192
>**Note:** If you followed the Linuxserver.io recommendations when configuring your container, the `/config` directory will be mapped to an external storage location. It is therefore recommended to place custom scripts in the `/config` directory so they will survive container updates, but they may be placed anywhere that is accessible by Lidarr.
180193

181-
### Environment Variable
194+
## Environment Variable
182195
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.
183196

184197
For example, the following value in your `docker run` command would convert any .mp3 to Opus:
185-
```
198+
199+
```shell
186200
-e FLAC2MP3_ARGS='-a "-vn -c:a libopus -b:a 192k" -e .opus -r "[.]mp3$"'
187201
```
188202

189-
Make sure to correctly use quotes and/or escape special characters when using this method. (See [regex notes](./README.md#technical-notes-on-regex) above.)
203+
Make sure to correctly use quotes and/or escape special characters when using this method. (See [regular expression notes](./README.md#technical-notes-on-regular-expressions) above.)
190204
In Docker Compose, the previous command would need an extra `$` to match the end-of-line:
205+
191206
```yaml
192207
environment:
193208
- FLAC2MP3_ARGS=-a "-vn -c:a libopus -b:a 192k" -e .opus -r '[.]mp3$$'
@@ -196,40 +211,31 @@ environment:
196211
*Example Synology Configuration*
197212
![flac2mp3](.assets/lidarr-synology-2.png "Synology container settings")
198213

199-
>**NOTE:** The environment variable settings are _only_ used when **no** command line arguments are present. **Any** command line argument will disable the use of the environment variable.
214+
>**NOTE:** The environment variable settings are *only* used when **no** command-line arguments are present. **Any** command-line argument will disable the use of the environment variable.
200215

201-
### Triggers
216+
## Triggers
202217
The only events/notification triggers that are supported are **On Release Import** and **On Upgrade**
203218

204-
### Batch Mode
205-
Batch mode allows the script to be executed independently of Lidarr. It converts the file specified on the command line and ignores any environment variables that are normally expected to be set by the music management program.
219+
## Batch Mode
220+
Batch mode allows the script to be executed independently of Lidarr. It converts the file specified on the command-line and ignores any environment variables that are normally expected to be set by the music management program.
206221

207222
Using this function, you can easily process all of your audio files in any subdirectory at once. See the [Batch Example](./README.md#batch-example) below.
208223

209-
#### Script Execution Differences in Batch Mode
224+
### Script Execution Differences in Batch Mode
210225
Because the script is not called from within Lidarr, expect the following behavior while in Batch Mode:
211-
* *The filename must be specified on the command line*<br/>(The `-f` option places the script in Batch Mode)
226+
* *The filename must be specified on the command-line*<br/>(The `-f` option places the script in Batch Mode)
212227
* *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.
213228
* *Original audio files are deleted.*<br/>The Recycle Bin function is not available. (Modifiable using the `-k` option.)
214229

215-
#### Batch Example
216-
To convert all .FLAC files in the `/music` directory to Apple Lossless Audio Codec (ALAC), enter the following at the Linux command line:
230+
### Batch Example
231+
To convert all .FLAC files in the `/music` directory to Apple Lossless Audio Codec (ALAC), enter the following at the Linux command-line:
232+
217233
```shell
218234
find /music/ -type f -name "*.flac" | while read file; do /usr/local/bin/flac2mp3.sh -f "$file" -a "-c:a alac" -e m4a; done
219235
```
220236

221-
### Logs
222-
By default, a log file is created for the script activity called:
223-
224-
`/config/logs/flac2mp3.txt`
225-
226-
This log can be downloaded from Lidarr under *System* > *Log Files*. The log filename can be modified with the `--log` command-line option.
227-
228-
Log rotation is performed, with 5 log files of 1MB each kept, matching Lidarr's log retention.
229-
>![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.*
230-
231-
#### Metadata Corrections
232-
This feature is not meant for general purpose use. It is only documented here for completeness.
237+
## Metadata Corrections
238+
**This feature is not meant for general purpose use.** It is only documented here for completeness.
233239

234240
List of supported tags and metadata corrections that are applied:
235241

@@ -244,6 +250,16 @@ List of supported tags and metadata corrections that are applied:
244250
| |/Punk\|Alternative/|"Alternative & Punk"
245251
| |/Rock/|"Rock"
246252

253+
## Logs
254+
By default, a log file is created for the script activity called:
255+
256+
`/config/logs/flac2mp3.txt`
257+
258+
This log can be downloaded from Lidarr under *System* > *Log Files*. The log filename can be modified with the `--log` command-line option.
259+
260+
Log rotation is performed, with 5 log files of 1MB each kept, matching Lidarr's log retention.
261+
>![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.*
262+
247263
# Uninstall
248264
To completely remove the mod:
249265
1. Delete the custom script from Lidarr's *Settings* > *Connect* screen that you created in the [Installation](./README.md#installation) section above.

0 commit comments

Comments
 (0)