diff options
author | Rasmus Steinke <rasi@xssn.at> | 2017-08-19 04:58:10 +0200 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2017-08-19 04:58:10 +0200 |
commit | c4caa358ea381ceb07b44fcf0ccbb4b3df04e15d (patch) | |
tree | 807284659b7586ce6f4212dcb81a58e2ef818135 /clerk | |
parent | 57b358e082aaf0429619a967bc9e90862d3e5a41 (diff) | |
download | perl-app-clerk-c4caa358ea381ceb07b44fcf0ccbb4b3df04e15d.tar.gz perl-app-clerk-c4caa358ea381ceb07b44fcf0ccbb4b3df04e15d.tar.xz |
use timezone and properly reload playlist view
Diffstat (limited to 'clerk')
-rwxr-xr-x | clerk | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -21,7 +21,7 @@ use HTTP::Date; use IPC::Run qw( timeout start ); use List::Util qw(any); use Net::MPD; -use POSIX; +use POSIX qw(tzset); use autodie; my $self="$Bin/$Script"; @@ -274,20 +274,26 @@ sub do_action { $mpd->{socket}->close; if ($context eq "playlist") { if ($in eq "Save current Queue\n") { - my $now = time(); - my $filename = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($now)), "\n"; + tzset(); + my $filename = localtime(); $mpd->save($filename); } else { - my @action_items = ("Add\n", "Replace\n"); + my @action_items = ("Add\n", "Replace\n", "Delete\n"); $action = backend_call(\@action_items); if ($action eq "Replace\n") { $mpd->clear(); - } - chomp $in; - $mpd->load("$in"); - if ($action eq "Replace\n") { + chomp $in; + $mpd->load("$in"); $mpd->play(); } + elsif ($action eq "Add\n") { + chomp $in; + $mpd->load("$in"); + } + elsif ($action eq "Delete\n") { + chomp $in; + $mpd->rm("$in"); + } } } elsif ($context eq "tracks") { my @action_items = ("Add\n", "Replace\n"); @@ -310,10 +316,9 @@ sub do_action { } sub list_playlists { - my @playlists = $mpd->list_playlists(); - my $output = formatted_playlists(\@playlists); - for (;;) { + my @playlists = $mpd->list_playlists(); + my $output = formatted_playlists(\@playlists); my $out = backend_call($output); do_action($out, "playlist", "ignore"); } |