Hi,

        Many CD rippers (well certainly the one I use) provide the option to
include the track number in a filename. Now, I've been using this for ages,
putting the number at the beginning of the filename, so that when the directory
is shown the files are in album order.

        Anyway, the following patch allows the extraction of tracknumbers from
filenames, if no number currently exists. Now, I realise that there is great
potential for numbers in filenames not being tracknumbers, but I figured that a
wrong track number is no worse than a '?' which is what appears at the moment.

        Well, there is currently one bug with this patch in that any tracks
without numbers in the filename get given the number 3 from the .mp3 extension.
I plan to fix this shortly, but I thought I would try to get some feedback on
the patch first. In particular, should I do some range checking on the numbers I
get back. (For example what would happen if a file called "30,000 miles.mp3" was
given the tracknumber 30000? Would this cause problems elsewhere?

Robert

p.s. This is my first ever patch to anything - so if I've messed up be
gentle.....


       \\\|///
     \\  - -  //
      (  @ @  )
+---oOOo-(_)-oOOo------------+
| Robert Hart                |
| [EMAIL PROTECTED]          |
| http://www.bath.ac.uk/     |
|   ooo0           ~ab6rah   |
|  (    )   0ooo             |
+---\  (----(   )------------+
     \_)     ) /
            (_/
Index: freeamp/plm/metadata/misc/misc.cpp

===================================================================

RCS file: /src/repository/freeamp/plm/metadata/misc/misc.cpp,v

retrieving revision 1.10

diff -c -r1.10 misc.cpp

*** freeamp/plm/metadata/misc/misc.cpp  2000/07/31 19:51:39     1.10

--- freeamp/plm/metadata/misc/misc.cpp  2000/08/29 03:31:37

***************

*** 175,180 ****

--- 175,208 ----

          metadata->SetTitle("RTP Stream");

      }

  

+ // do we need to come up with a track number?

+ //    if(!strncasecmp(url, "file://", 7) && !metadata->Track()==0)

+     {

+         char* temp = new char[strlen(url) + 1];

+ 

+         strcpy(temp, url);

+ 

+         char* ext = strrchr(temp, '.');

+         char* file = strrchr(temp, '/'); // these are all URLs so we don't need 
+DIR_MARKER

+         

+         if(ext) {

+             *ext = 0x00;

+             ext++;

+         }

+         

+         if(!file)

+             file = temp;

+         else

+             file++;

+       while(file && !isdigit(*file))

+                       file++;

+ 

+               if(file)

+                       metadata->SetTrack(atoi(file));

+ 

+         delete [] temp;

+     }

+ 

      // do we need to convert underscores?

      bool convertUnderscores = false;

  

Reply via email to