Commit 53ee1aa5 authored by Andreas Heimann's avatar Andreas Heimann

rewrite trackInfo and clipInfo extraction to not have hardcoded indexes

parent 1ae0ff2e
...@@ -55,8 +55,17 @@ class UploadController extends AbstractController ...@@ -55,8 +55,17 @@ class UploadController extends AbstractController
// get backup data // get backup data
$srtbFiles = glob($extractionPath.DIRECTORY_SEPARATOR."*.srtb"); $srtbFiles = glob($extractionPath.DIRECTORY_SEPARATOR."*.srtb");
$srtbContent = json_decode(file_get_contents($srtbFiles[0])); $srtbContent = json_decode(file_get_contents($srtbFiles[0]));
$trackInfo = json_decode($srtbContent->largeStringValuesContainer->values[0]->val);
$clipInfo = json_decode($srtbContent->largeStringValuesContainer->values[2]->val); foreach($srtbContent->largeStringValuesContainer->values as $valueItem) {
switch($valueItem->key) {
case "SO_TrackInfo_TrackInfo":
$trackInfo = json_decode($valueItem->val);
break;
case "SO_ClipInfo_ClipInfo_0":
$clipInfo = json_decode($valueItem->val);
break;
}
}
// set meta data // set meta data
$song->setTitle($trackInfo->title); $song->setTitle($trackInfo->title);
...@@ -101,9 +110,19 @@ class UploadController extends AbstractController ...@@ -101,9 +110,19 @@ class UploadController extends AbstractController
$hf->delTree($extractionPath); $hf->delTree($extractionPath);
} }
// final write // write new track/clip info
$srtbContent->largeStringValuesContainer->values[0]->val = json_encode($trackInfo); foreach($srtbContent->largeStringValuesContainer->values as $valueItem) {
$srtbContent->largeStringValuesContainer->values[2]->val = json_encode($clipInfo); switch($valueItem->key) {
case "SO_TrackInfo_TrackInfo":
$valueItem->val = json_encode($trackInfo);
break;
case "SO_ClipInfo_ClipInfo_0":
$valueItem->val = json_encode($clipInfo);
break;
}
}
// write srtb file
$srtbFileLocation = $this->getParameter('srtb_path').DIRECTORY_SEPARATOR.$song->getFileReference().".srtb"; $srtbFileLocation = $this->getParameter('srtb_path').DIRECTORY_SEPARATOR.$song->getFileReference().".srtb";
file_put_contents($srtbFileLocation, json_encode( $srtbContent )); file_put_contents($srtbFileLocation, json_encode( $srtbContent ));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment