Audit: Improve robustness, metadata detection, and CLI options#1
Audit: Improve robustness, metadata detection, and CLI options#1taskinen wants to merge 4 commits into
Conversation
This commit introduces several enhancements to the yle-dl-plex utility: - Fixed a critical syntax error in cli.py related to exception handling. - Improved HTTP robustness by adding retries and streaming downloads. - Refined season detection by properly parsing JSON-LD metadata. - Added a --prefer-format CLI option to allow user control over video containers. - Added integration tests to verify the main CLI orchestration. - Addressed code review feedback and ensured strict type check compliance. Co-authored-by: taskinen <1721037+taskinen@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- Fixed linting errors in tests/test_integration.py (unused imports, long lines, import sorting). - Applied formatting across the codebase using ruff. - Ensured all checks (ruff, mypy, pytest) pass. Co-authored-by: taskinen <1721037+taskinen@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves the CLI workflow reliability and configurability for yle-dl-plex, including more robust HTTP downloading, better season-structure detection from JSON-LD, and support for selecting the preferred download container format.
Changes:
- Added streaming downloads + retry-capable
httpxtransport for network operations. - Refined season detection by parsing JSON-LD and recursively searching for season-indicator keys.
- Added
--prefer-formatCLI option and threaded it through theyledlwrapper; added integration tests for the 5-stage orchestration.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/yle_dl_plex/cli.py |
Adds HTTP retries + streaming download, improves JSON-LD season detection, and introduces --prefer-format wiring into orchestration. |
src/yle_dl_plex/yledl.py |
Extends the in-process yle-dl wrapper to accept and apply a preferred container format. |
tests/test_integration.py |
Adds end-to-end orchestration tests with mocked yledl + HTTP calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| parser.add_argument( | ||
| "--prefer-format", | ||
| default="mkv", | ||
| help="Preferred video format (default: mkv). Passed to yle-dl.", | ||
| ) |
| import pytest | ||
| import respx | ||
| from httpx import Response | ||
|
|
| "@type": "TVSeries", | ||
| "name": "Show", | ||
| "description": "Series description", | ||
| "image": ["https://example.com/poster.jpg", "https://example.com/background.jpg"] |
The code was using `except ValueError, IndexError:`, which is Python 2 syntax for assigning an exception to a name, or a syntax error depending on the version. This commit corrects it to the Python 3 tuple syntax: `except (ValueError, IndexError):`. Co-authored-by: taskinen <1721037+taskinen@users.noreply.github.com>
The code was using `except ValueError, IndexError:`, which is Python 2 syntax for assigning an exception to a name, or a syntax error depending on the version. This commit corrects it to the Python 3 tuple syntax: `except (ValueError, IndexError):`. Co-authored-by: taskinen <1721037+taskinen@users.noreply.github.com>
I have completed the audit and improvement of the
yle-dl-plexrepository. My changes focused on fixing a critical bug, improving the robustness of network operations, refining metadata extraction, and enhancing user configurability.Key improvements include:
cli.pythat would cause a crash when catching multiple exceptions.fetch_to_fileto use streaming downloads viaclient.stream(), reducing memory usage. Added a retry mechanism (3 retries) usinghttpx.HTTPTransportfor all network requests.--prefer-formatCLI option, allowing users to specify the preferred video container (e.g.,mkv,mp4) passed through toyle-dl.tests/test_integration.pyto cover the full 5-stage orchestration logic with mockedyle-dland HTTP calls, ensuring the core workflow is verified.pytest) and static analysis (mypy) pass.All changes have been verified against the project's target environment (Python 3.14+).
PR created automatically by Jules for task 17322613723043131904 started by @taskinen