Skip to content

Audit: Improve robustness, metadata detection, and CLI options#1

Closed
taskinen wants to merge 4 commits into
mainfrom
improve-robustness-and-metadata-17322613723043131904
Closed

Audit: Improve robustness, metadata detection, and CLI options#1
taskinen wants to merge 4 commits into
mainfrom
improve-robustness-and-metadata-17322613723043131904

Conversation

@taskinen

Copy link
Copy Markdown
Owner

I have completed the audit and improvement of the yle-dl-plex repository. My changes focused on fixing a critical bug, improving the robustness of network operations, refining metadata extraction, and enhancing user configurability.

Key improvements include:

  1. Syntax Fix: Corrected a Python 3 syntax error in cli.py that would cause a crash when catching multiple exceptions.
  2. HTTP Robustness: Refactored fetch_to_file to use streaming downloads via client.stream(), reducing memory usage. Added a retry mechanism (3 retries) using httpx.HTTPTransport for all network requests.
  3. Refined Metadata Extraction: Updated the season detection logic to properly parse JSON-LD scripts and recursively search for season indicators, replacing a more fragile substring-based check.
  4. User Configurability: Introduced the --prefer-format CLI option, allowing users to specify the preferred video container (e.g., mkv, mp4) passed through to yle-dl.
  5. New Integration Tests: Added tests/test_integration.py to cover the full 5-stage orchestration logic with mocked yle-dl and HTTP calls, ensuring the core workflow is verified.
  6. Code Quality: Addressed minor feedback from a mock senior review, including adding missing type imports and ensuring all tests (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

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>
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown

pytest

112 tests  ±0   112 ✅ ±0   0s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 46324c8. ± Comparison against base commit 624dc5a.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

- 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>

Copilot AI 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.

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 httpx transport for network operations.
  • Refined season detection by parsing JSON-LD and recursively searching for season-indicator keys.
  • Added --prefer-format CLI option and threaded it through the yledl wrapper; 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.

Comment thread src/yle_dl_plex/cli.py Outdated
Comment on lines +387 to +391
parser.add_argument(
"--prefer-format",
default="mkv",
help="Preferred video format (default: mkv). Passed to yle-dl.",
)
Comment thread tests/test_integration.py Outdated
Comment on lines +5 to +8
import pytest
import respx
from httpx import Response

Comment thread tests/test_integration.py Outdated
"@type": "TVSeries",
"name": "Show",
"description": "Series description",
"image": ["https://example.com/poster.jpg", "https://example.com/background.jpg"]
google-labs-jules Bot and others added 2 commits May 27, 2026 10:23
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>
@taskinen taskinen closed this May 27, 2026
@taskinen taskinen deleted the improve-robustness-and-metadata-17322613723043131904 branch May 27, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants