ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GetId3\Module\Misc\Cue Class Reference

GetId3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //. More...

+ Inheritance diagram for GetId3\Module\Misc\Cue:
+ Collaboration diagram for GetId3\Module\Misc\Cue:

Public Member Functions

 analyze ()
 
 readCueSheetFilename ($filename)
 
 readCueSheet (&$filedata)
 
 parseCueSheet ($file)
 
 parseComment ($line, $track_on)
 Parses the REM command. More...
 
 parseFile ($line)
 Parses the FILE command. More...
 
 parseFlags ($line, $track_on)
 Parses the FLAG command. More...
 
 parseGarbage ($line, $track_on)
 Collect any unidentified data. More...
 
 parseIndex ($line, $track_on)
 Parses the INDEX command of a TRACK. More...
 
 parseString ($line, $track_on)
 
 parseTrack ($line, $track_on)
 Parses the TRACK command. More...
 
- Public Member Functions inherited from GetId3\Handler\BaseHandler
 __construct (GetId3Core $getid3, $call_module=null)
 
 analyze ()
 Analyze from file pointer. More...
 
 AnalyzeString (&$string)
 Analyze from string instead. More...
 
 saveAttachment (&$ThisFileInfoIndex, $filename, $offset, $length)
 

Data Fields

 $cuesheet = array()
 

Additional Inherited Members

- Protected Member Functions inherited from GetId3\Handler\BaseHandler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
- Protected Attributes inherited from GetId3\Handler\BaseHandler
 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Detailed Description

GetId3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //.

module for analyzing CUEsheet files

Module originally written [2009-Mar-25] by Nigel Barnes <ngbarnesØhotmail*com> Minor reformatting and similar small changes to integrate into GetId3 by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g

CueSheet parser by Nigel Barnes.

This is a PHP conversion of CueSharp 0.5 by Wyatt O'Day (wyday.com/cuesharp)

A CueSheet class used to open and parse cuesheets.

Author
James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g http://www.getid3.org

Definition at line 46 of file Cue.php.

Member Function Documentation

◆ analyze()

GetId3\Module\Misc\Cue::analyze ( )
Returns
boolean

Definition at line 58 of file Cue.php.

References GetId3\Module\Misc\Cue\$cuesheet, $info, and GetId3\Module\Misc\Cue\readCueSheetFilename().

59  {
60  $info = &$this->getid3->info;
61 
62  $info['fileformat'] = 'cue';
63  $this->readCueSheetFilename($info['filenamepath']);
64  $info['cue'] = $this->cuesheet;
65 
66  return true;
67  }
readCueSheetFilename($filename)
Definition: Cue.php:74
$info
Definition: example_052.php:80
+ Here is the call graph for this function:

◆ parseComment()

GetId3\Module\Misc\Cue::parseComment (   $line,
  $track_on 
)

Parses the REM command.

Parameters
string$line- The line in the cue file that contains the TRACK command.
integer$track_on- The track currently processing.

Definition at line 154 of file Cue.php.

Referenced by GetId3\Module\Misc\Cue\parseCueSheet().

155  {
156  $explodedline = explode(' ', $line, 3);
157  $comment_REM = (isset($explodedline[0]) ? $explodedline[0] : '');
158  $comment_type = (isset($explodedline[1]) ? $explodedline[1] : '');
159  $comment_data = (isset($explodedline[2]) ? $explodedline[2] : '');
160  if (($comment_REM == 'REM') && $comment_type) {
161  $comment_type = strtolower($comment_type);
162  $commment_data = trim($comment_data, ' "');
163  if ($track_on != -1) {
164  $this->cuesheet['tracks'][$track_on]['comments'][$comment_type][] = $comment_data;
165  } else {
166  $this->cuesheet['comments'][$comment_type][] = $comment_data;
167  }
168  }
169  }
+ Here is the caller graph for this function:

◆ parseCueSheet()

GetId3\Module\Misc\Cue::parseCueSheet (   $file)
Parameters
type$file- The cuesheet as an array of each line.

Definition at line 103 of file Cue.php.

References $file, GetId3\Module\Misc\Cue\parseComment(), GetId3\Module\Misc\Cue\parseFile(), GetId3\Module\Misc\Cue\parseFlags(), GetId3\Module\Misc\Cue\parseGarbage(), GetId3\Module\Misc\Cue\parseIndex(), GetId3\Module\Misc\Cue\parseString(), and GetId3\Module\Misc\Cue\parseTrack().

Referenced by GetId3\Module\Misc\Cue\readCueSheet().

