mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2025-10-23 15:11:08 +00:00
Merge commit 'refs/pull/19/head' of https://github.com/unshackle-dl/unshackle into dev
This commit is contained in:
@@ -3,27 +3,30 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from mypy.types import names
|
||||||
|
|
||||||
__shaka_platform = {"win32": "win", "darwin": "osx"}.get(sys.platform, sys.platform)
|
__shaka_platform = {"win32": "win", "darwin": "osx"}.get(sys.platform, sys.platform)
|
||||||
|
|
||||||
|
|
||||||
def find(*names: str) -> Optional[Path]:
|
def find(*names: str) -> Optional[Path]:
|
||||||
"""Find the path of the first found binary name."""
|
"""Find the path of the first found binary name."""
|
||||||
# Get the directory containing this file to find the local binaries folder
|
current_dir = Path(__file__).resolve().parent.parent
|
||||||
current_dir = Path(__file__).parent.parent
|
|
||||||
local_binaries_dir = current_dir / "binaries"
|
local_binaries_dir = current_dir / "binaries"
|
||||||
|
|
||||||
for name in names:
|
ext = ".exe" if sys.platform == "win32" else ""
|
||||||
# First check local binaries folder
|
|
||||||
if local_binaries_dir.exists():
|
|
||||||
local_path = local_binaries_dir / name
|
|
||||||
if local_path.is_file() and local_path.stat().st_mode & 0o111: # Check if executable
|
|
||||||
return local_path
|
|
||||||
|
|
||||||
# Also check with .exe extension on Windows
|
for name in names:
|
||||||
if sys.platform == "win32":
|
if local_binaries_dir.exists():
|
||||||
local_path_exe = local_binaries_dir / f"{name}.exe"
|
candidate_paths = [
|
||||||
if local_path_exe.is_file():
|
local_binaries_dir / f"{name}{ext}",
|
||||||
return local_path_exe
|
local_binaries_dir / name / f"{name}{ext}"
|
||||||
|
]
|
||||||
|
|
||||||
|
for path in candidate_paths:
|
||||||
|
if path.is_file():
|
||||||
|
# On Unix-like systems, check if file is executable
|
||||||
|
if sys.platform == "win32" or (path.stat().st_mode & 0o111):
|
||||||
|
return path
|
||||||
|
|
||||||
# Fall back to system PATH
|
# Fall back to system PATH
|
||||||
path = shutil.which(name)
|
path = shutil.which(name)
|
||||||
|
|||||||
@@ -439,7 +439,7 @@ class HLS:
|
|||||||
elif len(files) != range_len:
|
elif len(files) != range_len:
|
||||||
raise ValueError(f"Missing {range_len - len(files)} segment files for {segment_range}...")
|
raise ValueError(f"Missing {range_len - len(files)} segment files for {segment_range}...")
|
||||||
|
|
||||||
if isinstance(drm, Widevine):
|
if isinstance(drm, (Widevine, PlayReady)):
|
||||||
# with widevine we can merge all segments and decrypt once
|
# with widevine we can merge all segments and decrypt once
|
||||||
merge(to=merged_path, via=files, delete=True, include_map_data=True)
|
merge(to=merged_path, via=files, delete=True, include_map_data=True)
|
||||||
drm.decrypt(merged_path)
|
drm.decrypt(merged_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user