Skip to content

Commit 994b70e

Browse files
committed
2.5.012
1 parent f0964d2 commit 994b70e

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

.github/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ To stop playing press Ctrl+C in either the terminal or mpv
9595
<details><summary>List all subcommands</summary>
9696

9797
$ library
98-
xk media library subcommands (v2.5.011)
98+
xk media library subcommands (v2.5.012)
9999

100100
Create database subcommands:
101101
╭───────────────┬────────────────────────────────────────────────────╮

xklb/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.5.011"
1+
__version__ = "2.5.012"

xklb/fs_extract.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ def extract_metadata(mp_args, path) -> Optional[Dict[str, int]]:
213213
if getattr(mp_args, "process", False):
214214
if objects.is_profile(mp_args, DBType.audio) and Path(path).suffix not in [".opus", ".mka"]:
215215
path = media["path"] = str(
216-
process_audio.process_path(path, split_longer_than=2160 if "audiobook" in path.lower() else None)
216+
process_audio.process_path(
217+
path,
218+
split_longer_than=2160 if "audiobook" in path.lower() else None,
219+
delete_broken=getattr(mp_args, "delete_unplayable", False),
220+
)
217221
)
218222

219223
return media

xklb/scripts/process_audio.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def process_path(
3535
min_split_segment=nums.human_to_seconds(DEFAULT_MIN_SPLIT),
3636
dry_run=False,
3737
delete_video=False,
38+
delete_broken=False,
3839
):
3940
path = Path(path)
4041
assert path.exists()
@@ -60,8 +61,11 @@ def process_path(
6061
assert bitrate > 0
6162
assert channels > 0
6263
assert source_rate > 0
63-
except AssertionError as e:
64-
log.exception("Audio format likely misdetected: %s", path)
64+
except AssertionError:
65+
log.exception("Broken file or audio format misdetected: %s", path)
66+
if delete_broken:
67+
path.unlink()
68+
return None
6569
return path
6670

6771
ff_opts: List[str] = []
@@ -128,7 +132,16 @@ def process_path(
128132
if dry_run:
129133
print(cmd)
130134
else:
131-
subprocess.check_call(cmd, shell=True)
135+
try:
136+
subprocess.check_call(cmd, shell=True)
137+
except subprocess.CalledProcessError:
138+
log.exception("Could not transcode: %s", path)
139+
if delete_broken:
140+
path.unlink()
141+
return None
142+
else:
143+
raise
144+
132145
if video_stream:
133146
if delete_video:
134147
path.unlink() # Remove original

xklb/utils/consts.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def reddit_frequency(frequency) -> str:
131131

132132
SPEECH_RECOGNITION_EXTENSIONS = set("mp3|ogg|wav".split("|"))
133133
OCR_EXTENSIONS = set("gif|jpg|jpeg|png|tif|tff|tiff".split("|"))
134-
AUDIO_ONLY_EXTENSIONS = set("opus|oga|ogg|mp3|mpga|m2a|m4a|flac|wav|wma|aac|aa3|ac3|ape|mid|midi".split("|"))
134+
AUDIO_ONLY_EXTENSIONS = set("mka|opus|oga|ogg|mp3|mpga|m2a|m4a|flac|wav|wma|aac|aa3|ac3|ape|mid|midi".split("|"))
135135
VIDEO_EXTENSIONS = set(
136136
(
137137
"str|aa|aax|acm|adf|adp|dtk|ads|ss2|adx|aea|afc|aix|al|apl"
@@ -144,7 +144,7 @@ def reddit_frequency(frequency) -> str:
144144
"|mdgz|mdr|mdz|s3gz|s3r|s3z|xmgz|xmr|xmz|669|amf|ams|dbm|digi|dmf"
145145
"|dsm|dtm|far|gdm|ice|imf|it|j2b|m15|mdl|med|mmcmp|mms|mo3|mod|mptm"
146146
"|mt2|mtm|nst|okt|ogm|ogv|plm|ppm|psm|pt36|ptm|s3m|sfx|sfx2|st26|stk|stm"
147-
"|stp|ult|umx|wow|xm|xpk|flv|dat|lvf|m4v|mkv|ts|tp|mk3d|mka|mks|webm|mca|mcc"
147+
"|stp|ult|umx|wow|xm|xpk|flv|dat|lvf|m4v|mkv|ts|tp|mk3d|webm|mca|mcc"
148148
"|mjpg|mjpeg|mpg|mpeg|mpo|j2k|mlp|mods|moflex|mov|mp4|3gp|3g2|mj2|psp|m4b"
149149
"|ism|ismv|isma|f4v|mp2|mpa|mpc|mjpg|mpl2|msf|mtaf|ul|musx|mvi|mxg"
150150
"|v|nist|sph|nsp|nut|obu|oma|omg|pjs|pvf|yuv|cif|qcif|rgb|rt|rsd|rmvb|rm"
@@ -153,6 +153,7 @@ def reddit_frequency(frequency) -> str:
153153
"|v210|yuv10|vag|vc1|rcv|vob|viv|vpk|vqf|vql|vqe|wmv|wsd|xmv|xvag|yop|y4m"
154154
).split("|")
155155
)
156+
SUBTITLE_EXTENSIONS = set("srt|vtt|mks".split("|"))
156157
TEXTRACT_EXTENSIONS = set(
157158
"csv|tab|tsv|doc|docx|eml|epub|json|htm|html|msg|odt|pdf|pptx|ps|rtf|txt|log|xlsx|xls".split("|")
158159
)

0 commit comments

Comments
 (0)