mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-08-23 17:27:25 +00:00
Merge pull request #2821 from lbryio/ffmpeg-find
add `ffmpeg_find` api to check ffmpeg installation status, don't recheck for ffmpeg in `status`
This commit is contained in:
commit
e0623578bf
2 changed files with 32 additions and 9 deletions
|
@ -358,7 +358,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_api_definitions(cls):
|
def get_api_definitions(cls):
|
||||||
prefix = 'jsonrpc_'
|
prefix = 'jsonrpc_'
|
||||||
not_grouped = ['routing_table_get']
|
not_grouped = ['routing_table_get', 'ffmpeg_find']
|
||||||
api = {
|
api = {
|
||||||
'groups': {
|
'groups': {
|
||||||
group_name[:-len('_DOC')].lower(): getattr(cls, group_name).strip()
|
group_name[:-len('_DOC')].lower(): getattr(cls, group_name).strip()
|
||||||
|
@ -765,6 +765,26 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
asyncio.get_event_loop().call_later(0, shutdown)
|
asyncio.get_event_loop().call_later(0, shutdown)
|
||||||
return "Shutting down"
|
return "Shutting down"
|
||||||
|
|
||||||
|
async def jsonrpc_ffmpeg_find(self):
|
||||||
|
"""
|
||||||
|
Get ffmpeg installation information
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
ffmpeg_find
|
||||||
|
|
||||||
|
Options:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
(dict) Dictionary of ffmpeg information
|
||||||
|
{
|
||||||
|
'available': (bool) found ffmpeg,
|
||||||
|
'which': (str) path to ffmpeg,
|
||||||
|
'analyze_audio_volume': (bool) should ffmpeg analyze audio
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
return await self._video_file_analyzer.status(recheck=True)
|
||||||
|
|
||||||
async def jsonrpc_status(self):
|
async def jsonrpc_status(self):
|
||||||
"""
|
"""
|
||||||
Get daemon status
|
Get daemon status
|
||||||
|
|
|
@ -19,6 +19,7 @@ class VideoFileAnalyzer:
|
||||||
self._available_encoders = ""
|
self._available_encoders = ""
|
||||||
self._ffmpeg_installed = False
|
self._ffmpeg_installed = False
|
||||||
self._which = None
|
self._which = None
|
||||||
|
self._checked_ffmpeg = False
|
||||||
|
|
||||||
async def _execute(self, command, arguments):
|
async def _execute(self, command, arguments):
|
||||||
args = shlex.split(arguments)
|
args = shlex.split(arguments)
|
||||||
|
@ -48,18 +49,20 @@ class VideoFileAnalyzer:
|
||||||
self._ffmpeg_installed = True
|
self._ffmpeg_installed = True
|
||||||
log.debug("Using %s at %s", version.splitlines()[0].split(" Copyright")[0], self._which)
|
log.debug("Using %s at %s", version.splitlines()[0].split(" Copyright")[0], self._which)
|
||||||
|
|
||||||
async def status(self, reset=False):
|
async def status(self, reset=False, recheck=False):
|
||||||
if reset:
|
if reset:
|
||||||
self._available_encoders = ""
|
self._available_encoders = ""
|
||||||
self._ffmpeg_installed = False
|
self._ffmpeg_installed = False
|
||||||
self._which = None
|
self._which = None
|
||||||
|
if self._checked_ffmpeg and not recheck:
|
||||||
|
installed = self._ffmpeg_installed
|
||||||
|
else:
|
||||||
installed = True
|
installed = True
|
||||||
try:
|
try:
|
||||||
await self._verify_ffmpeg_installed()
|
await self._verify_ffmpeg_installed()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
installed = False
|
installed = False
|
||||||
|
self._checked_ffmpeg = True
|
||||||
return {
|
return {
|
||||||
"available": installed,
|
"available": installed,
|
||||||
"which": self._which,
|
"which": self._which,
|
||||||
|
|
Loading…
Add table
Reference in a new issue