+
+ my @offsets = @{ $response->{'offsets'}};
+ foreach my $offset (@offsets) {
+ printf OUT "# %d\n", $offset;
+ }
+
+ # Locate the media that contains a disc with the discid we requested
+ # initially. The API may return multiple media associated with the
+ # release, including media with different discids
+ my @mediums = grep {
+ my @disks = @{ $_->{'discs'} };
+ grep { $_->{'id'} eq $discid } @disks;
+ } @{ $release->{'media'} };
+
+ if (not @mediums) {
+ # This release doesn't have a media with our requested dicsid
+ # Shouldn't happen (?), skip it
+ next;
+ }
+
+ # Only consider the first medium
+ my $medium = @mediums[0];
+ my @tracks = @{ $medium->{'tracks'} };
+
+ my $total_len = 0;