Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

fix: import youtube_dl from YoutubeDLWrapper #20

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ addon:
import:
- addon: "xbmc.python"
version: "3.0.1"
- addon: "script.module.kodi-six" # this is a dependency of youtube-dl, but we need to put it here for CI tests
- addon: "script.module.requests"
- addon: "script.module.youtube.dl"
30 changes: 22 additions & 8 deletions scripts/bootstrap_kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,34 @@ def get_modules():


def bootstrap_modules():
lib_dirs = (
'lib',
'libs',
)

required_modules = get_modules()

# check if the required modules are installed, only for unit testing
for m in required_modules:
module_found = False
for p in sys.path:
if p.endswith(os.path.join(m, 'lib')):
module_found = True
break
if not module_found:
dev_path = os.path.join(root_dir, 'third-party', 'repo-scripts', m, 'lib')
if os.path.isdir(dev_path):
print(f"Adding dev path: {dev_path}")
sys.path.insert(0, dev_path)
if not module_found:
for lib_dir in lib_dirs:
if p.endswith(os.path.join(m, lib_dir)):
module_found = True
break # break out of lib_dirs loop
else:
break # module already found, break out of sys.path loop
if not module_found:

for lib_dir in lib_dirs:
dev_path = os.path.join(root_dir, 'third-party', 'repo-scripts', m, lib_dir)
if os.path.isdir(dev_path):
print(f"Adding dev path: {dev_path}")
sys.path.insert(0, dev_path)
module_found = True
break

if not module_found:
print(f"Module not found: {m}")
raise ModuleNotFoundError(f"Module not found: {m}")
5 changes: 4 additions & 1 deletion src/themerr/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from typing import Optional

# lib imports
import youtube_dl
try:
from YoutubeDLWrapper import youtube_dl # importing from wrapper applies kodi patches
except TypeError:
import youtube_dl # patches fail when building docs

# local imports
from . import logger
Expand Down