From dc9fbe99acb2f6f29924d961c4b94692b84d60a4 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 1 May 2012 19:11:40 -0500 Subject: currently playing songs don't have timestamps --- Changes | 1 + bin/lastfm_export | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index df06177..64db395 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for LastFM-Export {{$NEXT}} + - Make the update process not fail when a song is currently playing. 0.01 2012-03-19 - Initial release diff --git a/bin/lastfm_export b/bin/lastfm_export index eb721da..b40f7c7 100644 --- a/bin/lastfm_export +++ b/bin/lastfm_export @@ -58,13 +58,20 @@ my $count = 1; my $s = $exporter->tracks(from => $from); while (my $block = $s->next) { for my $item (@$block) { - $sth->execute( - $item->{artist}{'#text'}, - $item->{album}{'#text'}, - $item->{name}, - $item->{date}{uts}, - ); - $progress->update($count++) unless $quiet; + if ($item->{date}{uts}) { + $sth->execute( + $item->{artist}{'#text'}, + $item->{album}{'#text'}, + $item->{name}, + $item->{date}{uts}, + ); + $progress->update($count++) unless $quiet; + } + else { + $progress->message("skipping currently playing song: " + . "$item->{artist}{'#text'} - $item->{name}") + unless $quiet; + } } $dbh->commit; sleep 1; -- cgit v1.2.3-54-g00ecf