Skip to content

Commit a570dfa

Browse files
authored
Merge pull request #1138 from TheCaptain989/lidarr-flac2mp3
lidarr: flac2mp3 release 3.0.2
2 parents b71793b + 64de822 commit a570dfa

6 files changed

Lines changed: 785 additions & 439 deletions

File tree

.assets/lidarr-import.png

177 KB
Loading

.github/workflows/BuildImage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
echo "BASEIMAGE=${{ env.BASEIMAGE }}" >> $GITHUB_OUTPUT
2121
echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT
2222
# **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. ****
23-
MOD_VERSION="2.6.0"
23+
MOD_VERSION="3.0.2"
2424
echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_OUTPUT
2525
outputs:
2626
GITHUB_REPO: ${{ steps.outputs.outputs.GITHUB_REPO }}

README.md

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,41 @@ Development Container info:
6464

6565
</details>
6666
<details>
67-
<summary>Synology Screenshot</summary>
67+
<summary>Synology DSM 6 Screenshot</summary>
6868

69-
*Example Synology Configuration*
69+
*Example Synology DSM 6 Configuration*
7070
![flac2mp3](.assets/lidarr-synology.png "Synology container settings")
7171

7272
</details>
7373

7474
2. Start the container.
7575

76-
2. Configure a custom script from Lidarr's *Settings* > *Connect* screen and type the following in the **Path** field:
77-
`/usr/local/bin/flac2mp3.sh`
76+
2. Either:
77+
1. Configure a custom script from Lidarr's *Settings* > *Connect* screen and type the following in the **Path** field:
78+
`/usr/local/bin/flac2mp3.sh`
7879

79-
<details>
80-
<summary>Screenshot</summary>
80+
<details>
81+
<summary>Screenshot</summary>
8182

82-
*Example Custom Script*
83-
![lidarr-flac2mp3](.assets/lidarr-custom-script.png "Lidarr Custom Script dialog")
83+
*Example Custom Script*
84+
![lidarr-flac2mp3](.assets/lidarr-custom-script.png "Lidarr Custom Script dialog")
8485

85-
</details>
86+
</details>
8687

87-
This will use the defaults to create a 320Kbps MP3 file.
88+
*or*
89+
90+
2. Configure an [import script](#import-mode "Import Mode") from Lidarr's *Settings* > *Media Management* > *Importing* > *Import Using Script* screen and type the following in the **Import Script Path** field:
91+
`/usr/local/bin/flac2mp3.sh`
92+
93+
<details>
94+
<summary>Screenshot</summary>
95+
96+
*Example Import Script*
97+
![flac2mp3 import script](.assets/lidarr-import.png "Lidarr Import Script dialog")
98+
99+
</details>
100+
101+
This will use the defaults to create a 320Kbps MP3 file.
88102

89103
> [!IMPORTANT]
90104
> For any other setting, you **must** use one of the supported methods to pass arguments to the script. See the [Command-Line Syntax](#command-line-syntax) section below.
@@ -93,10 +107,10 @@ Development Container info:
93107
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.
94108

95109
> [!TIP]
96-
> By default, if you've configured Lidarr's **Recycle Bin** path correctly, the original audio file will be moved there.
110+
> By default, if you've configured Lidarr's **Recycle Bin** path correctly, the original audio file will be moved there, unless you're in Import mode.
97111

98112
> [!CAUTION]
99-
> 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.
113+
> 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. When in Import mode, the source audio track is always deleted.
100114

101115
## Command-Line Syntax
102116
> [!NOTE]
@@ -105,8 +119,20 @@ New file(s) will be placed in the same directory as the original FLAC file(s) (u
105119
### Options and Arguments
106120
The script may be called with optional command-line arguments.
107121

108-
The syntax for the command-line is:
109-
`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>] [{-c|--config} <config_file>] [{-d|--debug} [<level>]]`
122+
The syntax for the command-line is:
123+
124+
```shell
125+
flac2mp3.sh [{-b|--bitrate} <bitrate> | {-v|--quality} <quality> | {-a|--advanced} "<options>" {-e|--extension} <extension>]
126+
[{-f|--file} <audio_file>]
127+
[{-k|--keep-file}]
128+
[{-o|--output} <directory>]
129+
[{-r|--regex} '<regex>']
130+
[{-t|--tags} <taglist>]
131+
[{-l|--log} <log_file>]
132+
[{-c|--config} <config_file>]
133+
[{-d|--debug} [<level>]]
134+
[--no-ansi]
135+
```
110136

111137
<details>
112138
<summary>Table of Command-Line Arguments</summary>
@@ -115,18 +141,19 @@ Option|Argument|Description
115141
---|---|---
116142
`-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`.
117143
`-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`.
118-
`-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!
144+
`-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!
119145
`-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`.
120146
`-f`, `--file`|`<audio_file>`|If included, the script enters **[Batch Mode](#batch-mode)** and converts the specified audio file.<br/>![note] **Do not** use this argument when called from Lidarr!
121147
`-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.
122-
`-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.
148+
`-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.
123149
`-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$`.
150+
`-t`, `--tags`|`<taglist>`|Comma separated list of metadata tags to apply automated corrections to.<br/>See [Metadata Corrections](#metadata-corrections) section.
124151
`-l`, `--log`|`<log_file>`|The log filename<br/>Default of /config/log/flac2mp3.txt
125152
`-c`, `--config`|`<config_file>`|Lidar XML configuration file<br/>Default is `/config/config.xml`
126-
`-t`, `--tags`|`<taglist>`|Comma separated list of metadata tags to apply automated corrections to.<br/>See [Metadata Corrections](#metadata-corrections) section.
127153
`-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.
128-
`--help`| |Display help and exit.
129-
`--version`| |Display version and exit.
154+
`--no-ansi`||Force disable ANSI color codes in terminal output
155+
`--help`||Display help and exit.
156+
`--version`||Display version and exit.
130157

131158
</details>
132159

@@ -273,15 +300,26 @@ In a `docker run` command, it would be:
273300

274301
</details>
275302
<details>
276-
<summary>Synology Screenshot</summary>
303+
<summary>Synology DSM 6 Screenshot</summary>
277304

278-
*Example Synology Configuration*
305+
*Example Synology DSM 6 Configuration*
279306
![flac2mp3](.assets/lidarr-synology-2.png "Synology container settings")
280307

281308
</details>
282309

283-
## Triggers
284-
The only events/notification triggers that are supported are **On Release Import** and **On Upgrade**. The script will log an error if executed by any other trigger.
310+
## Custom Script Triggers
311+
The only events/notification triggers that are supported in Custom Script mode are **On Release Import** and **On Upgrade**. The script will log an error if executed by any other trigger.
312+
313+
## Import Mode
314+
When entered in Lidarr's *Import Script Path* field, the script is placed in Import mode. In this mode, Lidarr will run the script to pickup the downloaded audio tracks from your download client instead of using the built-in functionality.
315+
This mode allows the script to process the audio tracks before the files are fully added to the library, gaining some efficiency by converting and moving the tracks at the same time.
316+
However, because the Lidarr database is not updated before the conversion step, this introduces some inherent limitations.
317+
318+
### Script Execution Differences in Import Mode
319+
In Import mode, the script behaves similarly to Custom Script mode but with the following differences:
320+
* *The script will execute once per imported track.*<br/>Lidarr calls the script for each track, so importing an album with 10 tracks will execute the script 10 times.
321+
* *Outdated Lidarr entries might exist.*<br/>A manual Refresh & Scan will replace any outdated entries with the correct filenames. The script cannot correct this due to the database update timing.
322+
* *Original audio files are deleted.*<br/>The Recycle Bin function is not available.
285323

286324
## Batch Mode
287325
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.

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Only the latest major and minor version are supported.
66

77
| Version | Supported |
88
| ------- | ------------------ |
9-
| 2.6.x | :heavy_check_mark: |
10-
| < 2.6 | :x: |
9+
| 3.0.x | :heavy_check_mark: |
10+
| < 3.0 | :x: |
1111

1212
## Reporting a Vulnerability
1313

root/etc/s6-overlay/s6-rc.d/init-mod-lidarr-flac2mp3-add-package/run

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/with-contenv bash
2+
# shellcheck shell=bash
23

34
cat <<EOF
45
----------------
@@ -13,7 +14,7 @@ EOF
1314

1415
# Determine if setup is needed
1516
if [ ! -f /usr/bin/ffmpeg ]; then
16-
echo "**** Adding ffmpeg to package install list ****"
17+
echo "**** Adding flac2mp3 deps to package install list ****"
1718
echo "ffmpeg" >> /mod-repo-packages-to-install.list
1819
else
1920
echo "**** flac2mp3 deps already installed, skipping ****"
@@ -23,14 +24,14 @@ fi
2324
for file in /usr/local/bin/flac2mp3*.sh
2425
do
2526
# Change ownership
26-
if [ $(stat -c '%G' $file) != "abc" ]; then
27+
if [ "$(stat -c '%G' "$file")" != "abc" ]; then
2728
echo "Changing ownership on $file script."
28-
lsiown abc:abc $file
29+
lsiown abc:abc "$file"
2930
fi
3031

3132
# Make executable
32-
if [ ! -x $file ]; then
33+
if [ ! -x "$file" ]; then
3334
echo "Making $file script executable."
34-
chmod +x $file
35+
chmod +x "$file"
3536
fi
3637
done

0 commit comments

Comments
 (0)