Skip to content

Commit 036cc8e

Browse files
committed
2.5.013
1 parent 4a65951 commit 036cc8e

File tree

7 files changed

+84
-23
lines changed

7 files changed

+84
-23
lines changed

.github/README.md

+63-2
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.012)
98+
xk media library subcommands (v2.5.013)
9999

100100
Create database subcommands:
101101
╭───────────────┬────────────────────────────────────────────────────╮
@@ -596,7 +596,43 @@ BTW, for some cols like time_deleted you'll need to specify a where clause so th
596596

597597
Scan open directories
598598

599-
library download open_dir.db --fs --prefix ~/d/dump/video/ --relative -vv -s factory -p
599+
library web-add open_dir.db --video http://1.1.1.1/
600+
601+
Check download size of all videos matching some criteria
602+
603+
library download --fs open_dir.db --prefix ~/d/dump/video/ -w 'height<720' -E preview -pa
604+
605+
path count download_duration size avg_size
606+
--------- ------- ---------------------------- --------- ----------
607+
Aggregate 5694 2 years, 7 months and 5 days 724.4 GiB 130.3 MiB
608+
609+
Download all videos matching some criteria
610+
611+
library download --fs open_dir.db --prefix ~/d/dump/video/ -w 'height<720' -E preview
612+
613+
Stream directly to mpv
614+
615+
library watch open_dir.db
616+
617+
Check videos before downloading
618+
619+
library watch open_dir.db --online-media-only --loop --exit-code-confirm -i --action ask-keep -m 4 --start 35% --volume=0 -w 'height<720' -E preview
620+
621+
Assuming you have bound in mpv input.conf a key to 'quit' and another key to 'quit 4', using the ask-keep action will mark a video as deleted when you 'quit 4' and it will mark a video as watched when you 'quit'.
622+
623+
For example, here I bind "'" to "KEEP" and "j" to "DELETE"
624+
625+
' quit
626+
j quit 4
627+
628+
This is pretty intuitive after you use it a few times but writing this out I realize this might seem a bit complicated and brittle. You could also do something like `--cmd5 'echo {} >> chosen.txt' --cmd6 'echo {} >> rejected.txt'` instead of post-actions like `ask-keep`; this might be a bit more transparent. But you will still need to bind some keys in mpv:
629+
630+
k quit 5
631+
r quit 6
632+
633+
Download checked videos
634+
635+
library download --fs open_dir.db --prefix ~/d/dump/video/ -w 'id in (select media_id from history)'
600636

601637

602638

@@ -1340,6 +1376,27 @@ BTW, for some cols like time_deleted you'll need to specify a where clause so th
13401376
library watch -m 4 --loop --crop # play four cropped videos on a loop
13411377
library watch -m 4 --hstack # use hstack style
13421378

1379+
When using `--multiple-playback` it may be helpful to set simple window focus rules to prevent keys from accidentally being entered in the wrong mpv window (as new windows are created and capture the cursor focus).
1380+
You can set and restore your previous mouse focus setting by wrapping the command like this:
1381+
1382+
focus-under-mouse
1383+
library watch ... --multiple-playback 4
1384+
focus-follows-mouse
1385+
1386+
For example in KDE:
1387+
1388+
function focus-under-mouse
1389+
kwriteconfig5 --file kwinrc --group Windows --key FocusPolicy FocusUnderMouse
1390+
qdbus-qt5 org.kde.KWin /KWin reconfigure
1391+
end
1392+
1393+
function focus-follows-mouse
1394+
kwriteconfig5 --file kwinrc --group Windows --key FocusPolicy FocusFollowsMouse
1395+
kwriteconfig5 --file kwinrc --group Windows --key NextFocusPrefersMouse true
1396+
qdbus-qt5 org.kde.KWin /KWin reconfigure
1397+
end
1398+
1399+
13431400

13441401
</details>
13451402

@@ -1925,6 +1982,10 @@ BTW, for some cols like time_deleted you'll need to specify a where clause so th
19251982
image2.jpg
19261983
image3.jpg' | library cluster-sort --image --move-groups
19271984

1985+
Print similar paths
1986+
1987+
library fs 0day.db -pa --cluster --print-groups
1988+
19281989

19291990

19301991
</details>

xklb/__init__.py

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

xklb/fs_extract.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def extract_metadata(mp_args, path) -> Optional[Dict[str, int]]:
200200
else:
201201
log.debug(f"{timer()-start} {path}")
202202

203-
if getattr(mp_args, "hash", False) and media['type'] != "directory" and media['size'] > 0:
203+
if getattr(mp_args, "hash", False) and media["type"] != "directory" and media["size"] > 0:
204204
media["hash"] = sample_hash.sample_hash_file(path)
205205

206206
if getattr(mp_args, "move", False) and not file_utils.is_file_open(path):

xklb/media/dedupe.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -363,48 +363,48 @@ def get_fs_duplicates(args) -> List[dict]:
363363

