Fix for #2186 - funky characters in file names cause import script to crash.
This commit is contained in:
parent
08f7983bab
commit
e5ea53f8ac
1 changed files with 12 additions and 5 deletions
|
@ -54,11 +54,14 @@ function camp_add_metadata(&$p_mdata, $p_key, $p_val, $p_inputEncoding='iso-8859
|
||||||
if (!is_null($p_val)) {
|
if (!is_null($p_val)) {
|
||||||
$data = $p_val;
|
$data = $p_val;
|
||||||
$outputEncoding = 'UTF-8';
|
$outputEncoding = 'UTF-8';
|
||||||
if (function_exists('iconv') && ($p_inputEncoding != $outputEncoding) ) {
|
//if (function_exists('iconv') && ($p_inputEncoding != $outputEncoding) ) {
|
||||||
$data = @iconv($p_inputEncoding, $outputEncoding, $data);
|
if (function_exists('iconv') && is_string($p_val)) {
|
||||||
if ($data === FALSE) {
|
$newData = @iconv($p_inputEncoding, $outputEncoding, $data);
|
||||||
|
if ($newData === FALSE) {
|
||||||
echo "Warning: convert $key data to unicode failed\n";
|
echo "Warning: convert $key data to unicode failed\n";
|
||||||
$data = $p_val; // fallback
|
} elseif ($newData != $data) {
|
||||||
|
echo "Converted string: '$data' (".gettype($data).") -> '$newData' (".gettype($newData).").\n";
|
||||||
|
$data = $newData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$p_mdata[$p_key] = trim($data);
|
$p_mdata[$p_key] = trim($data);
|
||||||
|
@ -214,7 +217,8 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
|
||||||
foreach ($flds as $key => $getid3keys) {
|
foreach ($flds as $key => $getid3keys) {
|
||||||
foreach ($getid3keys as $getid3key) {
|
foreach ($getid3keys as $getid3key) {
|
||||||
$path = $getid3key["path"];
|
$path = $getid3key["path"];
|
||||||
$ignoreEnc = isset($getid3key["ignoreEnc"])?$getid3key["ignoreEnc"]:FALSE;
|
$ignoreEnc = isset($getid3key["ignoreEnc"])?
|
||||||
|
$getid3key["ignoreEnc"]:FALSE;
|
||||||
$dataPath = isset($getid3key["dataPath"])?$getid3key["dataPath"]:"";
|
$dataPath = isset($getid3key["dataPath"])?$getid3key["dataPath"]:"";
|
||||||
$encPath = isset($getid3key["encPath"])?$getid3key["encPath"]:"";
|
$encPath = isset($getid3key["encPath"])?$getid3key["encPath"]:"";
|
||||||
$enc = "UTF-8";
|
$enc = "UTF-8";
|
||||||
|
@ -222,6 +226,9 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
|
||||||
$tagElement = "\$infoFromFile$path$dataPath";
|
$tagElement = "\$infoFromFile$path$dataPath";
|
||||||
eval("\$tagExists = isset($tagElement);");
|
eval("\$tagExists = isset($tagElement);");
|
||||||
if ($tagExists) {
|
if ($tagExists) {
|
||||||
|
//echo "ignore encoding: ".($ignoreEnc?"yes":"no")."\n";
|
||||||
|
//echo "tag exists\n";
|
||||||
|
//echo "encode path: $encPath\n";
|
||||||
eval("\$data = $tagElement;");
|
eval("\$data = $tagElement;");
|
||||||
if (!$ignoreEnc && $encPath != "") {
|
if (!$ignoreEnc && $encPath != "") {
|
||||||
$encodedElement = "\$infoFromFile$path$encPath";
|
$encodedElement = "\$infoFromFile$path$encPath";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue