Skip to content

Commit 197dceb

Browse files
authored
Adding thumbnailer for .aiff files (#15)
* Adding thumbnailer for .aiff files * Fixing description
1 parent 60e7ee0 commit 197dceb

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

debian/control

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ Depends: xapp-thumbnailers-common
6363
Description: OpenRaster thumbnailer
6464
Produces thumbnails for OpenRaster (.ora) files.
6565

66+
Package: xapp-aiff-thumbnailer
67+
Architecture: all
68+
Depends: xapp-thumbnailers-common, python3-mutagen
69+
Description: AIFF thumbnailer
70+
Produces thumbnails for aiff files.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
usr/bin/xapp-aiff-thumbnailer
2+
usr/share/thumbnailers/xapp-aiff-thumbnailer.thumbnailer
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/python3
2+
import sys
3+
from pathlib import Path
4+
from typing import cast
5+
6+
from mutagen.aiff import AIFF
7+
from XappThumbnailers import Thumbnailer
8+
9+
thumbnailer = Thumbnailer()
10+
11+
12+
def extract_cover_aiff_file(filepath: Path) -> bytes | None:
13+
if not filepath.is_file() or not filepath.suffix == ".aiff":
14+
return None
15+
aiff_file: AIFF = AIFF(str(filepath))
16+
if aiff_file.tags is None:
17+
return None
18+
try:
19+
return cast(bytes, aiff_file.tags.getall("APIC")[0].data)
20+
except:
21+
pass
22+
finally:
23+
return None
24+
25+
26+
try:
27+
cover_data: bytes | None = extract_cover_aiff_file(filepath=Path(thumbnailer.args.input))
28+
if cover_data is not None:
29+
thumbnailer.save_bytes(data=cover_data)
30+
sys.exit(0)
31+
except:
32+
sys.exit(1)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[Thumbnailer Entry]
2+
TryExec=xapp-aiff-thumbnailer
3+
Exec=xapp-aiff-thumbnailer -i %i -o %o -s %s
4+
MimeType=audio/x-aiff

0 commit comments

Comments
 (0)