Skip to content

Commit

Permalink
check audio and restrict subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgramComputer committed Jan 10, 2024
1 parent 040ef3b commit 8738bbb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions db/schema/baseline.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CREATE TABLE _migrations (
filename VARCHAR(255) NOT NULL,
PRIMARY KEY (filename)
);

INSERT INTO _migrations VALUES('19700101_000001_lwt_original.sql');
INSERT INTO _migrations VALUES('19700102_000001_lwt_fork.sql');
INSERT INTO _migrations VALUES('20231224_131202_missing_auto_increment.sql');
Expand Down
4 changes: 2 additions & 2 deletions edit_texts.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,13 @@ function edit_texts_do_operation($op, $message1, $no_pagestart): string

//currently youtube dailymotion and vimeo but youtube-dl can support more
$pattern = "/(https?:\/\/).*(youtu|dailymotion|vimeo)/i";
$youtubedl_args = " " .trim($_REQUEST["TxAudioURI"])." -f bestaudio --no-cache-dir --no-continue -o ".'media'.'/%(title)r-%(id)s-'.$id.'-.%(ext)s';
$youtubedl_args = " " .trim($_REQUEST["TxAudioURI"])." —restrict-filenames -f bestaudio --no-cache-dir --no-continue -o ".'media'.'/%(id)s-%(format)s-'.$id.'-.%(ext)s';
$save_to_disk = getSettingWithDefault('set-tts');


if($save_to_disk && preg_match($pattern, trim($_REQUEST["TxAudioURI"])) && ($youtubedl = get_youtubedl_path($youtubedl_args)) != "" )
{
$youtubedl_args = " ". trim($_REQUEST["TxAudioURI"])." -f bestaudio --no-cache-dir --get-filename -o media".'/%(title)r-%(id)s-'.$id.'-.%(ext)s ';
$youtubedl_args = " ". trim($_REQUEST["TxAudioURI"])." —restrict-filenames -f bestaudio --no-cache-dir --get-filename -o media".'/%(id)s-%(format)s-'.$id.'-.%(ext)s ';
$titleandid = get_youtubedl_path($youtubedl_args);

$handle = popen($titleandid.' 2>&1; '.$youtubedl.' 2>&1', "r");
Expand Down
12 changes: 10 additions & 2 deletions inc/database_connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -1616,10 +1616,18 @@ function splitCheckText($text, $lid, $id)

try {
//TRY and see if file has timed text
$subtitles = \Done\Subtitles\Subtitles::loadFromString(get_first_value(
$text = get_first_value(
'SELECT TxText AS value FROM ' . $tbpref . 'texts
WHERE TxID = ' . $id
));
);
$subtitles = \Done\Subtitles\Subtitles::loadFromString($text);
$modified_string = \Done\Subtitles\Code\Helpers::convertToUtf8($text);
$modified_string = \Done\Subtitles\Code\Helpers::removeUtf8Bom($modified_string);
$modified_string = \Done\Subtitles\Code\Helpers::normalizeNewLines($modified_string);
$input_converter = \Done\Subtitles\Code\Helpers::getConverterByFileContent($modified_string);
if(str_contains(get_class($input_converter),"TxtConverter")){
return;
}

$internalFormat = $subtitles->getInternalFormat();
$seids= array();
Expand Down
4 changes: 2 additions & 2 deletions inc/session_utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -3915,8 +3915,8 @@ function makeMediaPlayer($path, $offset=0)
/**
* File extension (if exists)
*/
$extension = substr($path, -4);
if ($extension == '.mp3' || $extension == '.wav' || $extension == '.ogg') {
$extension = substr($path, -4); //extractor could be audio only in container %(format)
if ($extension == '.mp3' || $extension == '.wav' || $extension == '.ogg' || str_contains($path, "audio only")) {
makeAudioPlayer($path, $offset);
} else {
makeVideoPlayer($path, $offset);
Expand Down

0 comments on commit 8738bbb

Please sign in to comment.