Browse Source

Various changes. Going to make this a project.

Brennen Bearnes 10 years ago
parent
commit
60837a26d3
3 changed files with 22 additions and 11 deletions
  1. 12
    7
      Rhythmbox/Playlist.pm
  2. 8
    3
      playlist.pl
  3. 2
    1
      t/playlist.t

+ 12
- 7
Rhythmbox/Playlist.pm View File

@@ -32,6 +32,18 @@ sub lists {
32 32
   return sort grep { m/$pattern/ } @names;
33 33
 }
34 34
 
35
+sub songs_decoded {
36
+  my $self = shift;
37
+  my @songs = $self->songs(@_);
38
+
39
+  foreach my $song (@songs) {
40
+    $song =~ s{ (?:file|smb|ssh|sftp) :// (.*) }{$1}x;
41
+    $song = uri_unescape($song);
42
+  }
43
+
44
+  return @songs;
45
+}
46
+
35 47
 sub songs {
36 48
   my $self = shift;
37 49
   my ($pattern) = @_;
@@ -48,13 +60,6 @@ sub songs {
48 60
 
49 61
   @songs = sort grep { m/$self->{song_pattern}/ } @songs;
50 62
 
51
-  unless ($self->{raw_uri}) { 
52
-    foreach my $song (@songs) {
53
-      $song =~ s{ (?:file|smb|ssh|sftp) :// (.*) }{$1}x;
54
-      $song = uri_unescape($song);
55
-    }
56
-  }
57
-
58 63
   return @songs;
59 64
 }
60 65
 

+ 8
- 3
playlist.pl View File

@@ -67,14 +67,15 @@ my %options = (
67 67
   'song_pattern' => 'file://',
68 68
 );
69 69
 
70
-my $list = undef;
70
+my $list      = undef;
71
+my $raw_uri   = undef;
71 72
 
72 73
 GetOptions(
73
-  'raw-uri'        => \$options{'raw_uri'},
74 74
   'file=s'         => \$options{'file'},
75 75
   'song-pattern=s' => \$options{'song_pattern'},
76 76
 
77 77
   'list'           => \$list,
78
+  'raw-uri'        => \$raw_uri,
78 79
 );
79 80
 
80 81
 my $lists = Rhythmbox::Playlist->new(%options);
@@ -87,6 +88,10 @@ for my $pattern (@patterns) {
87 88
   if ($list) {
88 89
     print join "\n", $lists->lists($pattern);
89 90
   } else {
90
-    print join "\n", $lists->songs($pattern);
91
+    if ($raw_uri) {
92
+      print join "\n", $lists->songs($pattern);
93
+    } else {
94
+      print join "\n", $lists->songs_decoded($pattern);
95
+    }
91 96
   }
92 97
 }

+ 2
- 1
t/playlist.t View File

@@ -1,6 +1,7 @@
1 1
 use strict;
2 2
 use warnings;
3 3
 
4
-use Test::Simple tests => 1;
4
+use lib '..';
5 5
 
6
+use Test::Simple tests => 1;
6 7
 use Rhythmbox::Playlist;

Loading…
Cancel
Save