mirror of
https://github.com/rwinkhart/flac2pod.git
synced 2026-09-01 22:57:18 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d8d6f876a | ||
|
|
65dc1157e1 | ||
|
|
771f540af2 | ||
|
|
4055963026 | ||
|
|
af8c030201 | ||
|
|
c7133060a0 |
@@ -18,7 +18,11 @@ flac2pod --help
|
|||||||
```
|
```
|
||||||
flac2pod-flacgain <source_dir>
|
flac2pod-flacgain <source_dir>
|
||||||
```
|
```
|
||||||
...to tag your FLAC library with ReplayGain data.
|
...to tag your FLAC library with ReplayGain data, or run...
|
||||||
|
```
|
||||||
|
flac2pod-artconvert <source_dir>
|
||||||
|
```
|
||||||
|
...to convert embedded PNGs (in MP4/M4A files) to iPod-ready JPEGs.
|
||||||
|
|
||||||
In order for flac2pod to function, your source_dir must be structured as follows:
|
In order for flac2pod to function, your source_dir must be structured as follows:
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
from flac2pod import scan_source
|
||||||
|
from mutagen import mp4
|
||||||
|
from mutagen.mp4 import MP4Cover
|
||||||
|
from os import listdir
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = ArgumentParser(description='Convert embedded album art in MP4/M4A files from PNGs to iPod-compatible '
|
||||||
|
'JPEGs.')
|
||||||
|
parser.add_argument('source_dir', nargs='+',
|
||||||
|
help='directory tree containing music files - folder must contain library sorted into artists '
|
||||||
|
'and albums')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.source_dir[0].endswith('/'):
|
||||||
|
source = args.source_dir[0][:-1]
|
||||||
|
else:
|
||||||
|
source = args.source_dir[0]
|
||||||
|
|
||||||
|
source_directories = scan_source(source)
|
||||||
|
|
||||||
|
for album in sorted(source_directories[0]):
|
||||||
|
for song in listdir(album):
|
||||||
|
audio = mp4.MP4(f"{album}/{song}")
|
||||||
|
if audio.tags is None:
|
||||||
|
continue
|
||||||
|
if "covr" not in audio.tags:
|
||||||
|
continue
|
||||||
|
cover = audio.tags["covr"][0]
|
||||||
|
print(f"[{album}/{song}] Converting...")
|
||||||
|
open("/tmp/cover.png", "wb").write(cover)
|
||||||
|
image = Image.open("/tmp/cover.png")
|
||||||
|
image.thumbnail((300, 300))
|
||||||
|
image.save("/tmp/cover.jpeg", "JPEG", quality=50)
|
||||||
|
with open("/tmp/cover.jpeg", "rb") as f:
|
||||||
|
audio["covr"] = [
|
||||||
|
MP4Cover(f.read(), imageformat=MP4Cover.FORMAT_JPEG)
|
||||||
|
]
|
||||||
|
audio.save()
|
||||||
@@ -7,7 +7,6 @@ from os import listdir, system
|
|||||||
from subprocess import PIPE, run
|
from subprocess import PIPE, run
|
||||||
from sys import exit as s_exit
|
from sys import exit as s_exit
|
||||||
|
|
||||||
# argument parsing
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = ArgumentParser(description='Quickly tag your FLAC library with ReplayGain data using metaflac.')
|
parser = ArgumentParser(description='Quickly tag your FLAC library with ReplayGain data using metaflac.')
|
||||||
parser.add_argument('source_dir', nargs='+',
|
parser.add_argument('source_dir', nargs='+',
|
||||||
@@ -64,5 +63,3 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
print(f"[{album}/*] ReplayGain data is already present.")
|
print(f"[{album}/*] ReplayGain data is already present.")
|
||||||
|
|
||||||
s_exit(0)
|
|
||||||
|
|||||||
+9
-5
@@ -102,9 +102,13 @@ def scan_destination_convert():
|
|||||||
_bake_args, _flac2pod_rg_tags = '', f"-metadata comment='FLAC2PODRG#{_rggain}#{_rgpeak}#'"
|
_bake_args, _flac2pod_rg_tags = '', f"-metadata comment='FLAC2PODRG#{_rggain}#{_rgpeak}#'"
|
||||||
else:
|
else:
|
||||||
_bake_args, _flac2pod_rg_tags = '', ''
|
_bake_args, _flac2pod_rg_tags = '', ''
|
||||||
|
if args.preserve:
|
||||||
|
_art_args = '-c:v copy -map_metadata 0:g'
|
||||||
|
else:
|
||||||
|
_art_args = '-vn'
|
||||||
# generate the appropriate ffmpeg command
|
# generate the appropriate ffmpeg command
|
||||||
_cmd = f"screen -DmS flac2pod{_i} ffmpeg -i {_file_s} -c:a aac -ab 256k {_bake_args} -map_metadata 0 " \
|
_cmd = f"screen -DmS flac2pod{_i} ffmpeg -i {_file_s} {_art_args} -c:a aac -b:a 256k {_bake_args} " \
|
||||||
f"{_flac2pod_rg_tags} -aac_pns 0 -movflags +faststart -vn {_file_d} </dev/null"
|
f"{_flac2pod_rg_tags} -aac_pns 0 -movflags +faststart {_file_d} </dev/null"
|
||||||
if _rggain is not None:
|
if _rggain is not None:
|
||||||
print(f"\u001b[38;5;0;48;5;15mGain adjustment: {_rggain}dB\u001b[0m")
|
print(f"\u001b[38;5;0;48;5;15mGain adjustment: {_rggain}dB\u001b[0m")
|
||||||
else:
|
else:
|
||||||
@@ -131,11 +135,13 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('destination_dir', nargs='+',
|
parser.add_argument('destination_dir', nargs='+',
|
||||||
help='destination parent directory for output - will be created if it does not already exist')
|
help='destination parent directory for output - will be created if it does not already exist')
|
||||||
parser.add_argument('-b', '--bake', action='store_true',
|
parser.add_argument('-b', '--bake', action='store_true',
|
||||||
help='bake (encode) ReplayGain values into the file')
|
help='bake (encode) ReplayGain values into output files')
|
||||||
parser.add_argument('-a', '--albumgain', action='store_true',
|
parser.add_argument('-a', '--albumgain', action='store_true',
|
||||||
help='read ReplayGain album gain instead of ReplayGain track gain')
|
help='read ReplayGain album gain instead of ReplayGain track gain')
|
||||||
parser.add_argument('-x', '--stopifnogain', action='store_true',
|
parser.add_argument('-x', '--stopifnogain', action='store_true',
|
||||||
help='stop flac2pod if ReplayGain data cannot be found in a file')
|
help='stop flac2pod if ReplayGain data cannot be found in a file')
|
||||||
|
parser.add_argument('-p', '--preserve', action='store_true',
|
||||||
|
help='copy album art from input files')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.source_dir[0].endswith('/'):
|
if args.source_dir[0].endswith('/'):
|
||||||
@@ -150,5 +156,3 @@ if __name__ == "__main__":
|
|||||||
source_directories = scan_source(source)
|
source_directories = scan_source(source)
|
||||||
create_destination()
|
create_destination()
|
||||||
scan_destination_convert()
|
scan_destination_convert()
|
||||||
|
|
||||||
s_exit(0)
|
|
||||||
|
|||||||
+2
-1
@@ -19,6 +19,7 @@ echo -e '\npackaging as generic...\n'
|
|||||||
mkdir -p output/generictemp/usr/{bin,lib/flac2pod}
|
mkdir -p output/generictemp/usr/{bin,lib/flac2pod}
|
||||||
cp -r lib/. output/generictemp/usr/lib/flac2pod/
|
cp -r lib/. output/generictemp/usr/lib/flac2pod/
|
||||||
ln -s /usr/lib/flac2pod/flac2pod.py output/generictemp/usr/bin/flac2pod
|
ln -s /usr/lib/flac2pod/flac2pod.py output/generictemp/usr/bin/flac2pod
|
||||||
|
ln -s /usr/lib/flac2pod/flac2pod-artconvert.py output/generictemp/usr/bin/flac2pod-artconvert
|
||||||
ln -s /usr/lib/flac2pod/flac2pod-flacgain.py output/generictemp/usr/bin/flac2pod-flacgain
|
ln -s /usr/lib/flac2pod/flac2pod-flacgain.py output/generictemp/usr/bin/flac2pod-flacgain
|
||||||
cp -r share output/generictemp/usr/
|
cp -r share output/generictemp/usr/
|
||||||
tar -C output/generictemp -cvJf output/flac2pod-"$version".tar.xz usr/
|
tar -C output/generictemp -cvJf output/flac2pod-"$version".tar.xz usr/
|
||||||
@@ -37,7 +38,7 @@ pkgdesc='Converts your FLAC library to be iPod-ready'
|
|||||||
url='https://github.com/rwinkhart/flac2pod'
|
url='https://github.com/rwinkhart/flac2pod'
|
||||||
arch=('any')
|
arch=('any')
|
||||||
license=('GPL2')
|
license=('GPL2')
|
||||||
depends=(ffmpeg flac python python-mutagen screen)
|
depends=(ffmpeg flac python python-mutagen python-pillow screen)
|
||||||
source=(\""$source"\")
|
source=(\""$source"\")
|
||||||
sha512sums=('"$sha512"')
|
sha512sums=('"$sha512"')
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
flac2pod is a FOSS audio transcoding script for preparing music for an Apple iPod.
|
flac2pod is a FOSS audio transcoding script for preparing music for an Apple iPod.
|
||||||
Copyright (C) 2022 Randall Winkhart idgr@tutanota.com
|
Copyright (C) 2022-2023 Randall Winkhart idgr@tutanota.com
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
Reference in New Issue
Block a user