364364
size_groups = defaultdict(list)
365365
for m in media:
366-
size_groups[m['size']].append(m)
366+
size_groups[m["size"]].append(m)
367367
size_groups = [l for l in size_groups.values() if len(l) > 1]
368368

369-
size_paths = [d['path'] for g in size_groups for d in g]
370-
media = [d for d in media if d['path'] in size_paths]
369+
size_paths = [d["path"] for g in size_groups for d in g]
370+
media = [d for d in media if d["path"] in size_paths]
371371
log.info(
372-
'Got %s size matches (%s dup groups). Doing sample-hash comparison...',
372+
"Got %s size duplicates (%s groups). Doing sample-hash comparison...",
373373
len(size_paths),
374374
len(size_groups),
375375
)
376376

377-
sample_hash_paths = [d['path'] for d in media if not d.get('hash')]
377+
sample_hash_paths = [d["path"] for d in media if not d.get("hash")]
378378
with ThreadPoolExecutor(max_workers=20) as pool:
379379
hash_results = list(pool.map(sample_hash.sample_hash_file, sample_hash_paths))
380380
for path, hash in zip(sample_hash_paths, hash_results):
381381
for m in media:
382-
if m['path'] == path:
382+
if m["path"] == path:
383383
if hash is None:
384-
media = [ d for d in media if d['path'] != path ]
384+
media = [d for d in media if d["path"] != path]
385385
else:
386-
m['hash'] = hash
386+
m["hash"] = hash
387387
args.db["media"].upsert(m, pk=["path"], alter=True) # save sample-hash back to db
388388
break
389389

390390
sample_hash_groups = defaultdict(list)
391391
for m in media:
392-
sample_hash_groups[m['hash']].append(m)
392+
sample_hash_groups[m["hash"]].append(m)
393393
sample_hash_groups = [l for l in sample_hash_groups.values() if len(l) > 1]
394394

395395
log.info(
396-
'Got %s sample-hash matches (%s dup groups). Doing full hash comparison...',
396+
"Got %s sample-hash duplicates (%s groups). Doing full hash comparison...",
397397
len(list(iterables.flatten(sample_hash_groups))),
398398
len(sample_hash_groups),
399399
)
400400

401401
size_map = {}
402402
for m in media:
403-
size_map[m['path']] = m['size']
403+
size_map[m["path"]] = m["size"]
404404

405405
dup_media = []
406406
for g in sample_hash_groups:
407-
check_paths = [d['path'] for d in g]
407+
check_paths = [d["path"] for d in g]
408408
with ThreadPoolExecutor(max_workers=5) as pool:
409409
hash_results = list(pool.map(sample_compare.full_hash_file, check_paths))
410410
hash_groups = defaultdict(list)
@@ -414,7 +414,7 @@ def get_fs_duplicates(args) -> List[dict]:
414414
if len(paths) > 1:
415415
keep_path = paths[0]
416416
dup_media.extend(
417-
{'keep_path': keep_path, 'duplicate_path': p, 'duplicate_size': size_map[keep_path]}
417+
{"keep_path": keep_path, "duplicate_path": p, "duplicate_size": size_map[keep_path]}
418418
for p in paths[1:]
419419
)
420420

xklb/play_actions.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ def ii(string):
339339
limit = 16 * (args.limit or consts.DEFAULT_PLAY_QUEUE)
340340
where_not_deleted = (
341341
"where COALESCE(time_deleted,0) = 0"
342-
if "time_deleted" in m_columns and "deleted" not in args.sort_groups_by and "time_deleted" not in " ".join(args.where)
342+
if "time_deleted" in m_columns
343+
and "deleted" not in args.sort_groups_by
344+
and "time_deleted" not in " ".join(args.where)
343345
else ""
344346
)
345347
args.filter_sql.append(

xklb/post_actions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ def external_action(args, log_action, media_file, player_exit_code, player_proce
141141
cmd = getattr(args, player_exit_code_cmd, None)
142142
if cmd:
143143
log_action(player_exit_code_cmd.upper())
144-
if cmd in ['pass', 'mark-watched']:
144+
if cmd in ["pass", "mark-watched"]:
145145
pass
146-
elif cmd in ['soft-delete', 'mark-deleted']:
146+
elif cmd in ["soft-delete", "mark-deleted"]:
147147
db_media.mark_media_deleted(args, media_file)
148-
elif cmd in ['delete']:
148+
elif cmd in ["delete"]:
149149
if media_file.startswith("http"):
150150
db_media.mark_media_deleted(args, media_file)
151151
else:

xklb/scripts/merge_folders.py

-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ def gen_rename_data(destination_folder, destination_files, source_folder, source
7070
return source_rename_data
7171

7272

73-
74-
7573
def get_clobber(args):
7674
choice = None
7775
if args.replace:

0 commit comments

Comments
 (0)