Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Workaround erroneous urllib Windows proxy parsing #7092

Merged
merged 3 commits into from May 27, 2023

Conversation

coletdjnz
Copy link
Member

@coletdjnz coletdjnz commented May 21, 2023

Authored by: coletdjnz

IMPORTANT: PRs without the template will be CLOSED

Description of your pull request and other information

ADD DESCRIPTION HERE

Backport from Network Rework.

Workaround for python/cpython#86793 for older Python versions.

See #4136 for explanation.

Note: this issue doesn't impact the current yt-dlp as https proxies are treated as http, but for when we add support for https proxies in the future this will be needed.
(In saying that we may want to add a warning if a user does pass a https proxy in the current state)

Template

Before submitting a pull request make sure you have:

In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

Copilot Summary

🤖 Generated by Copilot at fe6249d

Summary

📦🛠️🔄

Patch urllib.request.getproxies to fix proxy detection on Windows. Create a new compat.urllib package that re-exports and patches the standard urllib module.

To fix proxy issues on Windows
We patch urllib with some hints
We use compat to re-export
The standard modules with some support
And update YoutubeDL with our prints

Walkthrough

  • Create and use a custom version of getproxies to fix proxy detection issues on Windows (link, link, link)
    • Add a new module compat/urllib/request.py that re-exports and patches urllib.request.getproxies (link)
    • Import getproxies from compat/urllib/request.py instead of urllib.request in YoutubeDL.py (link)
    • Replace the call to urllib.request.getproxies with the local getproxies in YoutubeDL.py (link)
  • Create a proxy module for urllib in compat/urllib/__init__.py to allow importing urllib from compat without breaking existing code (link)
    • Use a helper function passthrough_module to re-export all the symbols from urllib and make the local module act as a proxy for the standard module (link)

yt_dlp/compat/urllib/__init__.py Show resolved Hide resolved
yt_dlp/compat/urllib/request.py Show resolved Hide resolved
yt_dlp/compat/urllib/request.py Outdated Show resolved Hide resolved
@pukkandan pukkandan force-pushed the master branch 2 times, most recently from ee280c7 to 7aeda6c Compare May 24, 2023 18:09
@coletdjnz coletdjnz merged commit 3f66b6f into yt-dlp:master May 27, 2023
11 checks passed
@coletdjnz coletdjnz deleted the nw-backport/proxy-compat branch May 27, 2023 07:17
aalsuwaidi pushed a commit to aalsuwaidi/yt-dlp that referenced this pull request Apr 21, 2024
Convert proxies extracted from windows registry to http for older Python versions.
See: python/cpython#86793

Authored by: coletdjnz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants