Skip to content

Commit e97bb99

Browse files
add error message
1 parent cfa450b commit e97bb99

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎api.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function get_phonetic_reading($get_req): array
171171
function get_subtitles($get_req): array
172172
{
173173
$data = subtitles_from_uri($get_req['uri'], $get_req['lang_id']);
174-
return array("subtitles" => $data);
174+
return $data;
175175
}
176176

177177

‎inc/session_utility.php‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4879,7 +4879,8 @@ function phonetic_reading($text, $lang)
48794879
* @return string Subtitles text in any format
48804880
* @global bool $debug Show a DEBUG span if true
48814881
* */
4882-
function subtitles_from_uri($uri,$lang_id){
4882+
function subtitles_from_uri($uri,$lang_id):array
4883+
{
48834884

48844885
$abbr = getLanguageCode($lang_id, LWT_LANGUAGES_ARRAY);
48854886

@@ -4900,13 +4901,18 @@ function subtitles_from_uri($uri,$lang_id){
49004901
$filename = trim(substr($line,$pos));
49014902

49024903
}
4904+
4905+
if (($pos = strpos(mb_strtolower($line), 'err')) !== false) {
4906+
$err = trim(substr($line,$pos));
4907+
4908+
}
49034909

49044910
}
49054911
$fileContent = file_get_contents($filename);
49064912

49074913
unlink($filename);
49084914
pclose($handle);
4909-
return $fileContent?$fileContent : "";
4915+
return array("subtitles" => $fileContent?$fileContent : "","error" => $err);
49104916
}
49114917
}
49124918

‎js/pgm.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/js/jq_pgm.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,13 @@ function subtitles_receive_data(data) {
13231323
$('#subtitlesLoadingImg').css("display", "none");
13241324

13251325
$('#TxText').val(data["subtitles"]);
1326+
if (data["error"] !== undefined) {
1327+
1328+
msg = data["error"];
1329+
1330+
$('#subtitlesErrorMessage').text(msg);
1331+
$('#subtitlesErrorMessage').css("display", "inherit");
1332+
}
13261333

13271334
}
13281335
/**

0 commit comments

Comments
 (0)