104  {
105  //-1 means still global, all others are track specific
106  $track_on = -1;
107 
108  for ($i=0; $i < count($file); $i++) {
109  list($key) = explode(' ', strtolower($file[$i]), 2);
110  switch ($key) {
111  case 'catalog':
112  case 'cdtextfile':
113  case 'isrc':
114  case 'performer':
115  case 'songwriter':
116  case 'title':
117  $this->parseString($file[$i], $track_on);
118  break;
119  case 'file':
120  $currentFile = $this->parseFile($file[$i]);
121  break;
122  case 'flags':
123  $this->parseFlags($file[$i], $track_on);
124  break;
125  case 'index':
126  case 'postgap':
127  case 'pregap':
128  $this->parseIndex($file[$i], $track_on);
129  break;
130  case 'rem':
131  $this->parseComment($file[$i], $track_on);
132  break;
133  case 'track':
134  $track_on++;
135  $this->parseTrack($file[$i], $track_on);
136  if (isset($currentFile)) { // if there's a file
137  $this->cuesheet['tracks'][$track_on]['datafile'] = $currentFile;
138  }
139  break;
140  default:
141  //save discarded junk and place string[] with track it was found in
142  $this->parseGarbage($file[$i], $track_on);
143  break;
144  }
145  }
146  }
parseComment($line, $track_on)
Parses the REM command.
Definition: Cue.php:154
parseFlags($line, $track_on)
Parses the FLAG command.
Definition: Cue.php:198
parseIndex($line, $track_on)
Parses the INDEX command of a TRACK.
Definition: Cue.php:250
parseGarbage($line, $track_on)
Collect any unidentified data.
Definition: Cue.php:233
parseString($line, $track_on)
Definition: Cue.php:283
parseTrack($line, $track_on)
Parses the TRACK command.
Definition: Cue.php:315
parseFile($line)
Parses the FILE command.
Definition: Cue.php:178
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseFile()

GetId3\Module\Misc\Cue::parseFile (   $line)

Parses the FILE command.

Parameters
string$line- The line in the cue file that contains the FILE command.
Returns
array - Array of FILENAME and TYPE of file..

Definition at line 178 of file Cue.php.

References array.

Referenced by GetId3\Module\Misc\Cue\parseCueSheet().

