1 <?php |
1 <?php |
2 ///////////////////////////////////////////////////////////////// |
2 ///////////////////////////////////////////////////////////////// |
3 /// getID3() by James Heinrich <info@getid3.org> // |
3 /// getID3() by James Heinrich <info@getid3.org> // |
4 // available at http://getid3.sourceforge.net // |
4 // available at http://getid3.sourceforge.net // |
5 // or http://www.getid3.org // |
5 // or http://www.getid3.org // |
|
6 // also https://github.com/JamesHeinrich/getID3 // |
6 ///////////////////////////////////////////////////////////////// |
7 ///////////////////////////////////////////////////////////////// |
7 // See readme.txt for more details // |
8 // See readme.txt for more details // |
8 ///////////////////////////////////////////////////////////////// |
9 ///////////////////////////////////////////////////////////////// |
9 /// // |
10 /// // |
10 // module.tag.lyrics3.php // |
11 // module.tag.lyrics3.php // |
25 if (!getid3_lib::intValueSupported($info['filesize'])) { |
26 if (!getid3_lib::intValueSupported($info['filesize'])) { |
26 $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'; |
27 $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'; |
27 return false; |
28 return false; |
28 } |
29 } |
29 |
30 |
30 fseek($this->getid3->fp, (0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size] |
31 $this->fseek((0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size] |
31 $lyrics3_id3v1 = fread($this->getid3->fp, 128 + 9 + 6); |
32 $lyrics3_id3v1 = $this->fread(128 + 9 + 6); |
32 $lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size |
33 $lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size |
33 $lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200 |
34 $lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200 |
34 $id3v1tag = substr($lyrics3_id3v1, 15, 128); // ID3v1 |
35 $id3v1tag = substr($lyrics3_id3v1, 15, 128); // ID3v1 |
35 |
36 |
36 if ($lyrics3end == 'LYRICSEND') { |
37 if ($lyrics3end == 'LYRICSEND') { |
66 |
67 |
67 } else { |
68 } else { |
68 |
69 |
69 if (isset($info['ape']['tag_offset_start']) && ($info['ape']['tag_offset_start'] > 15)) { |
70 if (isset($info['ape']['tag_offset_start']) && ($info['ape']['tag_offset_start'] > 15)) { |
70 |
71 |
71 fseek($this->getid3->fp, $info['ape']['tag_offset_start'] - 15, SEEK_SET); |
72 $this->fseek($info['ape']['tag_offset_start'] - 15); |
72 $lyrics3lsz = fread($this->getid3->fp, 6); |
73 $lyrics3lsz = $this->fread(6); |
73 $lyrics3end = fread($this->getid3->fp, 9); |
74 $lyrics3end = $this->fread(9); |
74 |
75 |
75 if ($lyrics3end == 'LYRICSEND') { |
76 if ($lyrics3end == 'LYRICSEND') { |
76 // Lyrics3v1, APE, maybe ID3v1 |
77 // Lyrics3v1, APE, maybe ID3v1 |
77 |
78 |
78 $lyrics3size = 5100; |
79 $lyrics3size = 5100; |
99 $info['avdataend'] = $lyrics3offset; |
100 $info['avdataend'] = $lyrics3offset; |
100 $this->getLyrics3Data($lyrics3offset, $lyrics3version, $lyrics3size); |
101 $this->getLyrics3Data($lyrics3offset, $lyrics3version, $lyrics3size); |
101 |
102 |
102 if (!isset($info['ape'])) { |
103 if (!isset($info['ape'])) { |
103 $GETID3_ERRORARRAY = &$info['warning']; |
104 $GETID3_ERRORARRAY = &$info['warning']; |
104 if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, false)) { |
105 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true); |
105 $getid3_temp = new getID3(); |
106 $getid3_temp = new getID3(); |
106 $getid3_temp->openfile($this->getid3->filename); |
107 $getid3_temp->openfile($this->getid3->filename); |
107 $getid3_apetag = new getid3_apetag($getid3_temp); |
108 $getid3_apetag = new getid3_apetag($getid3_temp); |
108 $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start']; |
109 $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start']; |
109 $getid3_apetag->Analyze(); |
110 $getid3_apetag->Analyze(); |
110 if (!empty($getid3_temp->info['ape'])) { |
111 if (!empty($getid3_temp->info['ape'])) { |
111 $info['ape'] = $getid3_temp->info['ape']; |
112 $info['ape'] = $getid3_temp->info['ape']; |
112 } |
113 } |
113 if (!empty($getid3_temp->info['replay_gain'])) { |
114 if (!empty($getid3_temp->info['replay_gain'])) { |
114 $info['replay_gain'] = $getid3_temp->info['replay_gain']; |
115 $info['replay_gain'] = $getid3_temp->info['replay_gain']; |
115 } |
116 } |
116 unset($getid3_temp, $getid3_apetag); |
117 unset($getid3_temp, $getid3_apetag); |
117 } |
|
118 } |
118 } |
119 |
119 |
120 } |
120 } |
121 |
121 |
122 return true; |
122 return true; |
130 if (!getid3_lib::intValueSupported($endoffset)) { |
130 if (!getid3_lib::intValueSupported($endoffset)) { |
131 $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'; |
131 $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'; |
132 return false; |
132 return false; |
133 } |
133 } |
134 |
134 |
135 fseek($this->getid3->fp, $endoffset, SEEK_SET); |
135 $this->fseek($endoffset); |
136 if ($length <= 0) { |
136 if ($length <= 0) { |
137 return false; |
137 return false; |
138 } |
138 } |
139 $rawdata = fread($this->getid3->fp, $length); |
139 $rawdata = $this->fread($length); |
140 |
140 |
141 $ParsedLyrics3['raw']['lyrics3version'] = $version; |
141 $ParsedLyrics3['raw']['lyrics3version'] = $version; |
142 $ParsedLyrics3['raw']['lyrics3tagsize'] = $length; |
142 $ParsedLyrics3['raw']['lyrics3tagsize'] = $length; |
143 $ParsedLyrics3['tag_offset_start'] = $endoffset; |
143 $ParsedLyrics3['tag_offset_start'] = $endoffset; |
144 $ParsedLyrics3['tag_offset_end'] = $endoffset + $length - 1; |
144 $ParsedLyrics3['tag_offset_end'] = $endoffset + $length - 1; |
167 case 1: |
167 case 1: |
168 if (substr($rawdata, strlen($rawdata) - 9, 9) == 'LYRICSEND') { |
168 if (substr($rawdata, strlen($rawdata) - 9, 9) == 'LYRICSEND') { |
169 $ParsedLyrics3['raw']['LYR'] = trim(substr($rawdata, 11, strlen($rawdata) - 11 - 9)); |
169 $ParsedLyrics3['raw']['LYR'] = trim(substr($rawdata, 11, strlen($rawdata) - 11 - 9)); |
170 $this->Lyrics3LyricsTimestampParse($ParsedLyrics3); |
170 $this->Lyrics3LyricsTimestampParse($ParsedLyrics3); |
171 } else { |
171 } else { |
172 $info['error'][] = '"LYRICSEND" expected at '.(ftell($this->getid3->fp) - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead'; |
172 $info['error'][] = '"LYRICSEND" expected at '.($this->ftell() - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead'; |
173 return false; |
173 return false; |
174 } |
174 } |
175 break; |
175 break; |
176 |
176 |
177 case 2: |
177 case 2: |