Skip to content

Commit

Permalink
2.9.039
Browse files Browse the repository at this point in the history
  • Loading branch information
chapmanjacobd committed Aug 31, 2024
1 parent 8caaef8 commit 0ab549f
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ To stop playing press Ctrl+C in either the terminal or mpv
<details><summary>List all subcommands</summary>

$ library
library (v2.9.038; 84 subcommands)
library (v2.9.039; 84 subcommands)

Create database subcommands:
╭─────────────────┬──────────────────────────────────────────╮
Expand Down
96 changes: 48 additions & 48 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion xklb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from xklb.utils import argparse_utils, iterables
from xklb.utils.log_utils import log

__version__ = "2.9.038"
__version__ = "2.9.039"

progs = {
"Create database subcommands": {
Expand Down
2 changes: 1 addition & 1 deletion xklb/editdb/mpv_watchlater.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def scan_and_import(args, media) -> None:
**(md5s.get(p.stem) or {}),
"time_first_played": int(p.stat().st_ctime),
"time_last_played": int(p.stat().st_mtime),
"playhead": nums.safe_int(mpv_utils.mpv_watchlater_value(p, "start")),
"playhead": nums.safe_int(mpv_utils.mpv_watchlater_value(p, "start")) or 0,
}
for p in paths
if md5s.get(p.stem)
Expand Down
2 changes: 1 addition & 1 deletion xklb/mediadb/db_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def add(args, paths=None, media_ids=None, time_played=None, playhead=None, mark_
{
"media_id": media_id,
"time_played": time_played or consts.now(),
"playhead": playhead,
"playhead": playhead or 0,
"done": mark_done,
}
for media_id in media_ids
Expand Down
2 changes: 1 addition & 1 deletion xklb/multidb/copy_play_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def copy_play_count(args, source_db) -> None:
args,
[renamed_path],
time_played=d.get("time_played"),
playhead=d.get("playhead"),
playhead=d.get("playhead") or 0,
mark_done=d["done"],
)

Expand Down
2 changes: 1 addition & 1 deletion xklb/playback/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def play(args, m, media_len) -> None:
args,
m["original_path"],
start_time,
existing_playhead=m.get("playhead"),
existing_playhead=m.get("playhead") or 0,
media_duration=m.get("duration"),
)
log.debug("save_playhead %s", playhead)
Expand Down
3 changes: 2 additions & 1 deletion xklb/utils/sqlgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def perf_randomize_using_ids(args, m_columns):

def media_sql(args) -> tuple[str, dict]:
m_columns = db_utils.columns(args, "media")
h_columns = db_utils.columns(args, "history")
args.table, m_columns = sql_utils.search_filter(args, m_columns)

perf_randomize_using_ids(args, m_columns)
Expand All @@ -69,7 +70,7 @@ def media_sql(args) -> tuple[str, dict]:
, SUM(CASE WHEN h.done = 1 THEN 1 ELSE 0 END) play_count
, MIN(h.time_played) time_first_played
, MAX(h.time_played) time_last_played
, FIRST_VALUE(h.playhead) OVER (PARTITION BY h.media_id ORDER BY h.time_played DESC) playhead
{', FIRST_VALUE(h.playhead) OVER (PARTITION BY h.media_id ORDER BY h.time_played DESC) playhead' if 'playhead' in h_columns else ''}
, *
FROM {args.table} m
LEFT JOIN history h on h.media_id = m.id
Expand Down

0 comments on commit 0ab549f

Please sign in to comment.