Browse Source

Lyric translation: beta version

pull/8/head
Ludy Su 7 years ago
parent
commit
3fadb710da
  1. 34
      netease.php

34
netease.php

@ -168,29 +168,39 @@ class LudysuNetEaseLrc {
$resultLrc = ""; $resultLrc = "";
$orgLines = $this->processLrcLine($orgLrc); $orgLines = $this->processLrcLine($orgLrc);
$transLines = $this->processLrcLine($transLrc); $transLines = $this->processLrcLine($transLrc);
var_dump($orgLines); //var_dump($orgLines);
foreach ($orgLines as $key => $value) { foreach ($orgLines as $elem) {
$key = $elem['tag']; // time tag
$value = $elem['lrc']; // lyric line
$resultLrc .= $key . $value; $resultLrc .= $key . $value;
// Find matching translation // Find matching translation
$trans = ""; $trans = "";
// $lastMatchCursor = 0; if (!$this->isNullOrEmptyString($key)) {
// for ($i = $lastMatchCursor; $i < count($transLines); $i++) { $lastMatchCursor = 0;
// // Check for matching time tag for ($i = $lastMatchCursor; $i < count($transLines); $i++) {
// if ($key === $transLines[0]) { $tKey = $transLines[$i]['tag'];
// $lastMatchCursor = $i; $tValue = $transLines[$i]['lrc'];
// $trans = $transLines[1]; echo $key . " =? " . $tKey . "\n";
// } // Check for matching time tag
// } if ($key === $tKey) {
$lastMatchCursor = $i + 1;
$trans = $tValue;
break;
}
}
}
echo "\n";
if (!$this->isNullOrEmptyString($key) && $this->isNullOrEmptyString($trans)) { // $key is empty when it's not time tag, just metadata if (!$this->isNullOrEmptyString($trans)) { // $key is empty when it's not time tag, just metadata
$resultLrc .= " 【" . $trans . "】\n"; $resultLrc .= " 【" . $trans . "】\n";
} }
$resultLrc .= "\n"; $resultLrc .= "\n";
} }
// var_dump($resultLrc); //var_dump($resultLrc);
} }
return $resultLrc; return $resultLrc;
} }

Loading…
Cancel
Save