Spaces:
Running
Running
it has to be better at identifying re-issues and first presses , and also this error is back: Analysis failed: Failed to execute 'querySelector' on 'Document': '.md\\:w-80' is not a valid selector. please make sure app is bug free before completing
Browse files- components/deepseek-service.js +70 -7
- components/enhanced-ocr-service.js +55 -7
- components/ocr-service.js +42 -7
- script.js +28 -3
components/deepseek-service.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
class DeepseekService {
|
| 2 |
constructor() {
|
| 3 |
this.apiKey = localStorage.getItem('deepseek_api_key');
|
|
@@ -29,31 +30,65 @@ class DeepseekService {
|
|
| 29 |
const messages = [
|
| 30 |
{
|
| 31 |
role: 'system',
|
| 32 |
-
content: `You are a vinyl record identification expert. Analyze record images and extract all visible information.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
Return ONLY a JSON object with this exact structure:
|
| 34 |
{
|
| 35 |
"artist": "string or null",
|
| 36 |
"title": "string or null",
|
| 37 |
"catalogueNumber": "string or null",
|
| 38 |
"label": "string or null",
|
| 39 |
-
"year": "number or null",
|
|
|
|
|
|
|
| 40 |
"country": "string or null",
|
| 41 |
"format": "string or null (e.g., LP, 12\\", 7\\")",
|
| 42 |
"genre": "string or null",
|
| 43 |
"conditionEstimate": "string or null (NM/VG+/VG/G)",
|
| 44 |
-
"pressingInfo": "string or null (matrix/runout details)",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
"confidence": "high|medium|low",
|
| 46 |
"notes": "array of strings with additional observations"
|
| 47 |
}
|
| 48 |
|
| 49 |
-
Be precise. Only include info you can clearly read
|
| 50 |
},
|
| 51 |
{
|
| 52 |
role: 'user',
|
| 53 |
content: [
|
| 54 |
{
|
| 55 |
type: 'text',
|
| 56 |
-
text: 'Analyze these record photos. Identify the artist, title, catalogue number, label, year, and
|
| 57 |
},
|
| 58 |
...base64Images.map(base64 => ({
|
| 59 |
type: 'image_url',
|
|
@@ -76,7 +111,7 @@ Be precise. Only include info you can clearly read from the images. If text is b
|
|
| 76 |
body: JSON.stringify({
|
| 77 |
model: this.model,
|
| 78 |
messages: messages,
|
| 79 |
-
max_tokens:
|
| 80 |
temperature: 0.2
|
| 81 |
})
|
| 82 |
});
|
|
@@ -90,4 +125,32 @@ Be precise. Only include info you can clearly read from the images. If text is b
|
|
| 90 |
const content = data.choices[0].message.content;
|
| 91 |
|
| 92 |
// Extract JSON from potential markdown code blocks
|
| 93 |
-
const jsonMatch = content.match(/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
class DeepseekService {
|
| 3 |
constructor() {
|
| 4 |
this.apiKey = localStorage.getItem('deepseek_api_key');
|
|
|
|
| 30 |
const messages = [
|
| 31 |
{
|
| 32 |
role: 'system',
|
| 33 |
+
content: `You are a vinyl record identification expert specializing in pressing identification. Analyze record images and extract all visible information with special attention to first press vs reissue identification.
|
| 34 |
+
|
| 35 |
+
CRITICAL - Pressing Identification Rules:
|
| 36 |
+
1. DEADWAX/MATRIX ANALYSIS IS ESSENTIAL - Look for:
|
| 37 |
+
- Hand-etched vs machine-stamped matrix numbers (hand-etched often indicates early pressings)
|
| 38 |
+
- Plant identifiers: "STERLING", "RL", "PORKY", "TML", "EMI", "CBS"
|
| 39 |
+
- Mastering engineer initials or signatures
|
| 40 |
+
- "A1", "B1" stampings indicate first stamper/cut
|
| 41 |
+
- "-" or "/" separators in matrix numbers
|
| 42 |
+
- Additional letters after main catalog number (e.g., "-A", "/1")
|
| 43 |
+
|
| 44 |
+
2. LABEL ANALYSIS for pressing identification:
|
| 45 |
+
- Label design variations (logo style, color shades, rim text)
|
| 46 |
+
- Address changes on labels (indicate different pressing periods)
|
| 47 |
+
- "Made in..." country variations
|
| 48 |
+
- Stereo/mono indicators and their placement
|
| 49 |
+
- Copyright text differences
|
| 50 |
+
|
| 51 |
+
3. SLEEVE/COVER indicators:
|
| 52 |
+
- Barcode presence = likely 1980s+ reissue (originals often lack barcodes)
|
| 53 |
+
- Price codes (UK: K/T/S prefixes, US: $ prices)
|
| 54 |
+
- Laminated vs non-laminated sleeves
|
| 55 |
+
- "Digital Remaster" or "180g" stickers = modern reissue
|
| 56 |
+
|
| 57 |
+
4. YEAR vs ORIGINAL YEAR distinction:
|
| 58 |
+
- Sleeve may show original release year
|
| 59 |
+
- Label/barcode may reveal actual pressing year
|
| 60 |
+
- Catalog number patterns indicate era
|
| 61 |
+
|
| 62 |
Return ONLY a JSON object with this exact structure:
|
| 63 |
{
|
| 64 |
"artist": "string or null",
|
| 65 |
"title": "string or null",
|
| 66 |
"catalogueNumber": "string or null",
|
| 67 |
"label": "string or null",
|
| 68 |
+
"year": "number or null (the pressing/year shown on this copy)",
|
| 69 |
+
"originalYear": "number or null (if different from year, the original release year)",
|
| 70 |
+
"reissueYear": "number or null (if this is a reissue, when it was reissued)",
|
| 71 |
"country": "string or null",
|
| 72 |
"format": "string or null (e.g., LP, 12\\", 7\\")",
|
| 73 |
"genre": "string or null",
|
| 74 |
"conditionEstimate": "string or null (NM/VG+/VG/G)",
|
| 75 |
+
"pressingInfo": "string or null (full matrix/runout details as found)",
|
| 76 |
+
"isFirstPress": "boolean or null (true if evidence suggests first pressing)",
|
| 77 |
+
"pressingType": "string or null ('first_press', 'repress', 'reissue', 'unknown')",
|
| 78 |
+
"pressingConfidence": "string ('high', 'medium', 'low' - how confident you are about pressing identification)",
|
| 79 |
+
"pressingEvidence": "array of strings (specific visual evidence for pressing determination)",
|
| 80 |
"confidence": "high|medium|low",
|
| 81 |
"notes": "array of strings with additional observations"
|
| 82 |
}
|
| 83 |
|
| 84 |
+
Be precise. Only include info you can clearly read. For pressing identification, be conservative - only mark as first press if you see strong evidence (A1/B1 stampers, specific plant codes matching known first presses, etc.).`
|
| 85 |
},
|
| 86 |
{
|
| 87 |
role: 'user',
|
| 88 |
content: [
|
| 89 |
{
|
| 90 |
type: 'text',
|
| 91 |
+
text: 'Analyze these record photos. Identify the artist, title, catalogue number, label, year, and CRITICALLY: examine the deadwax/matrix area and labels closely to determine if this is a first pressing, repress, or reissue. Report any matrix numbers, plant codes, or label variations you can see.'
|
| 92 |
},
|
| 93 |
...base64Images.map(base64 => ({
|
| 94 |
type: 'image_url',
|
|
|
|
| 111 |
body: JSON.stringify({
|
| 112 |
model: this.model,
|
| 113 |
messages: messages,
|
| 114 |
+
max_tokens: 2000,
|
| 115 |
temperature: 0.2
|
| 116 |
})
|
| 117 |
});
|
|
|
|
| 125 |
const content = data.choices[0].message.content;
|
| 126 |
|
| 127 |
// Extract JSON from potential markdown code blocks
|
| 128 |
+
const jsonMatch = content.match(/```json\s*([\s\S]*?)\s*```|(\{[\s\S]*\})/);
|
| 129 |
+
const jsonStr = jsonMatch ? (jsonMatch[1] || jsonMatch[2]) : content;
|
| 130 |
+
|
| 131 |
+
try {
|
| 132 |
+
return JSON.parse(jsonStr.trim());
|
| 133 |
+
} catch (e) {
|
| 134 |
+
console.error('Failed to parse DeepSeek response:', content);
|
| 135 |
+
throw new Error('Failed to parse record data');
|
| 136 |
+
}
|
| 137 |
+
} catch (error) {
|
| 138 |
+
console.error('DeepSeek Analysis Error:', error);
|
| 139 |
+
throw error;
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
async fileToBase64(file) {
|
| 144 |
+
return new Promise((resolve, reject) => {
|
| 145 |
+
const reader = new FileReader();
|
| 146 |
+
reader.onload = () => {
|
| 147 |
+
const base64 = reader.result.split(',')[1];
|
| 148 |
+
resolve(base64);
|
| 149 |
+
};
|
| 150 |
+
reader.onerror = reject;
|
| 151 |
+
reader.readAsDataURL(file);
|
| 152 |
+
});
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
window.deepseekService = new DeepseekService();
|
components/enhanced-ocr-service.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
class EnhancedOCRService {
|
| 2 |
constructor() {
|
| 3 |
this.apiKey = localStorage.getItem('openai_api_key');
|
|
@@ -16,31 +17,65 @@ class EnhancedOCRService {
|
|
| 16 |
const messages = [
|
| 17 |
{
|
| 18 |
role: 'system',
|
| 19 |
-
content: `You are a vinyl record identification expert with advanced OCR capabilities. Analyze record images and extract all visible information.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
Return ONLY a JSON object with this exact structure:
|
| 21 |
{
|
| 22 |
"artist": "string or null",
|
| 23 |
"title": "string or null",
|
| 24 |
"catalogueNumber": "string or null",
|
| 25 |
"label": "string or null",
|
| 26 |
-
"year": "number or null",
|
|
|
|
|
|
|
| 27 |
"country": "string or null",
|
| 28 |
"format": "string or null (e.g., LP, 12\\", 7\\")",
|
| 29 |
"genre": "string or null",
|
| 30 |
"conditionEstimate": "string or null (NM/VG+/VG/G)",
|
| 31 |
-
"pressingInfo": "string or null (matrix/runout details)",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
"confidence": "high|medium|low",
|
| 33 |
"notes": "array of strings with additional observations"
|
| 34 |
}
|
| 35 |
|
| 36 |
-
Be precise. Only include info you can clearly read
|
| 37 |
},
|
| 38 |
{
|
| 39 |
role: 'user',
|
| 40 |
content: [
|
| 41 |
{
|
| 42 |
type: 'text',
|
| 43 |
-
text: 'Analyze these record photos. Identify the artist, title, catalogue number, label, year, and
|
| 44 |
},
|
| 45 |
...base64Images.map(base64 => ({
|
| 46 |
type: 'image_url',
|
|
@@ -63,7 +98,7 @@ Be precise. Only include info you can clearly read from the images. If text is b
|
|
| 63 |
body: JSON.stringify({
|
| 64 |
model: this.model,
|
| 65 |
messages: messages,
|
| 66 |
-
max_tokens:
|
| 67 |
temperature: 0.2
|
| 68 |
})
|
| 69 |
});
|
|
@@ -76,4 +111,17 @@ Be precise. Only include info you can clearly read from the images. If text is b
|
|
| 76 |
const data = await response.json();
|
| 77 |
const content = data.choices[0].message.content;
|
| 78 |
// Extract JSON from potential markdown code blocks
|
| 79 |
-
const jsonMatch = content.match(/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
class EnhancedOCRService {
|
| 3 |
constructor() {
|
| 4 |
this.apiKey = localStorage.getItem('openai_api_key');
|
|
|
|
| 17 |
const messages = [
|
| 18 |
{
|
| 19 |
role: 'system',
|
| 20 |
+
content: `You are a vinyl record identification expert with advanced OCR capabilities specializing in pressing identification. Analyze record images and extract all visible information with special attention to first press vs reissue identification.
|
| 21 |
+
|
| 22 |
+
CRITICAL - Pressing Identification Rules:
|
| 23 |
+
1. DEADWAX/MATRIX ANALYSIS IS ESSENTIAL - Look for:
|
| 24 |
+
- Hand-etched vs machine-stamped matrix numbers (hand-etched often indicates early pressings)
|
| 25 |
+
- Plant identifiers: "STERLING", "RL", "PORKY", "TML", "EMI", "CBS"
|
| 26 |
+
- Mastering engineer initials or signatures
|
| 27 |
+
- "A1", "B1" stampings indicate first stamper/cut
|
| 28 |
+
- "-" or "/" separators in matrix numbers
|
| 29 |
+
- Additional letters after main catalog number (e.g., "-A", "/1")
|
| 30 |
+
|
| 31 |
+
2. LABEL ANALYSIS for pressing identification:
|
| 32 |
+
- Label design variations (logo style, color shades, rim text)
|
| 33 |
+
- Address changes on labels (indicate different pressing periods)
|
| 34 |
+
- "Made in..." country variations
|
| 35 |
+
- Stereo/mono indicators and their placement
|
| 36 |
+
- Copyright text differences
|
| 37 |
+
|
| 38 |
+
3. SLEEVE/COVER indicators:
|
| 39 |
+
- Barcode presence = likely 1980s+ reissue (originals often lack barcodes)
|
| 40 |
+
- Price codes (UK: K/T/S prefixes, US: $ prices)
|
| 41 |
+
- Laminated vs non-laminated sleeves
|
| 42 |
+
- "Digital Remaster" or "180g" stickers = modern reissue
|
| 43 |
+
|
| 44 |
+
4. YEAR vs ORIGINAL YEAR distinction:
|
| 45 |
+
- Sleeve may show original release year
|
| 46 |
+
- Label/barcode may reveal actual pressing year
|
| 47 |
+
- Catalog number patterns indicate era
|
| 48 |
+
|
| 49 |
Return ONLY a JSON object with this exact structure:
|
| 50 |
{
|
| 51 |
"artist": "string or null",
|
| 52 |
"title": "string or null",
|
| 53 |
"catalogueNumber": "string or null",
|
| 54 |
"label": "string or null",
|
| 55 |
+
"year": "number or null (the pressing/year shown on this copy)",
|
| 56 |
+
"originalYear": "number or null (if different from year, the original release year)",
|
| 57 |
+
"reissueYear": "number or null (if this is a reissue, when it was reissued)",
|
| 58 |
"country": "string or null",
|
| 59 |
"format": "string or null (e.g., LP, 12\\", 7\\")",
|
| 60 |
"genre": "string or null",
|
| 61 |
"conditionEstimate": "string or null (NM/VG+/VG/G)",
|
| 62 |
+
"pressingInfo": "string or null (full matrix/runout details as found)",
|
| 63 |
+
"isFirstPress": "boolean or null (true if evidence suggests first pressing)",
|
| 64 |
+
"pressingType": "string or null ('first_press', 'repress', 'reissue', 'unknown')",
|
| 65 |
+
"pressingConfidence": "string ('high', 'medium', 'low' - how confident you are about pressing identification)",
|
| 66 |
+
"pressingEvidence": "array of strings (specific visual evidence for pressing determination)",
|
| 67 |
"confidence": "high|medium|low",
|
| 68 |
"notes": "array of strings with additional observations"
|
| 69 |
}
|
| 70 |
|
| 71 |
+
Be precise. Only include info you can clearly read. For pressing identification, be conservative - only mark as first press if you see strong evidence (A1/B1 stampers, specific plant codes matching known first presses, etc.).`
|
| 72 |
},
|
| 73 |
{
|
| 74 |
role: 'user',
|
| 75 |
content: [
|
| 76 |
{
|
| 77 |
type: 'text',
|
| 78 |
+
text: 'Analyze these record photos. Identify the artist, title, catalogue number, label, year, and CRITICALLY: examine the deadwax/matrix area and labels closely to determine if this is a first pressing, repress, or reissue. Report any matrix numbers, plant codes, or label variations you can see.'
|
| 79 |
},
|
| 80 |
...base64Images.map(base64 => ({
|
| 81 |
type: 'image_url',
|
|
|
|
| 98 |
body: JSON.stringify({
|
| 99 |
model: this.model,
|
| 100 |
messages: messages,
|
| 101 |
+
max_tokens: 2000,
|
| 102 |
temperature: 0.2
|
| 103 |
})
|
| 104 |
});
|
|
|
|
| 111 |
const data = await response.json();
|
| 112 |
const content = data.choices[0].message.content;
|
| 113 |
// Extract JSON from potential markdown code blocks
|
| 114 |
+
const jsonMatch = content.match(/```json\s*([\s\S]*?)\s*```|([\s\S]*)/);
|
| 115 |
+
const jsonStr = jsonMatch ? (jsonMatch[1] || jsonMatch[2]) : content;
|
| 116 |
+
|
| 117 |
+
try {
|
| 118 |
+
return JSON.parse(jsonStr.trim());
|
| 119 |
+
} catch (e) {
|
| 120 |
+
console.error('Failed to parse OCR response:', content);
|
| 121 |
+
throw new Error('Failed to parse record data');
|
| 122 |
+
}
|
| 123 |
+
} catch (error) {
|
| 124 |
+
console.error('OCR Analysis Error:', error);
|
| 125 |
+
throw error;
|
| 126 |
+
}
|
| 127 |
+
}
|
components/ocr-service.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
class OCRService {
|
| 2 |
constructor() {
|
| 3 |
this.apiKey = localStorage.getItem('openai_api_key');
|
|
@@ -16,31 +17,65 @@ class OCRService {
|
|
| 16 |
const messages = [
|
| 17 |
{
|
| 18 |
role: 'system',
|
| 19 |
-
content: `You are a vinyl record identification expert. Analyze record images and extract all visible information.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
Return ONLY a JSON object with this exact structure:
|
| 21 |
{
|
| 22 |
"artist": "string or null",
|
| 23 |
"title": "string or null",
|
| 24 |
"catalogueNumber": "string or null",
|
| 25 |
"label": "string or null",
|
| 26 |
-
"year": "number or null",
|
|
|
|
|
|
|
| 27 |
"country": "string or null",
|
| 28 |
"format": "string or null (e.g., LP, 12\\", 7\\")",
|
| 29 |
"genre": "string or null",
|
| 30 |
"conditionEstimate": "string or null (NM/VG+/VG/G)",
|
| 31 |
-
"pressingInfo": "string or null (matrix/runout details)",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
"confidence": "high|medium|low",
|
| 33 |
"notes": "array of strings with additional observations"
|
| 34 |
}
|
| 35 |
|
| 36 |
-
Be precise. Only include info you can clearly read
|
| 37 |
},
|
| 38 |
{
|
| 39 |
role: 'user',
|
| 40 |
content: [
|
| 41 |
{
|
| 42 |
type: 'text',
|
| 43 |
-
text: 'Analyze these record photos. Identify the artist, title, catalogue number, label, year, and
|
| 44 |
},
|
| 45 |
...base64Images.map(base64 => ({
|
| 46 |
type: 'image_url',
|
|
@@ -63,7 +98,7 @@ Be precise. Only include info you can clearly read from the images. If text is b
|
|
| 63 |
body: JSON.stringify({
|
| 64 |
model: this.model,
|
| 65 |
messages: messages,
|
| 66 |
-
max_tokens:
|
| 67 |
temperature: 0.2
|
| 68 |
})
|
| 69 |
});
|
|
@@ -90,7 +125,7 @@ Be precise. Only include info you can clearly read from the images. If text is b
|
|
| 90 |
throw error;
|
| 91 |
}
|
| 92 |
}
|
| 93 |
-
|
| 94 |
return new Promise((resolve, reject) => {
|
| 95 |
const reader = new FileReader();
|
| 96 |
reader.onload = () => {
|
|
|
|
| 1 |
+
|
| 2 |
class OCRService {
|
| 3 |
constructor() {
|
| 4 |
this.apiKey = localStorage.getItem('openai_api_key');
|
|
|
|
| 17 |
const messages = [
|
| 18 |
{
|
| 19 |
role: 'system',
|
| 20 |
+
content: `You are a vinyl record identification expert specializing in pressing identification. Analyze record images and extract all visible information with special attention to first press vs reissue identification.
|
| 21 |
+
|
| 22 |
+
CRITICAL - Pressing Identification Rules:
|
| 23 |
+
1. DEADWAX/MATRIX ANALYSIS IS ESSENTIAL - Look for:
|
| 24 |
+
- Hand-etched vs machine-stamped matrix numbers (hand-etched often indicates early pressings)
|
| 25 |
+
- Plant identifiers: "STERLING", "RL", "PORKY", "TML", "EMI", "CBS"
|
| 26 |
+
- Mastering engineer initials or signatures
|
| 27 |
+
- "A1", "B1" stampings indicate first stamper/cut
|
| 28 |
+
- "-" or "/" separators in matrix numbers
|
| 29 |
+
- Additional letters after main catalog number (e.g., "-A", "/1")
|
| 30 |
+
|
| 31 |
+
2. LABEL ANALYSIS for pressing identification:
|
| 32 |
+
- Label design variations (logo style, color shades, rim text)
|
| 33 |
+
- Address changes on labels (indicate different pressing periods)
|
| 34 |
+
- "Made in..." country variations
|
| 35 |
+
- Stereo/mono indicators and their placement
|
| 36 |
+
- Copyright text differences
|
| 37 |
+
|
| 38 |
+
3. SLEEVE/COVER indicators:
|
| 39 |
+
- Barcode presence = likely 1980s+ reissue (originals often lack barcodes)
|
| 40 |
+
- Price codes (UK: K/T/S prefixes, US: $ prices)
|
| 41 |
+
- Laminated vs non-laminated sleeves
|
| 42 |
+
- "Digital Remaster" or "180g" stickers = modern reissue
|
| 43 |
+
|
| 44 |
+
4. YEAR vs ORIGINAL YEAR distinction:
|
| 45 |
+
- Sleeve may show original release year
|
| 46 |
+
- Label/barcode may reveal actual pressing year
|
| 47 |
+
- Catalog number patterns indicate era
|
| 48 |
+
|
| 49 |
Return ONLY a JSON object with this exact structure:
|
| 50 |
{
|
| 51 |
"artist": "string or null",
|
| 52 |
"title": "string or null",
|
| 53 |
"catalogueNumber": "string or null",
|
| 54 |
"label": "string or null",
|
| 55 |
+
"year": "number or null (the pressing/year shown on this copy)",
|
| 56 |
+
"originalYear": "number or null (if different from year, the original release year)",
|
| 57 |
+
"reissueYear": "number or null (if this is a reissue, when it was reissued)",
|
| 58 |
"country": "string or null",
|
| 59 |
"format": "string or null (e.g., LP, 12\\", 7\\")",
|
| 60 |
"genre": "string or null",
|
| 61 |
"conditionEstimate": "string or null (NM/VG+/VG/G)",
|
| 62 |
+
"pressingInfo": "string or null (full matrix/runout details as found)",
|
| 63 |
+
"isFirstPress": "boolean or null (true if evidence suggests first pressing)",
|
| 64 |
+
"pressingType": "string or null ('first_press', 'repress', 'reissue', 'unknown')",
|
| 65 |
+
"pressingConfidence": "string ('high', 'medium', 'low' - how confident you are about pressing identification)",
|
| 66 |
+
"pressingEvidence": "array of strings (specific visual evidence for pressing determination)",
|
| 67 |
"confidence": "high|medium|low",
|
| 68 |
"notes": "array of strings with additional observations"
|
| 69 |
}
|
| 70 |
|
| 71 |
+
Be precise. Only include info you can clearly read. For pressing identification, be conservative - only mark as first press if you see strong evidence (A1/B1 stampers, specific plant codes matching known first presses, etc.).`
|
| 72 |
},
|
| 73 |
{
|
| 74 |
role: 'user',
|
| 75 |
content: [
|
| 76 |
{
|
| 77 |
type: 'text',
|
| 78 |
+
text: 'Analyze these record photos. Identify the artist, title, catalogue number, label, year, and CRITICALLY: examine the deadwax/matrix area and labels closely to determine if this is a first pressing, repress, or reissue. Report any matrix numbers, plant codes, or label variations you can see.'
|
| 79 |
},
|
| 80 |
...base64Images.map(base64 => ({
|
| 81 |
type: 'image_url',
|
|
|
|
| 98 |
body: JSON.stringify({
|
| 99 |
model: this.model,
|
| 100 |
messages: messages,
|
| 101 |
+
max_tokens: 2000,
|
| 102 |
temperature: 0.2
|
| 103 |
})
|
| 104 |
});
|
|
|
|
| 125 |
throw error;
|
| 126 |
}
|
| 127 |
}
|
| 128 |
+
async fileToBase64(file) {
|
| 129 |
return new Promise((resolve, reject) => {
|
| 130 |
const reader = new FileReader();
|
| 131 |
reader.onload = () => {
|
script.js
CHANGED
|
@@ -186,7 +186,7 @@ async function identifyPhotoType(imageFile, service) {
|
|
| 186 |
- spine: Spine with text
|
| 187 |
- label_a: Side A label
|
| 188 |
- label_b: Side B label
|
| 189 |
-
- deadwax: Deadwax/runout grooves showing matrix numbers
|
| 190 |
- inner: Inner sleeve
|
| 191 |
- insert: Insert or poster
|
| 192 |
- hype: Hype sticker on shrink
|
|
@@ -194,6 +194,8 @@ async function identifyPhotoType(imageFile, service) {
|
|
| 194 |
- corners: Close-up of sleeve corners/edges
|
| 195 |
- barcode: Barcode area
|
| 196 |
|
|
|
|
|
|
|
| 197 |
Return ONLY a JSON object: {"type": "one_of_the_above", "confidence": "high|medium|low"}`
|
| 198 |
},
|
| 199 |
{
|
|
@@ -462,13 +464,18 @@ function populateFieldsFromOCR(data) {
|
|
| 462 |
if (data.pressingInfo) window.detectedPressingInfo = data.pressingInfo;
|
| 463 |
if (data.conditionEstimate) window.detectedCondition = data.conditionEstimate;
|
| 464 |
if (data.notes) window.detectedNotes = data.notes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
|
| 466 |
// Update UI to show detected info
|
| 467 |
updateDetectedInfoPanel(data);
|
| 468 |
|
| 469 |
// Scroll to quick details section so user can verify
|
| 470 |
if (populatedCount > 0) {
|
| 471 |
-
const quickDetailsSection = document.querySelector('.md\\
|
| 472 |
if (quickDetailsSection) {
|
| 473 |
setTimeout(() => {
|
| 474 |
quickDetailsSection.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
@@ -476,7 +483,6 @@ function populateFieldsFromOCR(data) {
|
|
| 476 |
}
|
| 477 |
}
|
| 478 |
}
|
| 479 |
-
|
| 480 |
// Track user modifications to fields
|
| 481 |
document.addEventListener('DOMContentLoaded', () => {
|
| 482 |
['artistInput', 'titleInput', 'catInput', 'yearInput'].forEach(id => {
|
|
@@ -511,6 +517,25 @@ function updateDetectedInfoPanel(data) {
|
|
| 511 |
if (data.genre && data.genre !== 'null') infoItems.push(`<span class="text-green-400">Genre:</span> ${data.genre}`);
|
| 512 |
if (data.conditionEstimate && data.conditionEstimate !== 'null') infoItems.push(`<span class="text-green-400">Est. Condition:</span> ${data.conditionEstimate}`);
|
| 513 |
if (data.pressingInfo && data.pressingInfo !== 'null') infoItems.push(`<span class="text-green-400">Matrix:</span> ${data.pressingInfo}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 514 |
|
| 515 |
const confidenceColor = data.confidence === 'high' ? 'text-green-400' :
|
| 516 |
data.confidence === 'medium' ? 'text-yellow-400' : 'text-orange-400';
|
|
|
|
| 186 |
- spine: Spine with text
|
| 187 |
- label_a: Side A label
|
| 188 |
- label_b: Side B label
|
| 189 |
+
- deadwax: Deadwax/runout grooves showing matrix numbers (critical for pressing identification)
|
| 190 |
- inner: Inner sleeve
|
| 191 |
- insert: Insert or poster
|
| 192 |
- hype: Hype sticker on shrink
|
|
|
|
| 194 |
- corners: Close-up of sleeve corners/edges
|
| 195 |
- barcode: Barcode area
|
| 196 |
|
| 197 |
+
For deadwax photos, look for: hand-etched matrix numbers, stamped codes, "STERLING", "MASTERED BY", plant symbols, or any alphanumeric codes in the runout groove area.
|
| 198 |
+
|
| 199 |
Return ONLY a JSON object: {"type": "one_of_the_above", "confidence": "high|medium|low"}`
|
| 200 |
},
|
| 201 |
{
|
|
|
|
| 464 |
if (data.pressingInfo) window.detectedPressingInfo = data.pressingInfo;
|
| 465 |
if (data.conditionEstimate) window.detectedCondition = data.conditionEstimate;
|
| 466 |
if (data.notes) window.detectedNotes = data.notes;
|
| 467 |
+
// Store pressing identification data
|
| 468 |
+
if (data.pressingType) window.detectedPressingType = data.pressingType;
|
| 469 |
+
if (data.isFirstPress) window.detectedIsFirstPress = data.isFirstPress;
|
| 470 |
+
if (data.reissueYear) window.detectedReissueYear = data.reissueYear;
|
| 471 |
+
if (data.originalYear) window.detectedOriginalYear = data.originalYear;
|
| 472 |
|
| 473 |
// Update UI to show detected info
|
| 474 |
updateDetectedInfoPanel(data);
|
| 475 |
|
| 476 |
// Scroll to quick details section so user can verify
|
| 477 |
if (populatedCount > 0) {
|
| 478 |
+
const quickDetailsSection = document.querySelector('.md\\:w-80');
|
| 479 |
if (quickDetailsSection) {
|
| 480 |
setTimeout(() => {
|
| 481 |
quickDetailsSection.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
|
|
| 483 |
}
|
| 484 |
}
|
| 485 |
}
|
|
|
|
| 486 |
// Track user modifications to fields
|
| 487 |
document.addEventListener('DOMContentLoaded', () => {
|
| 488 |
['artistInput', 'titleInput', 'catInput', 'yearInput'].forEach(id => {
|
|
|
|
| 517 |
if (data.genre && data.genre !== 'null') infoItems.push(`<span class="text-green-400">Genre:</span> ${data.genre}`);
|
| 518 |
if (data.conditionEstimate && data.conditionEstimate !== 'null') infoItems.push(`<span class="text-green-400">Est. Condition:</span> ${data.conditionEstimate}`);
|
| 519 |
if (data.pressingInfo && data.pressingInfo !== 'null') infoItems.push(`<span class="text-green-400">Matrix:</span> ${data.pressingInfo}`);
|
| 520 |
+
|
| 521 |
+
// Add pressing identification info
|
| 522 |
+
if (data.isFirstPress !== undefined) {
|
| 523 |
+
const pressBadge = data.isFirstPress
|
| 524 |
+
? '<span class="px-2 py-0.5 bg-purple-500/20 text-purple-400 rounded text-xs font-medium">FIRST PRESS</span>'
|
| 525 |
+
: data.pressingType === 'reissue'
|
| 526 |
+
? '<span class="px-2 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs font-medium">REISSUE</span>'
|
| 527 |
+
: data.pressingType === 'repress'
|
| 528 |
+
? '<span class="px-2 py-0.5 bg-orange-500/20 text-orange-400 rounded text-xs font-medium">REPRESS</span>'
|
| 529 |
+
: '';
|
| 530 |
+
if (pressBadge) infoItems.push(pressBadge);
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
if (data.originalYear && data.originalYear !== data.year) {
|
| 534 |
+
infoItems.push(`<span class="text-purple-400">Original Year:</span> ${data.originalYear}`);
|
| 535 |
+
}
|
| 536 |
+
if (data.reissueYear && data.reissueYear !== data.year) {
|
| 537 |
+
infoItems.push(`<span class="text-blue-400">Reissue Year:</span> ${data.reissueYear}`);
|
| 538 |
+
}
|
| 539 |
|
| 540 |
const confidenceColor = data.confidence === 'high' ? 'text-green-400' :
|
| 541 |
data.confidence === 'medium' ? 'text-yellow-400' : 'text-orange-400';
|