sane-tag-music -> sane-tag-media, and formally support pdf
This commit is contained in:
2
TODO.md
2
TODO.md
@@ -149,7 +149,7 @@
|
||||
- have xdg-open parse `<repo:...> URIs (or adjust them so that it _can_ parse)
|
||||
- sane-bt-search: show details like 5.1 vs stereo, h264 vs h265
|
||||
- maybe just color these "keywords" in all search results?
|
||||
- transmission: apply `sane-tag-music` path fix in `torrent-done` script
|
||||
- transmission: apply `sane-tag-media` path fix in `torrent-done` script
|
||||
- many .mkv files do appear to be tagged: i'd just need to add support in my own tooling
|
||||
- uninsane.org: make URLs relative to allow local use (and as offline homepage)
|
||||
- email: fix so that local mail doesn't go to junk
|
||||
|
@@ -38,7 +38,7 @@ in
|
||||
"sane-scripts.secrets-update-keys"
|
||||
"sane-scripts.shutdown"
|
||||
"sane-scripts.sudo-redirect"
|
||||
"sane-scripts.tag-music"
|
||||
"sane-scripts.tag-media"
|
||||
"sane-scripts.vpn"
|
||||
"sane-scripts.which"
|
||||
"sane-scripts.wipe"
|
||||
@@ -218,10 +218,10 @@ in
|
||||
"sane-scripts.sync-music" = {};
|
||||
"sane-scripts.sync-from-iphone" = {};
|
||||
|
||||
"sane-scripts.tag-music".suggestedPrograms = [
|
||||
"sane-scripts.tag-media".suggestedPrograms = [
|
||||
"exiftool" #< for (slightly) better sandboxing than default exiftool
|
||||
];
|
||||
"sane-scripts.tag-music".sandbox = {
|
||||
"sane-scripts.tag-media".sandbox = {
|
||||
method = "bwrap";
|
||||
autodetectCliPaths = "existing";
|
||||
whitelistPwd = true; # for music renaming
|
||||
|
@@ -197,8 +197,8 @@ let
|
||||
srcRoot = ./src;
|
||||
pkgs = [ "ffmpeg" "python3.pkgs.unidecode" "sox" ];
|
||||
};
|
||||
tag-music = static-nix-shell.mkPython3 {
|
||||
pname = "sane-tag-music";
|
||||
tag-media = static-nix-shell.mkPython3 {
|
||||
pname = "sane-tag-media";
|
||||
srcRoot = ./src;
|
||||
pkgs = [ "python3.pkgs.mutagen" "python3.pkgs.pyexiftool" "python3.pkgs.pykakasi" "python3.pkgs.unidecode" ];
|
||||
};
|
||||
|
@@ -61,7 +61,7 @@
|
||||
# mutagen docs:
|
||||
# - <https://mutagen.readthedocs.io/en/latest/>
|
||||
"""
|
||||
tool which runs over a complete music library or a subset of it and:
|
||||
tool which runs over a complete music library (or audiobooks, videos, ebooks (limited)) or a subset of it and:
|
||||
- detect tags which are missing or likely incorrect
|
||||
- write new tags to existing media
|
||||
- new tags are specified manually (--artist, --album, ...)
|
||||
@@ -69,9 +69,9 @@ tool which runs over a complete music library or a subset of it and:
|
||||
|
||||
this tool does NOT move or rename files. it only edits tags.
|
||||
|
||||
USAGE: cd MUSIC_LIBRARY_TOP && sane-tag-music [options] fix-paths|fix-tags|print-missing|show [cmd-specific options] DIRECTORY [DIRECTORY ...]
|
||||
USAGE: cd MEDIA_LIBRARY_TOP && sane-tag-media [options] fix-paths|fix-tags|print-missing|show [cmd-specific options] DIRECTORY [DIRECTORY ...]
|
||||
|
||||
scans DIRECTORY and guesses artist/album/title for each track, based on path relative to pwd.
|
||||
scans DIRECTORY and guesses artist/album/title for each file, based on path relative to pwd.
|
||||
if the guessed tags look more correct than the existing tags (i.e. if the existing file is missing a tag),
|
||||
then this updates the tags on-disk to reflect their path.
|
||||
|
||||
@@ -87,7 +87,7 @@ options:
|
||||
--title TITLE
|
||||
--trackno TRACK_NUMBER
|
||||
--derive apply existing tags (e.g. album) found in the file set to any files in the set missing such tags
|
||||
--type audio|image skip files which aren't of some specific media type
|
||||
--type audio|image|text skip files which aren't of some specific media type
|
||||
|
||||
fix-tags options:
|
||||
--force: apply path-based tag to each file, even those which already have tags
|
||||
@@ -130,6 +130,9 @@ IMAGE_EXTENSIONS = [
|
||||
"jpeg",
|
||||
"png",
|
||||
]
|
||||
TEXT_EXTENSIONS = [
|
||||
"pdf",
|
||||
]
|
||||
|
||||
# some software encodes its name in the "producer" metadata field,
|
||||
# whereas i use that field to mean "producer" as "which studio produced this".
|
||||
@@ -145,6 +148,7 @@ KNOWN_SOFTWARE_PRODUCERS = [
|
||||
class MediaType(Enum):
|
||||
Audio = "audio"
|
||||
Image = "image"
|
||||
Text = "text"
|
||||
Other = "other"
|
||||
|
||||
def maybe_romanize(a: str) -> str|None:
|
||||
@@ -746,10 +750,12 @@ class MediaFile:
|
||||
def is_type(self, ty: MediaType) -> bool:
|
||||
is_audio = self.ext in AUDIO_EXTENSIONS
|
||||
is_image = self.ext in IMAGE_EXTENSIONS
|
||||
is_text = self.ext in TEXT_EXTENSIONS
|
||||
want_audio = ty == MediaType.Audio
|
||||
want_image = ty == MediaType.Image
|
||||
want_text = ty == MediaType.Text
|
||||
|
||||
return is_audio == want_audio and is_image == want_image
|
||||
return is_audio == want_audio and is_image == want_image and is_text == want_text
|
||||
|
||||
def tags_on_disk(self) -> Tags:
|
||||
return Tags(
|
Reference in New Issue
Block a user