Skip to content

Commit

Permalink
#449 Lyrics3 did not respect option_tag_apetag
Browse files Browse the repository at this point in the history
#449
If a file contained Lyrics3 tags the getid3>option_tag_apetag flag was not respected, it now skips the tag check and appends a warning.
Also Lyrics3 lyrics are now properly returned in the tags/comments structure.
  • Loading branch information
JamesHeinrich committed Aug 6, 2024
1 parent 27da383 commit c4f10f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
4 changes: 3 additions & 1 deletion getid3/getid3.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class getID3
*/
protected $startup_warning = '';

const VERSION = '1.9.23-202407291427';
const VERSION = '1.9.23-202408061058';
const FREAD_BUFFER_SIZE = 32768;

const ATTACHMENTS_NONE = false;
Expand Down Expand Up @@ -680,6 +680,8 @@ public function analyze($filename, $filesize=null, $original_filename='', $fp=nu
catch (getid3_exception $e) {
throw $e;
}
} else {
$this->warning('skipping check for '.$tag_name.' tags since option_tag_'.$tag_name.'=FALSE');
}
}
if (isset($this->info['id3v2']['tag_offset_start'])) {
Expand Down
40 changes: 22 additions & 18 deletions getid3/module.tag.lyrics3.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,23 @@ public function Analyze() {
if (!isset($info['ape'])) {
if (isset($info['lyrics3']['tag_offset_start'])) {
$GETID3_ERRORARRAY = &$info['warning'];
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true);
$getid3_temp = new getID3();
$getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize'], $this->getid3->fp);
$getid3_apetag = new getid3_apetag($getid3_temp);
$getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start'];
$getid3_apetag->Analyze();
if (!empty($getid3_temp->info['ape'])) {
$info['ape'] = $getid3_temp->info['ape'];
}
if (!empty($getid3_temp->info['replay_gain'])) {
$info['replay_gain'] = $getid3_temp->info['replay_gain'];
if ($this->getid3->option_tag_apetag) {
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true);
$getid3_temp = new getID3();
$getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize'], $this->getid3->fp);
$getid3_apetag = new getid3_apetag($getid3_temp);
$getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start'];
$getid3_apetag->Analyze();
if (!empty($getid3_temp->info['ape'])) {
$info['ape'] = $getid3_temp->info['ape'];
}
if (!empty($getid3_temp->info['replay_gain'])) {
$info['replay_gain'] = $getid3_temp->info['replay_gain'];
}
unset($getid3_temp, $getid3_apetag);
} else {
$this->warning('Unable to check for Lyrics3 and APE tags interaction since option_tag_apetag=FALSE');
}
unset($getid3_temp, $getid3_apetag);
} else {
$this->warning('Lyrics3 and APE tags appear to have become entangled (most likely due to updating the APE tags with a non-Lyrics3-aware tagger)');
}
Expand Down Expand Up @@ -296,19 +300,19 @@ public function Lyrics3LyricsTimestampParse(&$Lyrics3data) {
if (isset($thislinetimestamps) && is_array($thislinetimestamps)) {
sort($thislinetimestamps);
foreach ($thislinetimestamps as $timestampkey => $timestamp) {
if (isset($Lyrics3data['synchedlyrics'][$timestamp])) {
if (isset($Lyrics3data['comments']['synchedlyrics'][$timestamp])) {
// timestamps only have a 1-second resolution, it's possible that multiple lines
// could have the same timestamp, if so, append
$Lyrics3data['synchedlyrics'][$timestamp] .= "\r\n".$lyricline;
$Lyrics3data['comments']['synchedlyrics'][$timestamp] .= "\r\n".$lyricline;
} else {
$Lyrics3data['synchedlyrics'][$timestamp] = $lyricline;
$Lyrics3data['comments']['synchedlyrics'][$timestamp] = $lyricline;
}
}
}
}
$Lyrics3data['unsynchedlyrics'] = implode("\r\n", $notimestamplyricsarray);
if (isset($Lyrics3data['synchedlyrics']) && is_array($Lyrics3data['synchedlyrics'])) {
ksort($Lyrics3data['synchedlyrics']);
$Lyrics3data['comments']['unsynchedlyrics'][0] = implode("\r\n", $notimestamplyricsarray);
if (isset($Lyrics3data['comments']['synchedlyrics']) && is_array($Lyrics3data['comments']['synchedlyrics'])) {
ksort($Lyrics3data['comments']['synchedlyrics']);
}
return true;
}
Expand Down

0 comments on commit c4f10f7

Please sign in to comment.