Track number length hard coded to 2 digits

Discuss possible bugs amd cures here.

Track number length hard coded to 2 digits

Postby Quasimodo » January 03 2008 - 09:31

I just noticed this on some of my looong albums (like Harry Potter 6) with more than 100 tracks that track numbers are stored only with 2 digits despite of the database field length of 3. I don't know if you're going to change this in jinzora 3, but here are some patches to fix this:

In services/services/tagdata/getid3.php change:
1.
Code: Select all
              if (is_numeric(substr($meta['filename'],0,2))){
                      $meta['number'] = substr($meta['filename'],0,2);
              }

to
Code: Select all
                $nmbr_cutpoint = strspn($meta['filename'], "0123456789");
                if($nmbr_cutpoint > 0) {
                        $meta['number'] = substr($meta['filename'], 0, $nmbr_cutpoint);
                }


2.
Code: Select all
              if (is_numeric(substr($name,0,2))){

to
Code: Select all
               if ($nmbr_cutpoint > 0){


3.
Code: Select all
                              $meta['number'] = substr($name,0,2);

to
Code: Select all
                              $meta['number'] = substr($name,0,$nmbr_cutpoint);


4.
Code: Select all
                      $name1 = substr($name,2,strlen($name));

to
Code: Select all
                      $name1 = substr($name,$nmbr_cutpoint,strlen($name));


5.
Code: Select all
                      if ($meta['number'] == "-" && is_numeric(substr($file,0,2))) {

to
Code: Select all
                      if ($meta['number'] == "-" && $nmbr_cutpoint > 0) {


6.
Code: Select all
                              $meta['number'] = substr($fname,0,2);

to
Code: Select all
                              $meta['number'] = substr($fname,0,$nmbr_cutpoint);


And in services/services/tagdata/filesystem.php change
Code: Select all
              if (is_numeric(substr($name,0,2))){
                      $number = substr($name,0,2);
                      $name = trim(substr($name,3));
              }

to
Code: Select all
              $nmbr_cutpoint=strspn($name, "0123456789");
              if($nmbr_cutpoint > 0){
                      $number = trim(substr($name, $nmbr_cutpoint));
                      $name = trim(substr($name, $nmbr_cutpoint));
              }


Now jinzora can process track number of any length ( though you probably won't find 4-digit track numbers :wink: )

Quasimodo
Quasimodo
 
Posts: 358
Joined: January 18 2007 - 03:50
Location: Germany

Re: Track number length hard coded to 2 digits

Postby Dude » January 13 2008 - 09:19

Thank you Quasimodo for this post, it was just what I was looking. To assist everyone that would like to do this hack, I have added the line numbers for each file.

services/services/tagdata/getid3.php ***
1. - 355
2. - 368
3. - 372
4. - 374
5. - 395
6. - 396

services/services/tagdata/filesystem.php
line 59

* Make a backup of files before making these modifications.
** After making the above changes, rescan the folder for the changes to be visible.
*** I replaced the existing code with Quasimodo's hack. If you comment out existing code, the line numbers will not be accurate.

Cheers!
Dude
 
Posts: 14
Joined: October 01 2003 - 11:25


Return to Bug Discussion

Who is online

Users browsing this forum: No registered users and 1 guest