179  {
180  $line = substr($line, strpos($line, ' ') + 1);
181  $type = strtolower(substr($line, strrpos($line, ' ')));
182 
183  //remove type
184  $line = substr($line, 0, strrpos($line, ' ') - 1);
185 
186  //if quotes around it, remove them.
187  $line = trim($line, '"');
188 
189  return array('filename'=>$line, 'type'=>$type);
190  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ parseFlags()

GetId3\Module\Misc\Cue::parseFlags (   $line,
  $track_on 
)

Parses the FLAG command.

Parameters
string$line- The line in the cue file that contains the TRACK command.
integer$track_on- The track currently processing.

Definition at line 198 of file Cue.php.

References array.

Referenced by GetId3\Module\Misc\Cue\parseCueSheet().

199  {
200  if ($track_on != -1) {
201  foreach (explode(' ', strtolower($line)) as $type) {
202  switch ($type) {
203  case 'flags':
204  // first entry in this line
205  $this->cuesheet['tracks'][$track_on]['flags'] = array(
206  '4ch' => false,
207  'data' => false,
208  'dcp' => false,
209  'pre' => false,
210  'scms' => false,
211  );
212  break;
213  case 'data':
214  case 'dcp':
215  case '4ch':
216  case 'pre':
217  case 'scms':
218  $this->cuesheet['tracks'][$track_on]['flags'][$type] = true;
219  break;
220  default:
221  break;
222  }
223  }
224  }
225  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ parseGarbage()

GetId3\Module\Misc\Cue::parseGarbage (   $line,
  $track_on 
)

Collect any unidentified data.

Parameters
string$line- The line in the cue file that contains the TRACK command.
integer$track_on- The track currently processing.

Definition at line 233 of file Cue.php.

Referenced by GetId3\Module\Misc\Cue\parseCueSheet().

234  {
235  if ( strlen($line) > 0 ) {
236  if ($track_on == -1) {
237  $this->cuesheet['garbage'][] = $line;
238  } else {
239  $this->cuesheet['tracks'][$track_on]['garbage'][] = $line;
240  }
241  }
242  }
+ Here is the caller graph for this function:

◆ parseIndex()

GetId3\Module\Misc\Cue::parseIndex (   $line,
  $track_on 
)

Parses the INDEX command of a TRACK.

Parameters
string$line- The line in the cue file that contains the TRACK command.
integer$track_on- The track currently processing.

Definition at line 250 of file Cue.php.

References array.

Referenced by GetId3\Module\Misc\Cue\parseCueSheet().

251  {
252  $type = strtolower(substr($line, 0, strpos($line, ' ')));
253  $line = substr($line, strpos($line, ' ') + 1);
254 
255  if ($type == 'index') {
256  //read the index number
257  $number = intval(substr($line, 0, strpos($line, ' ')));
258  $line = substr($line, strpos($line, ' ') + 1);
259  }
260 
261  //extract the minutes, seconds, and frames
262  $explodedline = explode(':', $line);
263  $minutes = (isset($explodedline[0]) ? $explodedline[0] : '');
264  $seconds = (isset($explodedline[1]) ? $explodedline[1] : '');
265  $frames = (isset($explodedline[2]) ? $explodedline[2] : '');
266 
267  switch ($type) {
268  case 'index':
269  $this->cuesheet['tracks'][$track_on][$type][$number] = array('minutes'=>intval($minutes), 'seconds'=>intval($seconds), 'frames'=>intval($frames));
270  break;
271  case 'pregap':
272  case 'postgap':
273  $this->cuesheet['tracks'][$track_on][$type] = array('minutes'=>intval($minutes), 'seconds'=>intval($seconds), 'frames'=>intval($frames));
274  break;
275  }
276  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ parseString()

GetId3\Module\Misc\Cue::parseString (   $line,
  $track_on 
)
Parameters
type$line
type$track_on

Definition at line 283 of file Cue.php.

Referenced by GetId3\Module\Misc\Cue\parseCueSheet().

284  {
285  $category = strtolower(substr($line, 0, strpos($line, ' ')));
286  $line = substr($line, strpos($line, ' ') + 1);
287 
288  //get rid of the quotes
289  $line = trim($line, '"');
290 
291  switch ($category) {
292  case 'catalog':
293  case 'cdtextfile':
294  case 'isrc':
295  case 'performer':
296  case 'songwriter':
297  case 'title':
298  if ($track_on == -1) {
299  $this->cuesheet[$category] = $line;
300  } else {
301  $this->cuesheet['tracks'][$track_on][$category] = $line;
302  }
303  break;
304  default:
305  break;
306  }
307  }
+ Here is the caller graph for this function:

◆ parseTrack()

GetId3\Module\Misc\Cue::parseTrack (   $line,
  $track_on 
)

Parses the TRACK command.

Parameters
string$line- The line in the cue file that contains the TRACK command.
integer$track_on- The track currently processing.

Definition at line 315 of file Cue.php.

References array.

Referenced by GetId3\Module\Misc\Cue\parseCueSheet().

316  {
317  $line = substr($line, strpos($line, ' ') + 1);
318  $track = ltrim(substr($line, 0, strpos($line, ' ')), '0');
319 
320  //find the data type.
321  $datatype = strtolower(substr($line, strpos($line, ' ') + 1));
322 
323  $this->cuesheet['tracks'][$track_on] = array('track_number'=>$track, 'datatype'=>$datatype);
324  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ readCueSheet()

GetId3\Module\Misc\Cue::readCueSheet ( $filedata)
Parameters
type$filedata- The filename for the cue sheet to open.
Returns
type

Definition at line 86 of file Cue.php.

References GetId3\Module\Misc\Cue\$cuesheet, array, and GetId3\Module\Misc\Cue\parseCueSheet().

Referenced by GetId3\Module\Misc\Cue\readCueSheetFilename().

87  {
88  $cue_lines = array();
89  foreach (explode("\n", str_replace("\r", null, $filedata)) as $line) {
90  if ( (strlen($line) > 0) && ($line[0] != '#')) {
91  $cue_lines[] = trim($line);
92  }
93  }
94  $this->parseCueSheet($cue_lines);
95 
96  return $this->cuesheet;
97  }
parseCueSheet($file)
Definition: Cue.php:103
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readCueSheetFilename()

GetId3\Module\Misc\Cue::readCueSheetFilename (   $filename)
Parameters
type$filename
Returns
type

Definition at line 74 of file Cue.php.

References $filename, and GetId3\Module\Misc\Cue\readCueSheet().

Referenced by GetId3\Module\Misc\Cue\analyze().

75  {
76  $filedata = file_get_contents($filename);
77 
78  return $this->readCueSheet($filedata);
79  }
readCueSheet(&$filedata)
Definition: Cue.php:86
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cuesheet

GetId3\Module\Misc\Cue::$cuesheet = array()

Definition at line 52 of file Cue.php.

Referenced by GetId3\Module\Misc\Cue\analyze(), and GetId3\Module\Misc\Cue\readCueSheet().


The documentation for this class was generated from the following file: