Skip to content

Commit

Permalink
Update YouTuber.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakseis committed Nov 23, 2024
1 parent 4a23e05 commit ca922cc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Player/YouTuber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,17 @@ const char YOUTUBE_TRANSCRIPT_API_URL[] = "https://github.com/jdepoix/youtube-tr
const char SCRIPT_TEMPLATE[] = R"(import sys, socket
sys.stderr = LoggerStream()
def install_and_import(package):
def install_and_import(package, url=None):
import importlib
if url is None:
url = package
try:
importlib.import_module(package)
except ImportError:
import subprocess
subprocess.call(["pip3", "install", package])
import os
library_dir = os.path.dirname(os.path.abspath(socket.__file__))
subprocess.run([library_dir + "/../scripts/pip3", "install", url])
finally:
globals()[package] = importlib.import_module(package)
Expand Down

0 comments on commit ca922cc

Please sign in to comment.