Skip to content

Commit

Permalink
fix --where "x OR y"
Browse files Browse the repository at this point in the history
  • Loading branch information
chapmanjacobd committed Feb 15, 2025
1 parent 7599a98 commit 9e52432
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
3 changes: 2 additions & 1 deletion library/multidb/allocate_torrents.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ def allocate_torrents():
"-m",
"library",
"torrents-start",
*argparse_utils.forward_arggroups(args, arggroups.qBittorrent),
*argparse_utils.forward_arggroups(
args,
arggroups.qBittorrent,
arggroups.qBittorrent_paths,
download_drive=d["mountpoint"],
),
*torrent_files,
Expand Down
31 changes: 15 additions & 16 deletions library/playback/torrents_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ def parse_args():
parser.add_argument("--tag", help="Add a tag to matching torrents")
parser.add_argument("--untag", "--un-tag", "--no-tag", help="Remove a tag to matching torrents")
parser.add_argument("--stop", action="store_true", help="Stop matching torrents")
parser.add_argument("--check", "--recheck", action="store_true", help="Check matching torrents")
parser.add_argument("--start", action=argparse.BooleanOptionalAction, help="Start matching torrents")
parser.add_argument("--force-start", action=argparse.BooleanOptionalAction, help="Force start matching torrents")
parser.add_argument(
"--delete-incomplete",
nargs="?",
Expand All @@ -36,7 +33,9 @@ def parse_args():
help="Delete incomplete files from matching torrents",
)
parser.add_argument("--move", help="Directory to move folders/files")

parser.add_argument("--start", action=argparse.BooleanOptionalAction, help="Start matching torrents")
parser.add_argument("--force-start", action=argparse.BooleanOptionalAction, help="Force start matching torrents")
parser.add_argument("--check", "--recheck", action="store_true", help="Check matching torrents")
parser.add_argument("--export", action="store_true", help="Export matching torrent files")

arggroups.capability_soft_delete(parser)
Expand Down Expand Up @@ -412,18 +411,6 @@ def gen_row(t):
print("Stopping", len(torrents))
qbt_client.torrents_stop(torrent_hashes=torrent_hashes)

if args.check:
print("Checking", len(torrents))
qbt_client.torrents_recheck(torrent_hashes=torrent_hashes)

if args.start is not None:
print("Starting", len(torrents))
qbt_client.torrents_start(torrent_hashes=torrent_hashes)

if args.force_start is not None:
print("Force-starting", len(torrents))
qbt_client.torrents_set_force_start(args.force_start, torrent_hashes=torrent_hashes)

if args.delete_incomplete:
for t in torrents:
# check both in case of moving failure
Expand Down Expand Up @@ -504,6 +491,18 @@ def gen_row(t):
print(t.save_path, "==>", download_path)
qbt_client.torrents_set_save_path(download_path, torrent_hashes=[t.hash])

if args.start is not None:
print("Starting", len(torrents))
qbt_client.torrents_start(torrent_hashes=torrent_hashes)

if args.force_start is not None:
print("Force-starting", len(torrents))
qbt_client.torrents_set_force_start(args.force_start, torrent_hashes=torrent_hashes)

if args.check:
print("Checking", len(torrents))
qbt_client.torrents_recheck(torrent_hashes=torrent_hashes)

if args.export:
print("Exporting", len(torrents))
p = Path("exported_torrents")
Expand Down
14 changes: 7 additions & 7 deletions library/utils/sqlgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def fs_sql(args, limit) -> tuple[str, dict]:
{media_select_sql(args, m_columns)}
FROM {args.table} m
WHERE 1=1
{" ".join(args.filter_sql)}
AND (1=1 {" ".join(args.filter_sql)})
{" ".join(args.aggregate_filter_sql)}
ORDER BY 1=1
{', ' + args.sort if args.sort else ''}
Expand All @@ -49,7 +49,7 @@ def playlists_fs_sql(args, limit) -> tuple[str, dict]:
m.*
FROM {args.table} m
WHERE 1=1
{" ".join(args.filter_sql)}
AND (1=1 {" ".join(args.filter_sql)})
{" ".join(args.aggregate_filter_sql)}
ORDER BY 1=1
{', ' + args.sort if args.sort else ''}
Expand Down Expand Up @@ -88,7 +88,7 @@ def media_sql(args) -> tuple[str, dict]:
FROM {args.table} m
LEFT JOIN history h on h.media_id = m.rowid
WHERE 1=1
{" ".join(args.filter_sql)}
AND (1=1 {" ".join(args.filter_sql)})
GROUP BY m.rowid, m.path
)
SELECT
Expand Down Expand Up @@ -165,7 +165,7 @@ def construct_links_query(args, limit) -> tuple[str, dict]:
FROM {args.table} m
LEFT JOIN history h on h.media_id = m.rowid
WHERE 1=1
{" ".join(args.filter_sql)}
AND (1=1 {" ".join(args.filter_sql)})
GROUP BY m.rowid
)
SELECT
Expand Down Expand Up @@ -202,7 +202,7 @@ def construct_tabs_query(args) -> tuple[str, dict]:
FROM {args.table} m
LEFT JOIN history h on h.media_id = m.rowid
WHERE 1=1
{" ".join(args.filter_sql)}
AND (1=1 {" ".join(args.filter_sql)})
GROUP BY m.rowid
), time_valid_tabs as (
SELECT
Expand Down Expand Up @@ -355,7 +355,7 @@ def construct_playlists_query(args) -> tuple[str, dict]:
query = f"""SELECT *
FROM {pl_table} m
WHERE 1=1
{" ".join(args.filter_sql)}
AND (1=1 {" ".join(args.filter_sql)})
{'AND extractor_key != "Local"' if args.online_media_only else ''}
{'AND extractor_key = "Local"' if args.local_media_only else ''}
ORDER BY 1=1
Expand Down Expand Up @@ -429,7 +429,7 @@ def construct_download_query(args, dl_status=False) -> tuple[str, dict]:
{'AND (score IS NULL OR score > 7)' if 'score' in m_columns else ''}
{'AND (upvote_ratio IS NULL OR upvote_ratio > 0.73)' if 'upvote_ratio' in m_columns else ''}
{'AND is_supported(m.path)' if args.safe else ''}
{" ".join(args.filter_sql)}
AND (1=1 {" ".join(args.filter_sql)})
ORDER BY 1=1
{', COALESCE(m.time_modified, 0) = 0 DESC' if 'time_modified' in m_columns else ''}
{', m.error IS NULL DESC' if 'error' in m_columns else ''}
Expand Down

0 comments on commit 9e52432

Please sign in to comment.