Skip to content

Commit

Permalink
warn user on startup if ffmpeg is not available
Browse files Browse the repository at this point in the history
Closes #41
  • Loading branch information
hizkifw committed May 22, 2023
1 parent 30a2d68 commit b631dba
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ build/
*.egg-info
.install-cache/
.vim/
venv/
.venv/
12 changes: 12 additions & 0 deletions fc2_live_dl/FC2LiveDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ async def __aexit__(self, *err):
self._session = None

async def download(self, channel_id):
# Check ffmpeg
if not await FFMpeg.is_available():
if self.params["remux"]:
self._logger.error(
"ffmpeg not found in PATH, remuxing is not available"
)
self._logger.error(
"please install ffmpeg or disable remuxing with --no-remux"
)
raise FileNotFoundError(FFMpeg.FFMPEG_BIN)

# Initialize
self._logger = Logger("fc2 " + channel_id)
tasks = []
fname_stream = None
Expand Down
18 changes: 18 additions & 0 deletions fc2_live_dl/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ def __init__(self, flags):
self._ffmpeg = None
self._flags = flags

@classmethod
async def is_available(cls):
"""
Check if ffmpeg binary exists and is executable.
"""

try:
proc = await asyncio.create_subprocess_exec(
cls.FFMPEG_BIN,
"-version",
stdout=asyncio.subprocess.DEVNULL,
stderr=asyncio.subprocess.DEVNULL,
)
ret = await proc.wait()
return ret == 0
except FileNotFoundError:
return False

async def __aenter__(self):
self._loop = asyncio.get_running_loop()
self._ffmpeg = await asyncio.create_subprocess_exec(
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = fc2-live-dl
version = 2.1.2
version = 2.1.3
author = Hizkia Felix
author_email = [email protected]
description = Download live streams from FC2
Expand Down

0 comments on commit b631dba

Please sign in to comment.