From 9a8afadd172b7cab143f0049959fa64973589d94 Mon Sep 17 00:00:00 2001 From: Jade Laurence Empleo <140808788+syntaxsurge@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:07:37 +0800 Subject: [PATCH] [plugins] Handle `PermissionError` (#9229) Authored by: syntaxsurge, pukkandan --- yt_dlp/plugins.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/yt_dlp/plugins.py b/yt_dlp/plugins.py index 6422c7a51..3cc879fd7 100644 --- a/yt_dlp/plugins.py +++ b/yt_dlp/plugins.py @@ -86,11 +86,14 @@ class PluginFinder(importlib.abc.MetaPathFinder): parts = Path(*fullname.split('.')) for path in orderedSet(candidate_locations, lazy=True): candidate = path / parts - if candidate.is_dir(): - yield candidate - elif path.suffix in ('.zip', '.egg', '.whl') and path.is_file(): - if parts in dirs_in_zip(path): + try: + if candidate.is_dir(): yield candidate + elif path.suffix in ('.zip', '.egg', '.whl') and path.is_file(): + if parts in dirs_in_zip(path): + yield candidate + except PermissionError as e: + write_string(f'Permission error while accessing modules in "{e.filename}"\n') def find_spec(self, fullname, path=None, target=None): if fullname not in self.packages: