mirror of
https://github.com/rwinkhart/flac2pod.git
synced 2026-09-01 14:47:18 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c32b16598a | ||
|
|
3865e91517 | ||
|
|
7411af721d | ||
|
|
ee3e1f9fa1 | ||
|
|
91cea901be | ||
|
|
1d59ed62ac | ||
|
|
572b997286 | ||
|
|
6d8d6f876a | ||
|
|
65dc1157e1 | ||
|
|
771f540af2 | ||
|
|
4055963026 | ||
|
|
af8c030201 | ||
|
|
c7133060a0 | ||
|
|
a2e0e3fe74 | ||
|
|
d0d34a04ee | ||
|
|
e78a0bc2c2 | ||
|
|
2fd4d685e0 | ||
|
|
6732731c11 | ||
|
|
5c83969ce2 | ||
|
|
19a7f3b7b2 | ||
|
|
be7166e2dd | ||
|
|
8ba7815241 | ||
|
|
d03d73a2f8 | ||
|
|
aa9ec97695 | ||
|
|
fcee6ba3f4 | ||
|
|
1daa02f7ac | ||
|
|
6b8553cbee | ||
|
|
88e3994f4f | ||
|
|
f45dab8cfb | ||
|
|
6d8deda002 | ||
|
|
d2598c561a | ||
|
|
35bc1d9212 | ||
|
|
5550bc5b76 | ||
|
|
b91511286c | ||
|
|
8704749e7b | ||
|
|
094725cad0 | ||
|
|
f79d6ce025 | ||
|
|
c9a31dcbce | ||
|
|
1be96f0b20 | ||
|
|
282c193804 | ||
|
|
e833e4ce60 | ||
|
|
b5a2b9adb3 | ||
|
|
3c7ec3e921 | ||
|
|
10973e3ac8 | ||
|
|
c8ef53bc17 | ||
|
|
144c3f53e0 | ||
|
|
998c73c20f | ||
|
|
df1dce38eb | ||
|
|
ed12cc5d23 | ||
|
|
f72d3ac9b7 | ||
|
|
95a8dacd29 | ||
|
|
d64f4c56fa | ||
|
|
137e30c80b | ||
|
|
be5c96e182 | ||
|
|
7db318b561 | ||
|
|
dee1c3158f | ||
|
|
d973a3f659 | ||
|
|
d00e516e6c | ||
|
|
ea485480c4 | ||
|
|
b56dd7e5f5 | ||
|
|
c321e4d856 | ||
|
|
17df92256f | ||
|
|
76e7beb27d | ||
|
|
b41698ab65 | ||
|
|
94fa7570ec | ||
|
|
9f9d69b1a3 |
@@ -1,27 +1,49 @@
|
||||
# flac2pod
|
||||
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.
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
Simply run...
|
||||
|
||||
```
|
||||
flac2pod -f --mp3 # will convert library to MP3-320 and forcefully update Sound Check tags (even if they already exist)
|
||||
|
||||
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
|
||||
flac2pod <source_dir> <destination_dir>
|
||||
```
|
||||
|
||||
In order for flac2pod to function, your library must be structured as follows:
|
||||
Library dir -> Artist dir -> Album dir -> FLAC files
|
||||
...to convert your library, or run...
|
||||
|
||||
When prompted for the source directory, you want to input your library parent directory.
|
||||
```
|
||||
flac2pod --help
|
||||
```
|
||||
|
||||
...to see additional options, or run...
|
||||
|
||||
```
|
||||
flac2pod-flacgain <source_dir>
|
||||
```
|
||||
|
||||
...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:
|
||||
|
||||
source_dir -> artist dir -> album dir -> FLAC files
|
||||
|
||||
# Installation
|
||||
|
||||
flac2pod is available in the AUR as "flac2pod". If installing on a non-Arch-based distribution, follow the manual installation instructions:
|
||||
flac2pod is available in the AUR as "flac2pod".
|
||||
|
||||
- copy the flac2pod executable from https://github.com/rwinkhart/flac2pod/blob/master/bin/flac2pod to your /usr/bin/
|
||||
- copy the rg2sc executable from https://github.com/rwinkhart/rg2sc/blob/master/bin/rg2sc to your /usr/bin
|
||||
- install python-mutagen, ffmpeg, and lame
|
||||
If installing on a non-Arch-based distribution, a generic package is available on the releases page.
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
#!/bin/python3
|
||||
|
||||
# external modules
|
||||
|
||||
from os import path, system, walk
|
||||
from pathlib import Path
|
||||
from sys import argv
|
||||
|
||||
|
||||
# utility functions
|
||||
|
||||
def scan_source():
|
||||
_artist_dirs, _album_dirs, _full_paths = [], [], []
|
||||
for _root, _directories, _files in walk(path.expanduser(source)):
|
||||
for _dir in sorted(_directories):
|
||||
if not _root.endswith(path.expanduser(source)):
|
||||
_artist_dirs.append(_root)
|
||||
_artist_dirs = list(set(_artist_dirs))
|
||||
for _artist in sorted(_artist_dirs):
|
||||
for _root, _directories, _files in walk(path.expanduser(_artist)):
|
||||
if not _root.endswith(path.expanduser(_artist)):
|
||||
_album_dirs.append(_root)
|
||||
_album_dirs = list(set(_album_dirs))
|
||||
for _album in sorted(_album_dirs):
|
||||
for _root, _directories, _files in walk(path.expanduser(_album)):
|
||||
for _filename in _files:
|
||||
if _filename.endswith('.flac'):
|
||||
_full_paths.append(f"{_album}/{_filename[:-5]}")
|
||||
return _album_dirs, _full_paths
|
||||
|
||||
|
||||
def create_destination():
|
||||
for _dir in source_directories[0]:
|
||||
Path(path.expanduser(_dir.replace(path.expanduser(source), path.expanduser(destination))))\
|
||||
.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():
|
||||
for _file in source_directories[1]:
|
||||
print(_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 "
|
||||
f"'{_file.replace(path.expanduser(source), path.expanduser(destination))}.mp3'")
|
||||
|
||||
|
||||
def rg2sc():
|
||||
if argument.__contains__('-f'):
|
||||
system(f"{rg2sc} -f {destination}")
|
||||
else:
|
||||
system(f"{rg2sc} {destination}")
|
||||
|
||||
|
||||
# program start sequence
|
||||
|
||||
# retrieve typed argument
|
||||
argument_list = 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: ')
|
||||
if source.endswith('/'):
|
||||
source = source[:-1]
|
||||
destination = input('Destination parent directory: ')
|
||||
if destination.endswith('/'):
|
||||
destination = destination[:-1]
|
||||
|
||||
source_directories = scan_source()
|
||||
create_destination()
|
||||
if argument.__contains__('--alac'):
|
||||
scan_destination_convert_alac()
|
||||
else:
|
||||
scan_destination_convert_mp3()
|
||||
rg2sc()
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
git add -f LICENSE README.md commit.sh package.sh share lib/flac2pod-artconvert.py lib/flac2pod-flacgain.py lib/flac2pod.py
|
||||
git commit -m "$1"
|
||||
git push
|
||||
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()
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from flac2pod import scan_source
|
||||
from glob import glob
|
||||
from mutagen.flac import FLAC, FLACNoHeaderError
|
||||
from os import listdir
|
||||
from subprocess import PIPE, run
|
||||
from sys import exit as s_exit
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser(description='Quickly tag your FLAC library with ReplayGain data using metaflac.')
|
||||
parser.add_argument('source_dir', nargs='+',
|
||||
help='directory tree containing music files - folder must contain library sorted into artists '
|
||||
'and albums')
|
||||
parser.add_argument('-f', '--force', action='store_true',
|
||||
help='overwrite existing ReplayGain data')
|
||||
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)
|
||||
|
||||
gain = 1
|
||||
for album in sorted(source_directories[0]):
|
||||
for song in listdir(album):
|
||||
gain = 1 # reset for each song
|
||||
if not song.lower().endswith('.flac'):
|
||||
gain = 2 # set non-flac signal
|
||||
else:
|
||||
try:
|
||||
audio = FLAC(f"{album}/{song}")
|
||||
if audio.get('replaygain_track_gain') or audio.get('REPLAYGAIN_TRACK_GAIN'):
|
||||
print(f"[{album}/*] ReplayGain data is already present.")
|
||||
break
|
||||
else:
|
||||
gain = 0
|
||||
except FLACNoHeaderError:
|
||||
gain = 2 # set non-flac signal
|
||||
if gain == 2:
|
||||
print(f"[{album}/*] Contains non-FLAC files, skipping album...")
|
||||
break
|
||||
if gain != 2 and (args.force or gain == 0):
|
||||
print(f"[{album}/*] Adding ReplayGain data...")
|
||||
album_files = glob(album + '/*')
|
||||
run(['metaflac', '--remove-replay-gain'] + album_files)
|
||||
output = run(['metaflac', '--add-replay-gain'] + album_files, stderr=PIPE, text=True)
|
||||
if output.returncode == 1:
|
||||
if output.stderr.__contains__('sample') or output.stderr.__contains__('resolution of') or output.\
|
||||
stderr.__contains__('does not match'):
|
||||
print('Resolution/Sample Rate/Channel mismatch, scanning tracks as individuals...')
|
||||
for song in listdir(album):
|
||||
print(f"[{album}/{song}] Adding ReplayGain data...")
|
||||
output = run(('metaflac', '--add-replay-gain', f"{album}/{song}"), stderr=PIPE, text=True)
|
||||
if output.returncode == 1:
|
||||
print('There was an error processing your files.')
|
||||
print(f"Return Code: [{str(output.returncode)}] {output.stderr}")
|
||||
s_exit(1)
|
||||
else:
|
||||
print('There was an error processing your files.')
|
||||
print(f"Return Code: [{str(output.returncode)}] {output.stderr}")
|
||||
s_exit(1)
|
||||
Executable
+164
@@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from mutagen.flac import FLAC
|
||||
from os import cpu_count, getuid, listdir, path, stat, walk
|
||||
from pathlib import Path
|
||||
from shutil import copy
|
||||
from subprocess import DEVNULL, Popen
|
||||
from sys import exit as s_exit
|
||||
from time import sleep
|
||||
|
||||
|
||||
# scans source directory for music files, returns lists of album directories and their full paths
|
||||
def scan_source(_source):
|
||||
_artist_dirs, _album_dirs, _full_paths = [], [], []
|
||||
for _root, _directories, _files in walk(path.expanduser(_source)):
|
||||
for _dir in sorted(_directories):
|
||||
if not _root.endswith(path.expanduser(_source)):
|
||||
_artist_dirs.append(_root)
|
||||
_artist_dirs = list(set(_artist_dirs))
|
||||
for _artist in sorted(_artist_dirs):
|
||||
for _root, _directories, _files in walk(path.expanduser(_artist)):
|
||||
if not _root.endswith(path.expanduser(_artist)):
|
||||
_album_dirs.append(_root)
|
||||
_album_dirs = list(set(_album_dirs))
|
||||
for _album in sorted(_album_dirs):
|
||||
for _root, _directories, _files in walk(path.expanduser(_album)):
|
||||
for _filename in _files:
|
||||
if _filename.lower().endswith('.flac') or _filename.lower().endswith('.mp3') or \
|
||||
_filename.lower().endswith('.mp4') or _filename.lower().endswith('.m4a'):
|
||||
_full_paths.append(f"{_album}/{_filename}")
|
||||
return _album_dirs, _full_paths
|
||||
|
||||
|
||||
# creates destination directory structure
|
||||
def create_destination():
|
||||
for _dir in source_directories[0]:
|
||||
Path(path.expanduser(_dir.replace(path.expanduser(source), path.expanduser(destination))))\
|
||||
.mkdir(0o700, parents=True, exist_ok=True)
|
||||
|
||||
|
||||
# counts how many ffmpeg processes are running under the current user
|
||||
def count_user_ffmpeg_processes():
|
||||
_user = getuid()
|
||||
_proc_directory = '/proc'
|
||||
_running_processes = 0
|
||||
_subdirectories = [_d for _d in listdir(_proc_directory) if path.isdir(path.join(_proc_directory, _d))]
|
||||
for _subdirectory in _subdirectories:
|
||||
if _subdirectory.isnumeric():
|
||||
if stat(_proc_directory + '/' + _subdirectory).st_uid == _user:
|
||||
with open(_proc_directory + '/' + _subdirectory + '/cmdline', 'r') as _f:
|
||||
if _f.read().startswith('ffmpeg'):
|
||||
_running_processes += 1
|
||||
return _running_processes
|
||||
|
||||
|
||||
def scan_destination_convert():
|
||||
_i, _i_total, _total_files = 0, 0, len(source_directories[1])
|
||||
for _file in source_directories[1]:
|
||||
_i_total += 1
|
||||
_progress = round((_i_total / _total_files) * 100, 2)
|
||||
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():
|
||||
if not _file.lower().endswith('.flac'):
|
||||
print(f"[{_file}] Not a FLAC file, copying...")
|
||||
copy(f"{_file}", f"{_file.replace(path.expanduser(source), path.expanduser(destination))}")
|
||||
else:
|
||||
_file_d = _file.replace(path.expanduser(source), path.expanduser(destination))[:-5] + '.m4a'
|
||||
_active_processes = count_user_ffmpeg_processes()
|
||||
while _active_processes >= cpu_count():
|
||||
print(f"\nThere are already {_active_processes} processes running on your {cpu_count()} "
|
||||
f"threads...\n")
|
||||
sleep(1)
|
||||
_active_processes = count_user_ffmpeg_processes()
|
||||
_i += 1
|
||||
print(f"\n{_progress}% | \u001b[38;5;0;48;5;15mConverting {_file} to {_file_d}...\u001b[0m\n")
|
||||
# get relevant ReplayGain info
|
||||
_audio = FLAC(f"{_file}")
|
||||
if args.albumgain:
|
||||
if _audio.get('REPLAYGAIN_ALBUM_GAIN'):
|
||||
_rggain = float(_audio.get('REPLAYGAIN_ALBUM_GAIN')[0][:-3])
|
||||
elif _audio.get('replaygain_album_gain'):
|
||||
_rggain = float(_audio.get('replaygain_album_gain')[0][:-3])
|
||||
else:
|
||||
_rggain = None
|
||||
if _audio.get('REPLAYGAIN_ALBUM_PEAK'):
|
||||
_rgpeak = float(_audio.get('REPLAYGAIN_ALBUM_PEAK')[0])
|
||||
elif _audio.get('replaygain_album_peak'):
|
||||
_rgpeak = float(_audio.get('replaygain_album_peak')[0])
|
||||
else:
|
||||
_rgpeak = None
|
||||
else:
|
||||
if _audio.get('REPLAYGAIN_TRACK_GAIN'):
|
||||
_rggain = float(_audio.get('REPLAYGAIN_TRACK_GAIN')[0][:-3])
|
||||
elif _audio.get('replaygain_track_gain'):
|
||||
_rggain = float(_audio.get('replaygain_track_gain')[0][:-3])
|
||||
else:
|
||||
_rggain = None
|
||||
if _audio.get('REPLAYGAIN_TRACK_PEAK'):
|
||||
_rgpeak = float(_audio.get('REPLAYGAIN_TRACK_PEAK')[0])
|
||||
elif _audio.get('replaygain_track_peak'):
|
||||
_rgpeak = float(_audio.get('replaygain_track_peak')[0])
|
||||
else:
|
||||
_rgpeak = None
|
||||
# determine ffmpeg arguments
|
||||
if args.bake and _rggain is not None:
|
||||
_bake_args, _flac2pod_rg_tags = ['-filter:a', 'volume=' + str(_rggain) + 'dB'], []
|
||||
elif _rggain is not None and _rgpeak is not None:
|
||||
_bake_args, _flac2pod_rg_tags = [], ['-metadata', f"comment=FLAC2PODRG#{_rggain}#{_rgpeak}#"]
|
||||
else:
|
||||
_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
|
||||
_cmd = ['ffmpeg', '-i', _file] + _art_args + ['-c:a', 'aac', '-b:a', '256k'] + _bake_args +\
|
||||
_flac2pod_rg_tags + ['-aac_pns', '0', '-movflags', '+faststart', _file_d]
|
||||
if _rggain is not None:
|
||||
print(f"\u001b[38;5;0;48;5;15mGain adjustment: {_rggain}dB\u001b[0m")
|
||||
else:
|
||||
print('\u001b[38;5;0;48;5;88mNo ReplayGain data found!\u001b[0m')
|
||||
if args.stopifnogain:
|
||||
s_exit(1)
|
||||
Popen(_cmd, stdout=DEVNULL, stderr=DEVNULL)
|
||||
_active_processes = count_user_ffmpeg_processes()
|
||||
while _active_processes != 0:
|
||||
print(f"\nPlease wait for the remaining {_active_processes} conversions to complete...\n")
|
||||
sleep(1)
|
||||
_active_processes = count_user_ffmpeg_processes()
|
||||
print('\niPod conversion complete!\n')
|
||||
s_exit(0)
|
||||
|
||||
|
||||
# argument parsing
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser(description='Convert your existing FLAC library to be played on an iPod Classic.')
|
||||
parser.add_argument('source_dir', nargs='+',
|
||||
help='directory tree containing music files - folder must contain library sorted into artists '
|
||||
'and albums')
|
||||
parser.add_argument('destination_dir', nargs='+',
|
||||
help='destination parent directory for output - will be created if it does not already exist')
|
||||
parser.add_argument('-b', '--bake', action='store_true',
|
||||
help='bake (encode) ReplayGain values into output files')
|
||||
parser.add_argument('-a', '--albumgain', action='store_true',
|
||||
help='read ReplayGain album gain instead of ReplayGain track gain')
|
||||
parser.add_argument('-x', '--stopifnogain', action='store_true',
|
||||
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()
|
||||
|
||||
if args.source_dir[0].endswith('/'):
|
||||
source = args.source_dir[0][:-1]
|
||||
else:
|
||||
source = args.source_dir[0]
|
||||
if args.destination_dir[0].endswith('/'):
|
||||
destination = args.destination_dir[0][:-1]
|
||||
else:
|
||||
destination = args.destination_dir[0]
|
||||
|
||||
source_directories = scan_source(source)
|
||||
create_destination()
|
||||
scan_destination_convert()
|
||||
+23
-27
@@ -1,14 +1,12 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script packages flac2pod (from source) for Arch Linux.
|
||||
echo -e '\n\nthe value entered in this field will only affect the version reported to the package manager - the latest source is used regardless\n'
|
||||
read -r -p "version number: " version
|
||||
read -r -p "revision number: " revision
|
||||
|
||||
echo -e '\n\nThe value entered in this field will only affect the version reported to the package manager. The latest source is used regardless.\n'
|
||||
read -r -p "Version number: " version
|
||||
read -r -p "Revision number: " revision
|
||||
|
||||
echo -e '\nOptions (please enter the number only):'
|
||||
echo -e '\n1. GitHub Release Tag\n2. Local\n'
|
||||
read -r -p "Source (for build scripts): " source
|
||||
echo -e '\noptions (please enter the number only):'
|
||||
echo -e '\n1. gitHub release tag\n2. local\n'
|
||||
read -r -p "source (for build scripts): " source
|
||||
|
||||
if [ "$source" == "1" ]; then
|
||||
source='https://github.com/rwinkhart/flac2pod/releases/download/v$pkgver/flac2pod-$pkgver.tar.xz'
|
||||
@@ -16,22 +14,23 @@ else
|
||||
source=local://flac2pod-"$version".tar.xz
|
||||
fi
|
||||
|
||||
|
||||
# Archive creation
|
||||
echo -e '\nPackaging as generic...\n'
|
||||
mkdir -p packages/archtemp/usr
|
||||
cp -r bin packages/archtemp/usr/
|
||||
cp -r share packages/archtemp/usr/
|
||||
tar -C packages/archtemp -cvf packages/flac2pod-"$version".tar.xz usr/
|
||||
rm -rf packages/archtemp
|
||||
sha512="$(sha512sum packages/flac2pod-"$version".tar.xz | awk '{print $1;}')"
|
||||
# generic packaging
|
||||
echo -e '\npackaging as generic...\n'
|
||||
mkdir -p output/generictemp/usr/{bin,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-artconvert.py output/generictemp/usr/bin/flac2pod-artconvert
|
||||
ln -s /usr/lib/flac2pod/flac2pod-flacgain.py output/generictemp/usr/bin/flac2pod-flacgain
|
||||
cp -r share output/generictemp/usr/
|
||||
tar -C output/generictemp -cvJf output/flac2pod-"$version".tar.xz usr/
|
||||
rm -rf output/generictemp
|
||||
sha512="$(sha512sum output/flac2pod-"$version".tar.xz | awk '{print $1;}')"
|
||||
echo -e "\nsha512 sum:\n$sha512"
|
||||
echo -e "\nGeneric packaging complete.\n"
|
||||
echo -e "\ngeneric packaging complete\n"
|
||||
|
||||
# PKGBUILD creation
|
||||
echo -e '\nGenerating PKGBUILD...'
|
||||
echo -e '\ngenerating PKGBUILD...'
|
||||
echo "# Maintainer: Randall Winkhart <idgr at tutanota dot com>
|
||||
|
||||
pkgname=flac2pod
|
||||
pkgver="$version"
|
||||
pkgrel="$revision"
|
||||
@@ -39,15 +38,12 @@ pkgdesc='Converts your FLAC library to be iPod-ready'
|
||||
url='https://github.com/rwinkhart/flac2pod'
|
||||
arch=('any')
|
||||
license=('GPL2')
|
||||
depends=(python ffmpeg lame rg2sc)
|
||||
|
||||
depends=(ffmpeg flac python python-mutagen python-pillow)
|
||||
source=(\""$source"\")
|
||||
sha512sums=('"$sha512"')
|
||||
|
||||
package() {
|
||||
|
||||
tar xf flac2pod-"\"\$pkgver\"".tar.xz -C "\"\${pkgdir}\""
|
||||
|
||||
}
|
||||
" > packages/PKGBUILD
|
||||
echo -e "\nPKGBUILD generated.\n"
|
||||
" > output/PKGBUILD
|
||||
echo -e "\nPKGBUILD generated\n"
|
||||
|
||||
Executable → Regular
+1
-1
@@ -1,5 +1,5 @@
|
||||
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
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
Reference in New Issue
Block a user