Skip to content
This repository was archived by the owner on Jun 14, 2026. It is now read-only.

feat: Add Argument-Embedded Text Queue with Global Defaults Preservation - #1379

Open
wastaken7 wants to merge 2 commits into
masterfrom
feat/embedded-arguments-text-queue
Open

feat: Add Argument-Embedded Text Queue with Global Defaults Preservation#1379
wastaken7 wants to merge 2 commits into
masterfrom
feat/embedded-arguments-text-queue

Conversation

@wastaken7

@wastaken7 wastaken7 commented May 26, 2026

Copy link
Copy Markdown
Collaborator

This Pull Request introduces a feature allowing batch-uploading from various locations using a single .txt queue file, where each line can contain its own independent command-line overrides and arguments.

Key Changes

  • Argument-Embedded .txt Queue Parsing: Passing a .txt file as the main positional input path (without --unit3d) automatically triggers this queue mode.
  • Robust Argument Parsing (shlex): Uses Python's standard shlex library with double-quotes handling to cleanly parse Windows paths containing backslashes and spaces, as well as line-level argument tokens.
  • Global Defaults Inheritance: Designed a robust mechanism where global flags passed in the main command (e.g., -ua, -debug, --anon) are automatically preserved and inherited as baseline defaults for all items.
  • Progress Tracking & Isolation: Progress is tracked and logged in a file named after the .txt file (e.g., my_queue_processed_files.log). Re-running the command skips completed lines, permitting easy resume and text append.
  • Comments and Empty Lines: Supports comment lines starting with # and skips blank lines.
  • Detailed Documentation: Added clear instructions in docs/cli-args.md explaining the format, globality of arguments, and state isolation.

Example Queue File (my_uploads.txt):

# This is a comment
"F:\Movies\Adventure.Movie.2026.1080p-Group" -tk AITHER -imdb tt00000000 --anon
"D:\TV Shows\Special.Show.S01.1080p-Group" -tk CBR -tvdb 00000000 -pr

Summary by CodeRabbit

  • New Features

    • Per-line text-queue support: each non-empty, non-# line can include per-item arguments that override defaults for that upload task.
  • Bug Fixes

    • Queue processing now skips already-processed items and exits cleanly when no new items remain.
    • Processed-path logging is more consistent so resumed queues reflect the actual uploaded items.
  • Documentation

    • CLI docs updated to explain the text-queue format, per-line args, and resume/progress tracking.

Review Change Stack

- Add support for .txt queue files where each line has its own command-line arguments.
- Integrate shell-like parsing using shlex to correctly preserve Windows backslashes and spaces in paths.
- Isolate progress state using log files dedicated to the queue filename.
- Add automatic global defaults preservation logic so that global CLI flags (e.g. -ua, -debug, -anon) are inherited by queue items unless overridden at the line-level.
- Update queue display layout to handle structured QueueItem dicts cleanly.
- Add comprehensive documentation in docs/cli-args.md.
@github-actions

Copy link
Copy Markdown

Thanks for taking the time to contribute to this project. Upload Assistant is currently in a complete rewrite, and no new development is being conducted on this python source at this time.

If you have come this far, please feel free to leave open, any pull requests regarding new sites being added to the source, as these can serve as the baseline for later conversion.

If your pull request relates to a critical bug, this will be addressed in this code base, and a new release published as needed.

If your pull request only addresses a quite minor bug, it is not likely to be addressed in this code base.

Details for the new code base will follow at a later date.

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds support for argument-embedded .txt batch files: when a .txt file is passed without --unit3d, each non-empty non-comment line is parsed as an independent upload task with per-line arguments overriding global defaults. Queue deduplication, progress tracking, and upload processing are implemented, then documented.

Changes

Argument-Embedded Text Queue Support

Layer / File(s) Summary
Text Queue Parsing & Display
src/queuemanage.py
handle_queue reads the per-queue processed-files log, parses each eligible line via shlex into {path, args, line} dicts, filters out already-processed entries (by line and path), saves a queue log containing only the original lines, and optionally displays the queue. display_queue is widened to accept Sequence[Any] and extracts display strings (line or path) for logging instead of serializing the input list directly.
Per-Item Args Processing & Logged Path
upload.py
do_the_thing() detects args_line_queue items, parses the per-item args list into a cloned command-line meta with backfill from base_meta, and sets current_item_path from the queue item's line field. Three save_processed_file() calls are updated to record current_item_path instead of the raw path variable, ensuring consistent tracking of which queue item was processed.
Text Queue Documentation
docs/cli-args.md
Documents how .txt positional input is parsed as a batch queue: line format, comment/empty-line skipping, per-queue resume tracking using filename-derived log files, and per-line argument override behavior relative to global defaults.

Sequence Diagrams

sequenceDiagram
  participant handle_queue
  participant shlex_parse
  participant deduplicate
  participant display_queue
  participant do_the_thing
  participant save_processed_file

  handle_queue->>shlex_parse: parse .txt lines into {path,args,line}
  shlex_parse-->>handle_queue: parsed items
  handle_queue->>deduplicate: filter by line & path
  deduplicate-->>handle_queue: new_items
  handle_queue->>display_queue: normalize items and log display strings
  display_queue-->>handle_queue: logged output
  handle_queue->>do_the_thing: enqueue new_items
  do_the_thing->>save_processed_file: write current_item_path to processed log
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops through queued paths so grand,
Each line a task with args close at hand,
Deduplication keeps the processing clean,
Per-item overrides reign supreme,
Progress tracked through logs like a map,
No upload shall slip through this trap. 🐰📝

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main feature: adding argument-embedded text queue support with global defaults preservation, which is the central change across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/embedded-arguments-text-queue

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/queuemanage.py (1)

750-756: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update wrapper function signature to match static method.

The module-level display_queue wrapper function still uses Sequence[str] (line 751) while the class method QueueManager.display_queue was updated to Sequence[Any] (line 356). This creates a type inconsistency.

🔧 Proposed fix
 async def display_queue(
-    queue: Sequence[str],
+    queue: Sequence[Any],
     base_dir: Optional[str] = None,
     queue_name: Optional[str] = None,
     save_to_log: bool = True,
 ) -> None:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/queuemanage.py` around lines 750 - 756, The module-level wrapper function
display_queue has a type mismatch: its first parameter is declared as
Sequence[str] but it calls QueueManager.display_queue which now expects
Sequence[Any]; update the wrapper signature to use Sequence[Any] for the queue
parameter to match the static method (and add or update the typing import for
Any if not already present) so the types are consistent between the module-level
display_queue and QueueManager.display_queue.
🧹 Nitpick comments (2)
src/queuemanage.py (2)

454-455: ⚡ Quick win

Narrow the exception handler for better debuggability.

The broad except Exception suppresses potentially important errors during line parsing. Consider catching only ValueError (from shlex.split) and logging unexpected exceptions at debug level rather than swallowing them.

♻️ Suggested change
-                    except Exception as e:
-                        console.print(f"[red]Error parsing line in queue file: {line_stripped}. Error: {e}[/red]")
+                    except ValueError as e:
+                        console.print(f"[red]Error parsing line in queue file: {line_stripped}. Error: {e}[/red]")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/queuemanage.py` around lines 454 - 455, The current broad except
Exception around the line-parsing block should be narrowed: catch ValueError
(which shlex.split raises) and keep the user-facing console.print for that case
(referencing line_stripped and the parsing code that calls shlex.split), and add
a separate except Exception handler that logs the unexpected exception at debug
level using console.log (including the exception info) and re-raises it so we
don’t silently swallow unknown errors; replace the single except Exception as e:
console.print(...) with an except ValueError as e: console.print(...) and an
except Exception as e: console.log(...) followed by raise.

435-435: 💤 Low value

Move import shlex to module level.

The shlex import is inside the loop, which is inefficient since the import is re-evaluated on each iteration. Move it to the top of the file with other imports.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/queuemanage.py` at line 435, The import for shlex is currently inside a
loop (the inline "import shlex" at the loop around line 435); move that import
to the module top with the other imports and remove the in-loop import so it is
only imported once; update any functions referencing shlex (e.g., the loop body
where shlex.split is used) to rely on the top-level import and ensure there are
no duplicate imports elsewhere in the module.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/cli-args.md`:
- Line 43: The docs example currently shows a conflicting path; update the
"Queue Progress & Resume" example so the processed-log path exactly matches the
implementation: for the `.txt` source filename (e.g., my_queue.txt) show the
real generated processed-log name and location (my_queue_processed_files.log) as
produced by the code that builds the log path — replace or remove the hard-coded
"tmp/" prefix and ensure the example mirrors the actual behavior for
my_queue.txt and the function that computes the processed-log filename.

In `@upload.py`:
- Around line 1551-1555: The code currently checks any(opt in args_list for opt
in option_strings) which fails to detect equals-style args (e.g.,
"--screens=5"); update the membership check in the loop that builds meta (the
block using base_meta, dest_to_options, args_list, option_strings, meta) to
treat an option as present if any arg in args_list is exactly the option or
startswith option + '=' (e.g., replace the any(...) with something like any(arg
== opt or arg.startswith(opt + '=') for arg in option_strings for arg in
args_list) — implement the equivalent concise check so explicit equals-style
arguments prevent applying the global default.

---

Outside diff comments:
In `@src/queuemanage.py`:
- Around line 750-756: The module-level wrapper function display_queue has a
type mismatch: its first parameter is declared as Sequence[str] but it calls
QueueManager.display_queue which now expects Sequence[Any]; update the wrapper
signature to use Sequence[Any] for the queue parameter to match the static
method (and add or update the typing import for Any if not already present) so
the types are consistent between the module-level display_queue and
QueueManager.display_queue.

---

Nitpick comments:
In `@src/queuemanage.py`:
- Around line 454-455: The current broad except Exception around the
line-parsing block should be narrowed: catch ValueError (which shlex.split
raises) and keep the user-facing console.print for that case (referencing
line_stripped and the parsing code that calls shlex.split), and add a separate
except Exception handler that logs the unexpected exception at debug level using
console.log (including the exception info) and re-raises it so we don’t silently
swallow unknown errors; replace the single except Exception as e:
console.print(...) with an except ValueError as e: console.print(...) and an
except Exception as e: console.log(...) followed by raise.
- Line 435: The import for shlex is currently inside a loop (the inline "import
shlex" at the loop around line 435); move that import to the module top with the
other imports and remove the in-loop import so it is only imported once; update
any functions referencing shlex (e.g., the loop body where shlex.split is used)
to rely on the top-level import and ensure there are no duplicate imports
elsewhere in the module.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f7501a66-ef9f-4e47-8988-c3a342770789

📥 Commits

Reviewing files that changed from the base of the PR and between 3e39d5d and 177e213.

📒 Files selected for processing (3)
  • docs/cli-args.md
  • src/queuemanage.py
  • upload.py

Comment thread docs/cli-args.md
"D:\TV Shows\Fun.TV.Show.2026.1080p.WEB-DL-Group" -tk LST -df "desc_filename.txt" -tvdb 00000000 -pr
```
- **Comments and Empty Lines**: You can add comments starting with `#` or leave empty lines; they are automatically skipped.
- **Queue Progress & Resume**: Progress is isolated and tracked automatically based on the `.txt` filename (e.g., `my_queue.txt` uses `tmp/my_queue_processed_files.log`). If you stop and restart, Upload Assistant will skip already completed lines, allowing you to easily resume or append new items to the file.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify the processed-log file location example.

The filename pattern here conflicts with the PR behavior summary (my_queue_processed_files.log) and may mislead users about path/location. Please align the example with the actual generated location used by the implementation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/cli-args.md` at line 43, The docs example currently shows a conflicting
path; update the "Queue Progress & Resume" example so the processed-log path
exactly matches the implementation: for the `.txt` source filename (e.g.,
my_queue.txt) show the real generated processed-log name and location
(my_queue_processed_files.log) as produced by the code that builds the log path
— replace or remove the hard-coded "tmp/" prefix and ensure the example mirrors
the actual behavior for my_queue.txt and the function that computes the
processed-log filename.

Comment thread upload.py
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant