mirror of
https://github.com/rwinkhart/flac2pod.git
synced 2026-09-01 22:57:18 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7db318b561 | ||
|
|
dee1c3158f | ||
|
|
d973a3f659 | ||
|
|
d00e516e6c | ||
|
|
ea485480c4 | ||
|
|
b56dd7e5f5 | ||
|
|
c321e4d856 | ||
|
|
17df92256f | ||
|
|
76e7beb27d | ||
|
|
b41698ab65 | ||
|
|
94fa7570ec | ||
|
|
9f9d69b1a3 |
@@ -1,20 +1,20 @@
|
|||||||
# flac2pod
|
# flac2pod
|
||||||
Seamlessly converts your existing FLAC library to be played on an iPod Classic.
|
Seamlessly 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 either MP3-320 or ALAC for easy iPod Classic use. It also takes advantage of "rg2sc" (https://github.com/rwinkhart/rg2sc) to convert any existing ReplayGain tags to Apple Sound Check tags that are compatible with Apple products.
|
This script makes use of ffmpeg to convert your existing FLAC music library to MP3-320 for easy iPod Classic use. It also takes advantage of "rg2sc" (https://github.com/rwinkhart/rg2sc) to convert any existing ReplayGain tags to Apple Sound Check tags that are compatible with Apple products.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
Simply run:
|
||||||
```
|
```
|
||||||
flac2pod -f --mp3 # will convert library to MP3-320 and forcefully update Sound Check tags (even if they already exist)
|
flac2pod
|
||||||
|
|
||||||
flac2pod --alac # will convert library to ALAC in a .m4a container - only updates missing Sound Check tags
|
|
||||||
|
|
||||||
flac2pod # will convert library to MP3-320 - only updates missing Sound Check tags
|
|
||||||
```
|
```
|
||||||
|
...and you will be prompted for your source and destination directories.
|
||||||
|
|
||||||
|
|
||||||
In order for flac2pod to function, your library must be structured as follows:
|
In order for flac2pod to function, your library must be structured as follows:
|
||||||
Library dir -> Artist dir -> Album dir -> FLAC files
|
|
||||||
|
library parent dir -> artist dir -> album dir -> FLAC files
|
||||||
|
|
||||||
|
|
||||||
When prompted for the source directory, you want to input your library parent directory.
|
When prompted for the source directory, you want to input your library parent directory.
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
+35
-32
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
# external modules
|
# external modules
|
||||||
|
|
||||||
from os import path, system, walk
|
from os import cpu_count, path, walk
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from sys import argv
|
from sys import argv, exit as s_exit
|
||||||
|
from time import sleep
|
||||||
|
from subprocess import check_output, Popen
|
||||||
|
|
||||||
|
|
||||||
# utility functions
|
# utility functions
|
||||||
@@ -35,38 +37,43 @@ def create_destination():
|
|||||||
.mkdir(0o700, parents=True, exist_ok=True)
|
.mkdir(0o700, parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
def scan_destination_convert_alac():
|
|
||||||
for _file in source_directories[1]:
|
|
||||||
if not Path(f"{_file.replace(path.expanduser(source), path.expanduser(destination))}.m4a").is_file():
|
|
||||||
system(f"ffmpeg -i '{_file}.flac' -c:v copy -c:a alac -map_metadata 0 -id3v2_version 3 "
|
|
||||||
f"'{_file.replace(path.expanduser(source), path.expanduser(destination))}.m4a'")
|
|
||||||
|
|
||||||
|
|
||||||
def scan_destination_convert_mp3():
|
def scan_destination_convert_mp3():
|
||||||
|
_i, _total_files = 0, len(source_directories)
|
||||||
for _file in source_directories[1]:
|
for _file in source_directories[1]:
|
||||||
print(_file)
|
|
||||||
if not Path(f"{_file.replace(path.expanduser(source), path.expanduser(destination))}.mp3").is_file():
|
if not Path(f"{_file.replace(path.expanduser(source), path.expanduser(destination))}.mp3").is_file():
|
||||||
system(f"ffmpeg -i '{_file}.flac' -c:v copy -ab 320k -map_metadata 0 -id3v2_version 3 "
|
_file_s = _file.replace(' ', '\\ ').replace("'", "\\'").replace(')', '\\)').replace('(', '\\(').replace\
|
||||||
f"'{_file.replace(path.expanduser(source), path.expanduser(destination))}.mp3'")
|
('&', '\\&').replace('`', '\\`').replace('$', '\\$') + '.flac'
|
||||||
|
_file_d = _file.replace(path.expanduser(source), path.expanduser(destination)).replace(' ', '\\ ')\
|
||||||
|
.replace("'", "\\'").replace(')', '\\)').replace('(', '\\(').replace('&', '\\&')\
|
||||||
def rg2sc():
|
.replace('`', '\\`').replace('$', '\\$') + '.mp3'
|
||||||
if argument.__contains__('-f'):
|
_active_processes = int(check_output('ps -C ffmpeg | wc -l', shell=True)) - 1
|
||||||
system(f"{rg2sc} -f {destination}")
|
if _active_processes >= cpu_count():
|
||||||
|
while _active_processes >= cpu_count():
|
||||||
|
print(f"\nThere are already {cpu_count()} processes running...\n")
|
||||||
|
sleep(1)
|
||||||
|
_active_processes = int(check_output('ps -C ffmpeg | wc -l', shell=True)) - 1
|
||||||
|
_i += 1
|
||||||
|
_progress = _i / _total_files
|
||||||
|
print(f"\n{_progress}% | \u001b[38;5;0;48;5;15mConverting {_file_s} to {_file_d}...\u001b[0m\n")
|
||||||
|
if '-s' in arguments:
|
||||||
|
_cmd = f"screen -DmS flac2pod{_i} ffmpeg -i {_file_s} -map 0:a -ab 320k -map_metadata 0" \
|
||||||
|
f" -id3v2_version 3 {_file_d} </dev/null; rg2sc -f -s {_file_d}"
|
||||||
else:
|
else:
|
||||||
system(f"{rg2sc} {destination}")
|
_cmd = f"screen -DmS flac2pod{_i} ffmpeg -i {_file_s} -c:v copy -ab 320k -map_metadata 0" \
|
||||||
|
f" -id3v2_version 3 {_file_d} </dev/null; rg2sc -f {_file_d}"
|
||||||
|
Popen(_cmd, shell=True)
|
||||||
|
_active_processes = int(check_output('ps -C ffmpeg | wc -l', shell=True)) - 1
|
||||||
|
while _active_processes != 0:
|
||||||
|
print('\nPlease wait for the remaining conversions to complete...\n')
|
||||||
|
sleep(1)
|
||||||
|
_active_processes = int(check_output('ps -C ffmpeg | wc -l', shell=True)) - 1
|
||||||
|
sleep(1)
|
||||||
|
print('\niPod conversion complete!\n')
|
||||||
|
s_exit()
|
||||||
|
|
||||||
|
|
||||||
# program start sequence
|
|
||||||
|
|
||||||
# retrieve typed argument
|
# retrieve typed argument
|
||||||
argument_list = argv
|
arguments = argv
|
||||||
i, argument = 0, ''
|
|
||||||
for _ in argument_list:
|
|
||||||
while i < len(argument_list) - 1:
|
|
||||||
i += 1
|
|
||||||
argument += argument_list[i] + ' '
|
|
||||||
argument = argument[:-1]
|
|
||||||
|
|
||||||
source = input('Source parent directory: ')
|
source = input('Source parent directory: ')
|
||||||
if source.endswith('/'):
|
if source.endswith('/'):
|
||||||
@@ -77,8 +84,4 @@ if destination.endswith('/'):
|
|||||||
|
|
||||||
source_directories = scan_source()
|
source_directories = scan_source()
|
||||||
create_destination()
|
create_destination()
|
||||||
if argument.__contains__('--alac'):
|
scan_destination_convert_mp3()
|
||||||
scan_destination_convert_alac()
|
|
||||||
else:
|
|
||||||
scan_destination_convert_mp3()
|
|
||||||
rg2sc()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user