Yesterday I published an article about the Laser Disc collection that I’ve gathered over the last few years, and I wanted to share a few thoughts about how I got to that page.
In order to keep track of my collection, I used the services of the LaserDisc Database site (which also has HD-DVD titles, but that will be a different article at some point)
Update
I used the approach explained below to show my collection of HD-DVDs.
You can see the
post here.
1. Getting the data from LDDb
To get the data, I just logged in, went to my collection, clicked on “Show Export controls” and downloaded the ASCII version. It seems there’s currently a bug in their website, as the ASCII version is actually a CSV file, delimited by semicolons (;), and the CSV file is a tab-delimited plain text file.
Either way, I went with the semicolon-separated file, as it’s easier to process using PHP. Its structure is also simple and easy to understand, so we should be able to easily get the information we want.
1
2
3
4
5
|
ID;Format;Reference;Title;Release;Video;Specs;Country;UPC;Condition;Notes;Date
07154;ld;42785;12 Monkeys (1995);1996-07-16;NTSC;LBX/SRD/+CAV;USA;096894278564;;;
19083;ld;EE 1041;Abyss, The: Special Edition (1989);1995;PAL;LBX/SRD;United Kingdom;5027522010411;;;
18757;ld;EE 1089;Aliens: Special Edition (1986);1996;PAL;LBX/SRD;United Kingdom;5027522010893;;;
.....................................
|
2. Parsing the LDDb data
Parsing the data was done with PHP, because it’s easy to run and I already know, and I’ve already written something similar for my IMDb ratings script, so most code will be reused.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
while (($line = fgets($handle)) !== false) {
if($index > 0) { // skipping heading line
sleep(2);
$data = explode(';', $line);
$allmoviesdata[$index]['title'] = $data['3'];
$allmoviesdata[$index]['id'] = $data['0'];
$allmoviesdata[$index]['reference'] = $data['2'];
$allmoviesdata[$index]['release_date'] = $data['4'];
$allmoviesdata[$index]['video'] = $data['5'];
$allmoviesdata[$index]['specs'] = $data['6'];
$allmoviesdata[$index]['country'] = $data['7'];
$allmoviesdata[$index]['barcode'] = $data['8'];
$url = "https://www.lddb.com/laserdisc/".$data['0']."/".str_replace(' ', '-', $data['2'])."/".str_replace(' ', '-', $data['3'])."";
}
}
|
I’ve also written a small scraper of the LDDb detail page to get the IMDb url, but this is not relevant here, but that’s why there’s a sleep(2)
timer in the code, to scrape a page from LDDb every two seconds, to avoid overloading their servers and/or get banned.
I also needed it to take the laser disc images, because I was tired (and dumb) and didn’t see the pattern behind their images system, where they have folders for each hundred photos, based on their ID
1
|
18762 => https://www.lddb.com/cover/ld/18701-18800/18762.jpg
|
The next part is a small trick, because I know I won’t update the Laser Disc page too soon, so I didn’t have to make something that’s easily scriptable, therefore, I decided to add the entire variable to a new array and output it as a JSON string.
1
2
3
|
$alldata = array();
$alldata['lds'] = $allmoviesdata;
echo json_encode($alldata);
|
I chose JSON for this, because I was able to quickly convert it to YAML using this tool, and added the result to the article’s front matter. This part is manual, using copy/paste (hey, some people are writing doctorate thesis using only copy/paste)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
lds:
'01':
title: 12 Monkeys (1995)
id: '07154'
reference: '42785'
release_date: '1996-07-16'
video: NTSC
specs: LBX/SRD/+CAV
country: USA
barcode: '096894278564'
imdbid: tt0114746
photo:
- https://www.lddb.com/cover/ld/07101-07200/07154.jpg
- https://www.lddb.com/cover/ld/07101-07200/07154_back.jpg
|
3. Displaying the data
To display the data, I simply use the shortcode {{< laserdiscs >}}, which uses data from the front matter to render some nice blocks of information.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
{{ with $.Page.Params.lds }}
<section class="laserdiscs-collection">
{{ range $.Page.Params.lds }}
{{ $parent := . }}
<hr>
<div class="row">
<div class="archive-image col-md-4 col-sm-5">
{{ if isset $parent "photo" }}
{{ range first 1 .photo }}
<a class="switch-image" rel="lightbox" href="javascript:void(0)" data-link="/uploads/2022/laserdiscs/{{ $parent.id }}.jpg">
<img src="/uploads/2022/laserdiscs/{{ $parent.id }}-400x400.jpg" alt="{{ $parent.title }}">
<!-- <img src="{{ . }}" alt="> -->
</a>
{{ end }}
{{ range after 1 .photo }}
<a class="switch-image" rel="lightbox" href="javascript:void(0)" data-link="/uploads/2022/laserdiscs/{{ $parent.id }}_back.jpg">
<img src="/uploads/2022/laserdiscs/{{ $parent.id }}_back-400x400.jpg" alt="{{ $parent.title }}">
<!-- <img src="{{ . }}" alt="{{ $parent.title }}"> -->
</a>
{{ end }}
{{ else }}
<span class="no-image">no image</span>
{{ end }}
</div>
<div class="post-excerpt col-md-8 col-sm-7">
<h3>
{{ if in .title ", The" }}
<span class="text-muted">The </span>{{ replace .title ", The" "" }}
{{ else }}
{{ .title }}
{{ end }}
</h3>
<table>
<tr>
<th>Release Date</th>
<td>{{ .release_date }}</td>
</tr>
<tr>
<th>Format</th>
<td>{{ .video }} • {{ .specs }}</td>
</tr>
<tr>
<th>Barcode</th>
<td>{{ with .barcode}}{{ . }}{{ else }}n/a{{ end }}</td>
</tr>
<tr>
<td><a target="_blank" href="https://www.lddb.com/laserdisc/{{ .id }}/{{ .reference | urlize }}/{{ .title | urlize }}">LaserDisc Database</a></td>
<td><a target="_blank" href="https://www.imdb.com/title/{{ .imdbid }}/">Internet Movie Database</a></td>
</tr>
</table>
</div>
</div>
{{ end }}
</section>
{{ end }}
|
I’ve also added a quick shortcode that outputs small images, so I can easily download them, as LDDb is displaying them with a watermark if you’re not logged in, and I didn’t want to hotlink their images, so I’m serving them from my server.
That’s pretty much it. I’m planning into writing a similar post regarding HD-DVD titles I own, but I need to get my library together. If you have suggestions about how this post can be improved, let me know.