Support files with capitalized extensions

This commit is contained in:
2024-03-23 12:35:36 -04:00
parent 91cea901be
commit ee3e1f9fa1
2 changed files with 17 additions and 6 deletions
+14
View File
@@ -1,27 +1,41 @@
# flac2pod # flac2pod
Converts your existing FLAC library to be played on an iPod Classic. Converts your existing FLAC library to be played on an iPod Classic.
This script makes use of ffmpeg to convert your existing FLAC music library to AAC-256 for easy iPod Classic use. It can also bake your existing ReplayGain data into the output files. SoundCheck support was removed due to this feature being very finicky on iPods. If you would like to add SoundCheck data to your output files, omit the --bake option and then use https://github.com/rwinkhart/rg2sc on your output files. This script makes use of ffmpeg to convert your existing FLAC music library to AAC-256 for easy iPod Classic use. It can also bake your existing ReplayGain data into the output files. SoundCheck support was removed due to this feature being very finicky on iPods. If you would like to add SoundCheck data to your output files, omit the --bake option and then use https://github.com/rwinkhart/rg2sc on your output files.
In order for ReplayGain baking to work, your FLAC library must already be tagged with ReplayGain data. If you haven't already done this, flac2pod comes with a script (flac2pod-flacgain) for quickly applying these ReplayGain tags. In order for ReplayGain baking to work, your FLAC library must already be tagged with ReplayGain data. If you haven't already done this, flac2pod comes with a script (flac2pod-flacgain) for quickly applying these ReplayGain tags.
# WARNING
This is an older project of mine that is only updated to fix bugs and maintain compatibility. It is written rather poorly, but it does what it says on the tin, so I will not be investing time into rewriting it.
# Usage # Usage
Simply run... Simply run...
``` ```
flac2pod <source_dir> <destination_dir> flac2pod <source_dir> <destination_dir>
``` ```
...to convert your library, or run... ...to convert your library, or run...
``` ```
flac2pod --help flac2pod --help
``` ```
...to see additional options, or run... ...to see additional options, or run...
``` ```
flac2pod-flacgain <source_dir> flac2pod-flacgain <source_dir>
``` ```
...to tag your FLAC library with ReplayGain data, or run... ...to tag your FLAC library with ReplayGain data, or run...
``` ```
flac2pod-artconvert <source_dir> flac2pod-artconvert <source_dir>
``` ```
...to convert embedded PNGs (in MP4/M4A files) to iPod-ready JPEGs. ...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:
+3 -6
View File
@@ -1,7 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# external modules
from argparse import ArgumentParser from argparse import ArgumentParser
from mutagen.flac import FLAC from mutagen.flac import FLAC
from os import cpu_count, path, walk from os import cpu_count, path, walk
@@ -29,12 +27,11 @@ def scan_source(_source):
for _album in sorted(_album_dirs): for _album in sorted(_album_dirs):
for _root, _directories, _files in walk(path.expanduser(_album)): for _root, _directories, _files in walk(path.expanduser(_album)):
for _filename in _files: for _filename in _files:
if _filename.endswith('.flac') or _filename.endswith('.mp3') or _filename.endswith('.mp4') \ if _filename.lower().endswith('.flac') or _filename.lower().endswith('.mp3') or \
or _filename.endswith('.m4a'): _filename.lower().endswith('.mp4') or _filename.lower().endswith('.m4a'):
_full_paths.append(f"{_album}/{_filename}") _full_paths.append(f"{_album}/{_filename}")
return _album_dirs, _full_paths return _album_dirs, _full_paths
def create_destination(): def create_destination():
for _dir in source_directories[0]: for _dir in source_directories[0]:
Path(path.expanduser(_dir.replace(path.expanduser(source), path.expanduser(destination))))\ Path(path.expanduser(_dir.replace(path.expanduser(source), path.expanduser(destination))))\
@@ -48,7 +45,7 @@ def scan_destination_convert():
_progress = round((_i_total / _total_files) * 100, 2) _progress = round((_i_total / _total_files) * 100, 2)
if not Path(f"{(_file.replace(path.expanduser(source), path.expanduser(destination)))[:-5]}.m4a").is_file()\ if not Path(f"{(_file.replace(path.expanduser(source), path.expanduser(destination)))[:-5]}.m4a").is_file()\
and not Path(f"{(_file.replace(path.expanduser(source), path.expanduser(destination)))}").is_file(): and not Path(f"{(_file.replace(path.expanduser(source), path.expanduser(destination)))}").is_file():
if not _file.endswith('.flac'): if not _file.lower().endswith('.flac'):
print(f"[{_file}] Not a FLAC file, copying...") print(f"[{_file}] Not a FLAC file, copying...")
copy(f"{_file}", f"{_file.replace(path.expanduser(source), path.expanduser(destination))}") copy(f"{_file}", f"{_file.replace(path.expanduser(source), path.expanduser(destination))}")
else: else: