From 01a332a6c8f40fe3a669bd45850b63eaa56ba1c1 Mon Sep 17 00:00:00 2001 From: Jacob Chapman <7908073+chapmanjacobd@users.noreply.github.com> Date: Mon, 13 May 2024 00:00:13 +0800 Subject: [PATCH] 2.8.010 --- .github/README.md | 2 +- ff.py | 67 ---------------------------------------- xklb/__init__.py | 2 +- xklb/mediadb/db_media.py | 5 +-- xklb/utils/arggroups.py | 8 +++-- 5 files changed, 11 insertions(+), 73 deletions(-) delete mode 100755 ff.py diff --git a/.github/README.md b/.github/README.md index 66143bd6..a63edd8e 100644 --- a/.github/README.md +++ b/.github/README.md @@ -97,7 +97,7 @@ To stop playing press Ctrl+C in either the terminal or mpv
List all subcommands $ library - library (v2.8.009; 72 subcommands) + library (v2.8.010; 72 subcommands) Create database subcommands: ╭───────────────┬──────────────────────────────────────────╮ diff --git a/ff.py b/ff.py deleted file mode 100755 index c37117cb..00000000 --- a/ff.py +++ /dev/null @@ -1,67 +0,0 @@ -import hashlib -import os -import subprocess -import sys - -from xklb.utils import arggroups, argparse_utils, processes - - -def parse_args(): - parser = argparse_utils.ArgumentParser(description='Decode I-frame and calculate SHA1.') - parser.add_argument('--iframes', nargs='*', type=int, default=[1], help='The specific I-frame to decode.') - arggroups.debug(parser) - - parser.add_argument('path', type=str, help='Path to the video file.') - - args = parser.parse_args() - arggroups.args_post(args, parser) - - return args - -# ffmpeg -nostdin -r 200 -i in.mkv -vf "select='eq(pict_type,I)'" -fps_mode passthrough -an -y out.mp4 - - - -def decode_iframes(args): - return subprocess.Popen( - ( - 'ffmpeg', - '-nostdin', - '-i', - args.path, - '-an','-fps_mode','passthrough', - "-vf", - "select='eq(pict_type,I)'", - '-vf', - ','.join(fr'select=eq(n\,{i})' for i in args.iframes), - '-vframes', - # '1', - str(len(args.iframes)), - '-c:v', - 'rawvideo', - '-pixel_format', 'rgb24', - '-f', - 'image2pipe', - '-', - ), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE if args.verbose == 0 else None, - ) - - -def data_sha1(data): - sha1_hash = hashlib.sha1() - sha1_hash.update(data) - return sha1_hash.hexdigest() - - -def main(): - args = parse_args() - r = decode_iframes(args) - stdout, stderr = r.communicate() - sha1 = data_sha1(stdout) - print(sha1) - - -if __name__ == '__main__': - main() diff --git a/xklb/__init__.py b/xklb/__init__.py index 410498c2..022101f8 100644 --- a/xklb/__init__.py +++ b/xklb/__init__.py @@ -1 +1 @@ -__version__ = "2.8.009" +__version__ = "2.8.010" diff --git a/xklb/mediadb/db_media.py b/xklb/mediadb/db_media.py index 286b8d27..f2248445 100644 --- a/xklb/mediadb/db_media.py +++ b/xklb/mediadb/db_media.py @@ -390,6 +390,7 @@ def get_dir_media(args, dirs: Collection, include_subdirs=False, limit=2_000) -> WHERE 1=1 and m.id in (select id from {args.table}) {filter_paths} + {" ".join(args.filter_sql)} GROUP BY m.id, m.path ) SELECT * @@ -532,13 +533,13 @@ def get_related_media(args, m: dict) -> list[dict]: LEFT JOIN history h on h.media_id = m.id WHERE 1=1 and path != :path - {'' if args.related >= consts.RELATED_NO_FILTER else (" ".join(args.filter_sql) or '')} + {'' if args.related >= consts.RELATED_NO_FILTER else " ".join(args.filter_sql)} GROUP BY m.id, m.path ) SELECT * FROM m WHERE 1=1 - {'' if args.related >= consts.RELATED_NO_FILTER else (" ".join(args.aggregate_filter_sql) or '')} + {'' if args.related >= consts.RELATED_NO_FILTER else " ".join(args.aggregate_filter_sql)} ORDER BY play_count , m.path like "http%" , {'rank' if 'sort' in args.defaults else f'ntile(1000) over (order by rank)' + (f', {args.sort}' if args.sort else '')} diff --git a/xklb/utils/arggroups.py b/xklb/utils/arggroups.py index 36eb16dc..2a6bbf2e 100644 --- a/xklb/utils/arggroups.py +++ b/xklb/utils/arggroups.py @@ -32,8 +32,12 @@ def get_caller_name(): def args_post(args, parser, create_db=False): - args.defaults = {k:v for k, v in args.__dict__.items() if parser.get_default(k) == v} - settings = {k: v for k, v in args.__dict__.items() if k not in ["database", "verbose", "defaults"] + list(args.defaults.keys())} + args.defaults = {k: v for k, v in args.__dict__.items() if parser.get_default(k) == v} + settings = { + k: v + for k, v in args.__dict__.items() + if k not in ["database", "verbose", "defaults"] + list(args.defaults.keys()) + } args.extractor_config = { k: v for k, v in settings.items() if k not in ["db", "paths", "actions", "backfill_pages"] } | (getattr(args, "extractor_config", None) or {})