Skip to content

Commit aad7c02

Browse files
committed
fix: FileNotFoundError on importing vlc lib #49
1 parent 329ab27 commit aad7c02

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/pytgpt/utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,20 @@
1414
from typing import Union
1515
from typing import NoReturn
1616
import requests
17-
import vlc
1817
import httpx
1918
import asyncio
2019
import urllib.parse
2120
from time import sleep as wait
2221

22+
try:
23+
import vlc
24+
25+
is_vlc_imported = True
26+
except Exception as e:
27+
logging.debug(f"Unable to import vlc lib - {e}")
28+
# Ref : #49
29+
is_vlc_imported = False
30+
2331
appdir = appdirs.AppDirs("pytgpt", "Smartwa")
2432

2533
default_path = appdir.user_cache_dir
@@ -1033,6 +1041,9 @@ def play(path_to_audio_file: Union[Path, str]) -> NoReturn:
10331041
raise FileNotFoundError(f"File does not exist - '{path_to_audio_file}'")
10341042

10351043
def play_using_vlc():
1044+
if not is_vlc_imported:
1045+
logging.warn("Failed to import vlc lib, check logs (debug)")
1046+
return
10361047
# create instance
10371048
instance = vlc.Instance()
10381049
# Create a Media Player object

0 commit comments

Comments
 (0)