-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6e23be
commit 01ed381
Showing
5 changed files
with
618 additions
and
470 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pytubefix | ||
|
||
|
||
def monkey_patch_red_downloader(): | ||
import sys | ||
from importlib import abc as importlib_abc | ||
from importlib import machinery as importlib_machinery | ||
|
||
class ReplaceLoader(importlib_abc.Loader): | ||
def load_module(self, name): | ||
sys.modules[name] = pytubefix | ||
return pytubefix | ||
|
||
class ReplaceFinder(importlib_abc.MetaPathFinder): | ||
def find_spec(self, fullname, path, target=None): | ||
if fullname == 'pytube': | ||
return importlib_machinery.ModuleSpec(fullname, ReplaceLoader()) | ||
return None | ||
|
||
# Insert the custom finder into sys.meta_path | ||
sys.meta_path.insert(0, ReplaceFinder()) | ||
|
||
|
||
monkey_patch_red_downloader() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.