feat: Add Argument-Embedded Text Queue with Global Defaults Preservation - #1379
feat: Add Argument-Embedded Text Queue with Global Defaults Preservation#1379wastaken7 wants to merge 2 commits into
Conversation
- 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.
|
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. |
📝 WalkthroughWalkthroughThis PR adds support for argument-embedded ChangesArgument-Embedded Text Queue Support
Sequence DiagramssequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winUpdate wrapper function signature to match static method.
The module-level
display_queuewrapper function still usesSequence[str](line 751) while the class methodQueueManager.display_queuewas updated toSequence[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 winNarrow the exception handler for better debuggability.
The broad
except Exceptionsuppresses potentially important errors during line parsing. Consider catching onlyValueError(fromshlex.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 valueMove
import shlexto module level.The
shleximport 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
📒 Files selected for processing (3)
docs/cli-args.mdsrc/queuemanage.pyupload.py
| "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. |
There was a problem hiding this comment.
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.
This Pull Request introduces a feature allowing batch-uploading from various locations using a single
.txtqueue file, where each line can contain its own independent command-line overrides and arguments.Key Changes
.txtQueue Parsing: Passing a.txtfile as the main positional input path (without--unit3d) automatically triggers this queue mode.shlex): Uses Python's standardshlexlibrary with double-quotes handling to cleanly parse Windows paths containing backslashes and spaces, as well as line-level argument tokens.-ua,-debug,--anon) are automatically preserved and inherited as baseline defaults for all items..txtfile (e.g.,my_queue_processed_files.log). Re-running the command skips completed lines, permitting easy resume and text append.#and skips blank lines.docs/cli-args.mdexplaining the format, globality of arguments, and state isolation.Example Queue File (
my_uploads.txt):Summary by CodeRabbit
New Features
Bug Fixes
Documentation