using ffmpeg directly instead of AAXtoMP3

This commit is contained in:
benton 2021-11-06 14:29:50 -05:00
parent c5c8750587
commit 98faaa4579
4 changed files with 29 additions and 68 deletions

View file

@ -7,17 +7,14 @@
]
},
"locked": {
"lastModified": 1631424389,
"narHash": "sha256-Nbs8FjqdJQwSBG8AjfOefqjbqVueO2o5HGz4/7YdQMM=",
"owner": "BentonEdmondson",
"repo": "benpkgs",
"rev": "d6cd8eab1c25cb1186de283f28c9afed97c49dd2",
"type": "github"
"lastModified": 1633315458,
"narHash": "sha256-CKlsbD3I+CduADnEbPZV+LD4ByQ0RiDy39F3z6DKOQc=",
"type": "git",
"url": "file:///home/benton/git/benpkgs"
},
"original": {
"owner": "BentonEdmondson",
"repo": "benpkgs",
"type": "github"
"type": "git",
"url": "file:///home/benton/git/benpkgs"
}
},
"inept-epub": {
@ -40,33 +37,13 @@
"type": "github"
}
},
"libgourou-utils": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1631412686,
"narHash": "sha256-u0v3qU+qckvZE/obCHjeyktcvH8Wyo4Zld9AxEI53bI=",
"owner": "BentonEdmondson",
"repo": "libgourou-utils",
"rev": "88d6dc2b549a28f886a15a7992890d60e576716d",
"type": "github"
},
"original": {
"owner": "BentonEdmondson",
"repo": "libgourou-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1631381596,
"narHash": "sha256-Xk91RO0uMyul8fWo3RP7WqEP5bsKUVucJRgLZgascAo=",
"lastModified": 1633080050,
"narHash": "sha256-T9I2WnlUzAIL70dk9V1jqaYk3nypy/cMkWR19S47ZHc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f6e9e908ccbcabb365cb5434a4a38dd8c996fc72",
"rev": "82155ff501c7622cb2336646bb62f7624261f6d7",
"type": "github"
},
"original": {
@ -80,7 +57,6 @@
"inputs": {
"benpkgs": "benpkgs",
"inept-epub": "inept-epub",
"libgourou-utils": "libgourou-utils",
"nixpkgs": "nixpkgs"
}
}

View file

@ -2,13 +2,10 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
libgourou-utils.url = "github:BentonEdmondson/libgourou-utils";
libgourou-utils.inputs.nixpkgs.follows = "nixpkgs";
inept-epub.url = "github:BentonEdmondson/inept-epub";
inept-epub.inputs.nixpkgs.follows = "nixpkgs";
benpkgs.url = "github:BentonEdmondson/benpkgs";
benpkgs.url = "git+file:///home/benton/git/benpkgs";
benpkgs.inputs.nixpkgs.follows = "nixpkgs";
};
@ -18,19 +15,24 @@
inept-epub = flakes.inept-epub.defaultPackage.x86_64-linux;
benpkgs = flakes.benpkgs.packages.x86_64-linux;
in {
defaultPackage.x86_64-linux = nixpkgs.python3Packages.buildPythonApplication {
defaultPackage.x86_64-linux = nixpkgs.python3Packages.buildPythonApplication rec {
pname = "knock";
version = "1.0.0-alpha";
src = self;
src = ./.;
nativeBuildInputs = [ nixpkgs.makeWrapper ];
buildInputs = [
inept-epub
benpkgs.libgourou
nixpkgs.ffmpeg
];
propagatedBuildInputs = [
nixpkgs.python3Packages.python_magic
nixpkgs.python3Packages.xdg
nixpkgs.python3Packages.click
libgourou-utils
inept-epub
benpkgs.Audible
benpkgs.AAXtoMP3
];
format = "other";
@ -39,6 +41,7 @@
mkdir -p $out/bin $out/${nixpkgs.python3.sitePackages}
cp lib/*.py $out/${nixpkgs.python3.sitePackages}
cp src/knock.py $out/bin/knock
wrapProgram $out/bin/knock --prefix PATH : ${nixpkgs.lib.makeBinPath buildInputs}
'';
meta = {

View file

@ -9,21 +9,11 @@ def handle_aax(aax_path):
authcode_path.parent.mkdir(parents=True, exist_ok=True)
m4b_path = aax_path.with_suffix('.m4b')
cover_path = aax_path.parent.joinpath('cover.jpg')
chapters_path = aax_path.with_suffix('.chapters.txt')
if m4b_path.exists():
click.echo(f"Error: {m4b_path} must be moved out of the way or deleted.", err=True)
sys.exit(1)
if cover_path.exists():
click.echo(f"Error: {cover_path} must be moved out of the way or deleted.", err=True)
sys.exit(1)
if chapters_path.exists():
click.echo(f"Error: {chapters_path} must be moved out of the way or deleted.", err=True)
sys.exit(1)
if not authcode_path.exists():
click.echo('This device does not have an Audible decryption key.')
@ -50,20 +40,12 @@ def handle_aax(aax_path):
authcode = authcode_path.read_text()
def cleanup():
cover_path.unlink(missing_ok=True)
chapters_path.unlink(missing_ok=True)
run([
'AAXtoMP3',
'--authcode', authcode,
'-e:m4b',
'-t', str(aax_path.parent),
'-D', '.',
'-F', str(aax_path.stem),
str(aax_path)
], cleanser=cleanup)
cleanup()
'ffmpeg',
'-activation_bytes', authcode,
'-i', str(aax_path),
'-c', 'copy', str(m4b_path),
'-loglevel', 'error'
])
click.secho(f'DRM-free M4B file created:\n{aax_path.with_suffix(".m4b")}', fg='green')

View file

@ -39,8 +39,8 @@ def main(path):
else:
click.echo(f'Error: Files of type {path_type} are not supported.\n', err=True)
click.echo('Only the following file types are currently supported:', err=True)
click.echo(' * ACSM (Adobe)\n')
click.echo(' * AAX (Audible)\n')
click.echo(' * ACSM (Adobe)\n', err=True)
click.echo(' * AAX (Audible)\n', err=True)
click.echo('Please open a feature request at:', err=True)
click.echo(f' https://github.com/BentonEdmondson/knock/issues/new?title=Support%20{path_type}%20Files&labels=enhancement', err=True)
sys.exit(1)