Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Get all the information about a release with just CDTOC? (Read 1159 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Get all the information about a release with just CDTOC?

When encoding or verifying an album with CUETools, it can create a file with .accurip extension containing a code that I consider important: "CTDB TOCID". With this, I can easily access all the album information in CUETools DB (freedb DISCID, CRC32, AccurateRIP ID, etc.) as indicated in this post:
https://hydrogenaud.io/index.php/topic,122010.0.html

CUETools additionally writes three tags to each track, most notably "CDTOC". My question is: if I don't have the file (.accurip), is it possible to also access all the data mentioned above, using only the CDTOC? If so, how? maybe some way to convert this "CDTOC" to "CTDB TOCID" (or something like that)? Best regards.

Re: Get all the information about a release with just CDTOC?

Reply #1
The easiest way to get the CTDB TOCID if you don't have the .accurip file is to Verify the rip and create a new .accurip file.
AFAIK, there isn't a utility to convert CDTOC to CTDB TOCID.
korth

Re: Get all the information about a release with just CDTOC?

Reply #2
The easiest way to get the CTDB TOCID if you don't have the .accurip file is to Verify the rip and create a new .accurip file.
AFAIK, there isn't a utility to convert CDTOC to CTDB TOCID.
Just what I was afraid of. The problem is that a few years ago I deleted some tracks from an album (I never listen to those tracks. I'm not really interested in keeping them), and CUETools (or any other tool that communicates with AccurateRip) can't verify without the entire album. I always thought that with CDTOC I could consult the CTDB and all the release information, but it seems that's not the case. I don't know why CUETools, when it writes its tags to each track, doesn't also write the all-important "CTDB TOCID."

Re: Get all the information about a release with just CDTOC?

Reply #3
How many rips do you have that need to access the DB this way?
korth

Re: Get all the information about a release with just CDTOC?

Reply #4
Even if this is the CUETools forum;
https://www.dbpoweramp.com/Help/perfecttunes/accuraterip.htm can verify tracks (against the AR database, not against the CUETools database). I'm on the road right now and I don't remember if it needs the AccurateRip tags or whether a CDTOC tag will do. But it is possible to calculate the AR identifyer from the TOC, like here: https://github.com/davehensley/calculate-accuraterip-id-from-toc

Re: Get all the information about a release with just CDTOC?

Reply #5
Well the CTDB also requires the entire CD to verify tracks but if you just want to SEE the release information, here is one (long) method to manually access the database if all you have is the CDTOC. Of course it would be easier if you could convert the CDTOC to CTDB TOCID but I haven't worked that out yet.

wanted CTDB TOCID: jwbCIS8AlSqzES7CrVwQ.1bfhoQ-
have CDTOC: B+96+691B+B5BF+131E0+19279+1DDD5+255A9+2C2BD+331D1+39E69+3FA29+490D6

convert hex to decimal
11+150+26907+46527+78304+103033+122325+153001+180925+209361+237161+260649+299222
You don't need the number of tracks (11)
Subtract 150 from all start positions and change delimiter from + to :
0:26757:46377:78154:102883:122175:152701:180775:209211:237011:260499:299072
This can be used to access the database
Code: [Select]
http://db.cuetools.net/lookup2.php?version=3&ctdb=1&metadata=extensive&fuzzy=1&toc=0:26757:46377:78154:102883:122175:152851:180775:209211:237011:260499:299072
Get id from top record (id="173732")
Code: [Select]
http://db.cuetools.net/cd/173732
korth

Re: Get all the information about a release with just CDTOC?

Reply #6
Note: The above example and the one that follows does not include a CDTOC with a CD Extra Data Track or Playstation type data track. These would require additional calculations.

To convert a CDTOC (that contains start positions for audio tracks only + lead-out) to CTDB TOCID

CDTOC: B+96+691B+B5BF+131E0+19279+1DDD5+255A9+2C2BD+331D1+39E69+3FA29+490D6
Subtract the first start position (96) from all (e.g. 691B - 96 = 6885)
6885+B529+1314A+191E3+1DD3F+25513+2C227+3313B+39DD3+3F993+49040
Create a string with each position represented as 4 byte hex and appended to the previous
000068850000B5290001314A000191E30001DD3F000255130002C2270003313B00039DD30003F99300049040
pad (with zeroes) so there are a total of 100 4 byte hex strings represented
Code: [Select]
000068850000B5290001314A000191E30001DD3F000255130002C2270003313B00039DD30003F993000490400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Create a SHA-1 hash of that 800 character string
Code: [Select]
8f06c2212f00952ab3112ec2ad5c10fb56df8684

Convert that string to a RFC 4648 Base64 string of printable ASCII characters (28 characters)
Code: [Select]
jwbCIS8AlSqzES7CrVwQ+1bfhoQ=
Change
 any '+' to a '.'
 any '/' to a '_'
 any '=' to a '-'

Code: [Select]
jwbCIS8AlSqzES7CrVwQ.1bfhoQ-


Here's one with a data track after the audio (hex A=10 tracks but there are 12 start positions)
A+96+693C+BD03+11663+16F30+1CE6C+22303+22925+28C49+2ECD9+388C4+42D0D
The start position of the data track is not equal to the last frame of the audio +1. In this example, in addition to subtracting the first track start position, you need to subtract an additional 11400 frames (11250 frames for lead-out/lead-in + 150 frames of pre-gap) from that value. That's 2C88 in hex. AND you don't need the lead-out start position from the data track (42D0D). The CTDB TOCID calculation only uses audio positions.
693C - 96 = 68A6
[...]
388C4 - 96 - 2C88 = 35BA6

68A6+BC6D+115CD+16E9A+1CDD6+2226D+2288F+28BB3+2EC43+35BA6
000068A60000BC6D000115CD00016E9A0001CDD60002226D0002288F00028BB30002EC4300035BA6

Code: [Select]
000068A60000BC6D000115CD00016E9A0001CDD60002226D0002288F00028BB30002EC4300035BA6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
SHA-1
Code: [Select]
3327ff840208f20238033eca541419e62c05ed65
Base64
Code: [Select]
Myf/hAII8gI4Az7KVBQZ5iwF7WU=
+ / = characters converted to _ . -
Code: [Select]
Myf_hAII8gI4Az7KVBQZ5iwF7WU-
korth

Re: Get all the information about a release with just CDTOC?

Reply #7
Well the CTDB also requires the entire CD to verify tracks but if you just want to SEE the release information, here is one (long) method to manually access the database if all you have is the CDTOC. Of course it would be easier if you could convert the CDTOC to CTDB TOCID but I haven't worked that out yet.

wanted CTDB TOCID: jwbCIS8AlSqzES7CrVwQ.1bfhoQ-
have CDTOC: B+96+691B+B5BF+131E0+19279+1DDD5+255A9+2C2BD+331D1+39E69+3FA29+490D6

convert hex to decimal
11+150+26907+46527+78304+103033+122325+153001+180925+209361+237161+260649+299222
You don't need the number of tracks (11)
Subtract 150 from all start positions and change delimiter from + to :
0:26757:46377:78154:102883:122175:152701:180775:209211:237011:260499:299072
This can be used to access the database
Code: [Select]
http://db.cuetools.net/lookup2.php?version=3&ctdb=1&metadata=extensive&fuzzy=1&toc=0:26757:46377:78154:102883:122175:152851:180775:209211:237011:260499:299072
Get id from top record (id="173732")
Code: [Select]
http://db.cuetools.net/cd/173732
Thank you very much, your steps work perfectly. I've written a Python script to automate this process a bit. Simply paste your CDTOC (in the variable CDTOC), run the script, and it will return all the components converted to decimal, with the subtraction based on the second component, and the number of tracks removed. The result is a URL ready to paste into the browser and retrieve the ID.

Code: [Select]
import os
CDTOC = "1C+96+2B9D+5596+8E76+A7FA+DB17+FBBD+11EAB+1489F+168D2+18B8C+1AC66+1D25B+1F213+21999+239D5+24FEF+26F2A+28C6E+2AE92+2D7CD+3007A+320D9+34D73+36F49+3B96B+3CC50+4417E+48AB4"
CDTOC = CDTOC.split("+");
CDTOC.pop(0)
dec = []
for i in CDTOC:
   i = int(i, 16) - int(CDTOC[0], 16)
   dec.append(str(i))
dec[0] = "0"
dec = ":".join(dec)
URL = "http://db.cuetools.net/lookup2.php?version=3&ctdb=1&metadata=extensive&fuzzy=1&toc=" + dec
print(URL)

I've tested it with several albums and have always been able to get exactly the same CTDB-TOCID as the one found in the .accurip file.
NOTE: I haven't yet analyzed in depth your (more complex) steps related to albums with extra data or PlayStation data.
Best regards.

Re: Get all the information about a release with just CDTOC?

Reply #8
For your amusement:
I added the steps (quoted below) in a simple c# console app targeting .net4.7
Currently it will fail (with a message) on a CDTOC with a data track; fail by checking the number of start positions against the track count (maybe I'll work on adding data tracks later but this app was just for fun) <updated 2025-04-22

Paste text from CDTOC, press Enter e.g.
Code: [Select]
B+96+691B+B5BF+131E0+19279+1DDD5+255A9+2C2BD+331D1+39E69+3FA29+490D6
Output:
Code: [Select]
CTDB TOCID: jwbCIS8AlSqzES7CrVwQ.1bfhoQ-
The program ends on error or after output.

To convert a CDTOC (that contains start positions for audio tracks only + lead-out) to CTDB TOCID

CDTOC: B+96+691B+B5BF+131E0+19279+1DDD5+255A9+2C2BD+331D1+39E69+3FA29+490D6
Subtract the first start position (96) from all (e.g. 691B - 96 = 6885)
6885+B529+1314A+191E3+1DD3F+25513+2C227+3313B+39DD3+3F993+49040
Create a string with each position represented as 4 byte hex and appended to the previous
000068850000B5290001314A000191E30001DD3F000255130002C2270003313B00039DD30003F99300049040
pad (with zeroes) so there are a total of 100 4 byte hex strings represented
Code: [Select]
000068850000B5290001314A000191E30001DD3F000255130002C2270003313B00039DD30003F993000490400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Create a SHA-1 hash of that 800 character string
Code: [Select]
8f06c2212f00952ab3112ec2ad5c10fb56df8684

Convert that string to a RFC 4648 Base64 string of printable ASCII characters (28 characters)
Code: [Select]
jwbCIS8AlSqzES7CrVwQ+1bfhoQ=
Change
 any '+' to a '.'
 any '/' to a '_'
 any '=' to a '-'

Code: [Select]
jwbCIS8AlSqzES7CrVwQ.1bfhoQ-



EDIT: 2025-04-28 modified version to include single data track and corrected text label
korth


Re: Get all the information about a release with just CDTOC?

Reply #10
So it does not convert "to CTDB TOCID" then :P
It also failed on a data track.
It appears that @Toad King  did write a script to convert from the MusicBrainz CDTOC to CTDB TOCID that I did not know about
https://github.com/ToadKing/musicbrainz-userscripts/blob/master/musicbrainz-ctdb.user.js
(Edit: looking at the code I think that's part of what it does but I did not try it)
korth

 

Re: Get all the information about a release with just CDTOC?

Reply #11
So it does not convert "to CTDB TOCID" then :P
It also failed on a data track.
It appears that @Toad King  did write a script to convert from the MusicBrainz CDTOC to CTDB TOCID that I did not know about
https://github.com/ToadKing/musicbrainz-userscripts/blob/master/musicbrainz-ctdb.user.js
(Edit: looking at the code I think that's part of what it does but I did not try it)

If the user script is installed, then on a MusicBrainz Disc ID page it will show a CTDB equivalent (if any).