Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add add-album script for adding new albums
- Loading branch information
1 parent
f2846cf
commit e1dbe6e
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/perl | ||
|
||
# usage ./add-album.pl artist album hash | ||
|
||
use warnings; | ||
use strict; | ||
|
||
use Data::Dumper; | ||
use Storable; | ||
|
||
my $store = 'tracks.db'; | ||
|
||
my $artist = shift; | ||
my $album = shift; | ||
my $hash = shift; | ||
|
||
my $data = retrieve($store); | ||
|
||
print Dumper($data); | ||
|
||
if ($artist and $album and $hash) { | ||
|
||
print "adding $album by $artist with mb hash = $hash\n"; | ||
|
||
my $index; | ||
my $count = 1; | ||
|
||
# get the next free index | ||
until ($index) { | ||
$index = $count unless $data->{$count}; | ||
$count++; | ||
} | ||
|
||
$data->{$index}{hash} = $hash; | ||
$data->{$index}{artist} = $artist; | ||
$data->{$index}{name} = $album; | ||
|
||
store($data, $store) or die "Can't store data in $store\n"; | ||
|
||
} |