add subdef_source in config

This commit is contained in:
aynsix
2020-07-06 18:23:42 +03:00
parent 22302982a4
commit 8f3f3845c0
3 changed files with 26 additions and 8 deletions

View File

@@ -457,7 +457,12 @@ class ToolsController extends Controller
);
$permalinkUrl = '';
if ($record->has_preview() && ($previewLink = $record->get_preview()->get_permalink()) != null) {
$conf = $this->getConf();
// if subdef_source not set, by default use the preview permalink
$subdefSource = $conf->get(['externalservice', 'ginger', 'AutoSubtitling', 'subdef_source']) ?: 'preview';
if ($this->isPhysicallyPresent($record, $subdefSource) && ($previewLink = $record->get_subdef($subdefSource)->get_permalink()) != null) {
$permalinkUrl = $previewLink->get_url()->__toString();
}
@@ -524,4 +529,15 @@ class ToolsController extends Controller
'videoTextTrackFields' => $videoTextTrackFields
]);
}
private function isPhysicallyPresent(\record_adapter $record, $subdefName)
{
try {
return $record->get_subdef($subdefName)->is_physically_present();
} catch (\Exception $e) {
unset($e);
}
return false;
}
}