caveman-dick / rubyripper

Automatically exported from code.google.com/p/rubyripper
0 stars 0 forks source link

Rubyripper doesn't handle situations where information from freedb is sent on multiple lines #65

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
What is the expected output? What do you see instead?

Freedb can send information about a track, record title, etc. on multiple 
lines. However, Rubyripper always assume that a new line in the response 
from freedb is 'new' information.

This can be recreated by modifying the row (rr_lib.rb)

--------------------------------------------------
@socket.puts("cddb read #{@category} #{@discid}") # Get match
--------------------------------------------------

to

--------------------------------------------------
@socket.puts("cddb read rock bf126b0e") # Get match
--------------------------------------------------

This will get information about a Bob Dylan bootlet. Adding a

--------------------------------------------------
puts(@raw_response)
--------------------------------------------------

at the beginning of rr_lib.rb cd_vars gives this output:

--------------------------------------------------
DISCID=bf126b0e
DTITLE=Bob Dylan / Oh Me! Oh My! Country Pie! (D1) 2000-05-18 Stockhol
DTITLE=m
DYEAR=2000
DGENRE=Rock
TTITLE0=good evening, ladies and gentlemen, would you please welcome .
TTITLE0=..
TTITLE1=Roving Gambler
TTITLE2=Mr. Tambourine Man
TTITLE3=Masters Of War
TTITLE4=Visions Of Johanna
TTITLE5=Tangled Up In Blue
TTITLE6=Gates Of Eden
TTITLE7=Country Pie
TTITLE8=Ballad Of A Thin Man
TTITLE9=Watching The River Flow
TTITLE10=Things Have Changed
TTITLE11=Not Dark Yet
TTITLE12=Leopard-Skin Pill-Box Hat
TTITLE13=Love Sick
--------------------------------------------------

Notice that TTITLE0 requires TWO rows! When rrip_cli report information 
about the disc, this is shown:

--------------------------------------------------
FREEDB INFO
1) Artist : m
2) Album :
3) Genre : Rock
4) Year : 2000
5) Track 1 : good evening, ladies and gentlemen, would you please welcome .
6) Track 2 : ..
7) Track 3 : Roving Gambler
8) Track 4 : Mr. Tambourine Man
9) Track 5 : Masters Of War
10) Track 6 : Visions Of Johanna
11) Track 7 : Tangled Up In Blue
12) Track 8 : Gates Of Eden
13) Track 9 : Country Pie
14) Track 10 : Ballad Of A Thin Man
15) Track 11 : Watching The River Flow
16) Track 12 : Things Have Changed
17) Track 13 : Not Dark Yet
18) Track 14 : Leopard-Skin Pill-Box Hat
--------------------------------------------------

As you see, the second row with TTITLE0 data has become a track title of 
its own. A result of this is that all remaining track names are out of 
sync.

The same applies to the disc title, there are two rows used for the title, 
but only the last one is used by rubyripper (I guess the data read from 
the first line is overwritten when the second line is read)

I've fiddled with a workaround but I haven't solved it all yet. I guess 
one has to take a look at the next line of the input before processing the 
current line. This should be done in order to check whether the next line 
has the same type of data as the current line. What I have come up with 
transforms the data read from the @raw_response to this:

--------------------------------------------------
DISCID bf126b0e
DTITLE Bob Dylan / Oh Me! Oh My! Country Pie! (D1) 2000-05-18 Stockholm
DYEAR 2000
DGENRE Rock
TTITLE0 good evening, ladies and gentlemen, would you please welcome ...
TTITLE1 Roving Gambler
TTITLE2 Mr. Tambourine Man
TTITLE3 Masters Of War
TTITLE4 Visions Of Johanna
TTITLE5 Tangled Up In Blue
TTITLE6 Gates Of Eden
TTITLE7 Country Pie
TTITLE8 Ballad Of A Thin Man
TTITLE9 Watching The River Flow
TTITLE10 Things Have Changed
TTITLE11 Not Dark Yet
TTITLE12 Leopard-Skin Pill-Box Hat
TTITLE13 Love Sick
--------------------------------------------------

which seem pretty correct to me. My code doesn't change any of the data in 
the @raw_response, it just writes output to the screen. And here is the 
code:

--------------------------------------------------
old_key = ''
old_value = ''

for i in 0...@raw_response.length 

   # split this row into key (DISCID/DTITLE/DYEAR, etc) and value
   r = raw_response[i].split('=')

   # if this is the first line of data from freedb
   # just save key and value for future use
   if i == 0
      old_key = r[0]
      old_value = r[1]

   # This is the last line of input from freedb
   elsif i == (@raw_response.length - 1)

      # if the key of this row is the same as the
      # previous line, just append the data to the
      # previous data
      if r[0] == old_key
         old_value.concat(r[1])
         puts(old_key + ' ' + old_value)

      # The key is different, so first handle the
      # old data, and then the current data
      else
         puts(old_key + ' ' + old_value)
         puts(r[0] + ' ' + r[1])
      end

   # Any other row
   else

      # Same key as previous line, just append data
      if r[0] == old_key
         old_value.concat(r[1])

      # different key, handle previous line and
      # remember this line for future use
      else
         puts(old_key + ' ' + old_value)
         old_key = r[0]
         old_value = r[1]
      end
   end
end
--------------------------------------------------

Hope this can be of any help

What version of rubyripper are you using? On what operating system? Are 
you using the gtk2 or the commandline interface?

rrip_cli, 0.3 but the code is the same in the latest available download. 
Running Kubuntu Linux

Please provide any additional information below.

Original issue reported on code.google.com by crazysw...@gmail.com on 11 Mar 2007 at 2:18

GoogleCodeExporter commented 8 years ago
Ok, didn't know that the lines could actually be two rows. Although I 
appreciate 
your help with providing code, I'll have a look for a more suble change which 
does 
the same.

Original comment by rubyripp...@gmail.com on 11 Mar 2007 at 2:31

GoogleCodeExporter commented 8 years ago
I think I fixed it in commit 84. See for the changes:
http://groups.google.com/group/rubyripper-commits/msg/ef42a6b46d8cbbf2

Please open a new bug if it ain't working.

Original comment by rubyripp...@gmail.com on 11 Mar 2007 at 3:18