Skip to content

Commit

Permalink
fix: FileNotFoundError on importing vlc lib #49
Browse files Browse the repository at this point in the history
  • Loading branch information
Simatwa committed May 26, 2024
1 parent 329ab27 commit aad7c02
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/pytgpt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@
from typing import Union
from typing import NoReturn
import requests
import vlc
import httpx
import asyncio
import urllib.parse
from time import sleep as wait

try:
import vlc

is_vlc_imported = True
except Exception as e:
logging.debug(f"Unable to import vlc lib - {e}")
# Ref : #49
is_vlc_imported = False

appdir = appdirs.AppDirs("pytgpt", "Smartwa")

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

def play_using_vlc():
if not is_vlc_imported:
logging.warn("Failed to import vlc lib, check logs (debug)")
return
# create instance
instance = vlc.Instance()
# Create a Media Player object
Expand Down

0 comments on commit aad7c02

Please sign in to comment.