aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/yt_dlp_plugins/extractor
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp_plugins/extractor')
-rw-r--r--yt_dlp_plugins/extractor/radiko_dependencies.py29
-rw-r--r--yt_dlp_plugins/extractor/radiko_podcast.py7
-rwxr-xr-xyt_dlp_plugins/extractor/radiko_protobufs.py7
3 files changed, 34 insertions, 9 deletions
diff --git a/yt_dlp_plugins/extractor/radiko_dependencies.py b/yt_dlp_plugins/extractor/radiko_dependencies.py
new file mode 100644
index 0000000..769a5e3
--- /dev/null
+++ b/yt_dlp_plugins/extractor/radiko_dependencies.py
@@ -0,0 +1,29 @@
+# Bundle importing code Copyright (c) 2021-2022 Grub4K, from yt-dont-lock-p.
+# https://github.com/Grub4K/yt-dont-lock-p/blob/ff3b6e1d42ce8584153ae27544d2c05b50ab5954/yt_dlp_plugins/postprocessor/yt_dont_lock_p/__init__.py#L23-L46
+# Used under 0BSD with permission
+
+# https://discord.com/channels/807245652072857610/1112613156934668338/1416816007732920430 (yt-dlp discord server, https://discord.gg/H5MNcFW63r )
+# [17:00] garret1317: @Grub4K can i pinch your MIT-licensed dependency bundling code to use in my 0BSD-licensed plugin?
+# I will credit of course but i can't require that anyone else does the same
+# (Any response to this message will be considered a written consent or refusal of the request)
+# [17:04] Grub4K: Feel free to use that part under 0BSD
+# [17:05] garret1317: 👍 cheers
+
+try:
+ import protobug
+except ImportError:
+ import sys
+ from pathlib import Path
+
+ # Try importing from zip file bundle
+ search_path = str(Path(__file__).parent.parent)
+ sys.path.append(search_path)
+ try:
+ import protobug
+ except ImportError:
+ protobug = None
+ except Exception:
+ protobug = None
+
+ finally:
+ sys.path.remove(search_path)
diff --git a/yt_dlp_plugins/extractor/radiko_podcast.py b/yt_dlp_plugins/extractor/radiko_podcast.py
index 84bc288..a984be3 100644
--- a/yt_dlp_plugins/extractor/radiko_podcast.py
+++ b/yt_dlp_plugins/extractor/radiko_podcast.py
@@ -7,11 +7,10 @@ from yt_dlp.utils import (
)
import dataclasses
-try:
- import protobug
+
+from yt_dlp_plugins.extractor.radiko_dependencies import protobug
+if protobug:
import yt_dlp_plugins.extractor.radiko_protobufs as pb
-except ImportError:
- protobug = None
class _RadikoPodcastBaseIE(InfoExtractor):
diff --git a/yt_dlp_plugins/extractor/radiko_protobufs.py b/yt_dlp_plugins/extractor/radiko_protobufs.py
index 4eb4f8b..a8bbec1 100755
--- a/yt_dlp_plugins/extractor/radiko_protobufs.py
+++ b/yt_dlp_plugins/extractor/radiko_protobufs.py
@@ -1,12 +1,9 @@
#!/usr/bin/env python3
-try:
- import protobug
-except ImportError:
- protobug = None
-
import struct
import random
+from yt_dlp_plugins.extractor.radiko_dependencies import protobug
+
if protobug: # i suppose it works lmao