Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

* Added pattern functionality for M3U info lines. See 'm3ugen --help'

* Cleaned up the --help screen a bit.

git-svn-id: file:///var/lib/svn/m3ugen/trunk@9 1e1f2d8e-b8a0-4649-aeed-5658290dd61f
  • Loading branch information...
commit 808c9a5805dc02e895d6343868a9a9003a4d99b3 1 parent 391afa3
Alex Malinovich authored March 09, 2007

Showing 2 changed files with 31 additions and 7 deletions. Show diff stats Hide diff stats

  1. 7  debian/changelog
  2. 31  m3ugen
7  debian/changelog
... ...
@@ -1,3 +1,10 @@
  1
+m3ugen (0.13) unstable; urgency=low
  2
+
  3
+  * Added pattern functionality for M3U info lines. See 'm3ugen --help'
  4
+  * Cleaned up the --help screen a bit.
  5
+
  6
+ -- Alex Malinovich <demonbane@the-love-shack.net>  Fri,  9 Mar 2007 04:33:07 -0800
  7
+
1 8
 m3ugen (0.12) unstable; urgency=low
2 9
 
3 10
   * Improved UTF-8 support. All filehandles are now explicitly opened as UTF-8.
31  m3ugen
@@ -15,12 +15,8 @@
15 15
 # 	tags appropriately, however it has not been accepted into
16 16
 # 	upstream yet. Using the patch this version of m3ugen will
17 17
 # 	properly sort by disc number as well as album.
18  
-#
19  
-# TODO:	Make sure that all code is Unicode-friendly. Since OGG tags
20  
-# 	can be in Unicode the code should handle those strings
21  
-# 	appropriately.
22 18
 
23  
-$version="0.12";
  19
+$version="0.13";
24 20
 
25 21
 use Audio::File;
26 22
 use Cwd;
@@ -30,7 +26,7 @@ use File::Find;
30 26
 use Getopt::Mixed 1.006;
31 27
 use IO::Handle;
32 28
 
33  
-Getopt::Mixed::init("r recursive>r n no-path>n h help>h usage>h d debug>d a albums>a v version>v");
  29
+Getopt::Mixed::init("r recursive>r n no-path>n h help>h usage>h d debug>d a albums>a v version>v p=s pattern>p");
34 30
 $Getopt::Mixed::ignoreCase = 0;
35 31
 Getopt::Mixed::getOptions();
36 32
 
@@ -38,6 +34,9 @@ if ($opt_h) {
38 34
   print "Usage: m3ugen [OPTION]... SOURCE [M3UFILE]\n";
39 35
   print "Output an m3u playlist containing mp3, Ogg Vorbis, and FLAC files found in\n";
40 36
   print "SOURCE to M3UFILE if specified, STDOUT otherwise.\n\n";
  37
+  print "PATTERN specifies the pattern to use when writing the M3U info line using\n";
  38
+  print "the following variables: %a = artist, %t = track title, %n = track number\n";
  39
+  print "                         %b = album, %d = disc number [if available]\n\n";
41 40
   print "  -h, --help         display this screen and exit\n\n";
42 41
   print "  -r, --recursive    recursively search through directories\n";
43 42
   print "                     (default is specified directory ONLY)\n\n";
@@ -45,6 +44,8 @@ if ($opt_h) {
45 44
   print "                     (implies M3UFILE behavior and ignores M3UFILE if specified)\n\n";
46 45
   print "  -n, --no-path      print paths relative to SOURCE\n";
47 46
   print "                     (default is to print full path)\n\n";
  47
+  print "  -p PATTERN,        quoted pattern to use for printing title in M3UFILE\n";
  48
+  print "  --pattern=PATTERN  (Examples: '%n - %t' or '%a.%b.%t')\n\n";
48 49
   print "  -d, --debug        print debugging output to STDERR\n\n";
49 50
   print "  -v, --version      print version information and exit\n\n";
50 51
   exit 0;
@@ -151,7 +152,23 @@ foreach $filename (@files) {
151 152
   print ERROR "title = \"$title\"\n";
152 153
   print ERROR "length = \"$length\"\n";
153 154
 
154  
-  $m3ulines = "#EXTINF:".$length.",".$artist." - ".$title."\n";
  155
+  $m3ulines = "#EXTINF:".$length.","; #default info
  156
+  if ($opt_p) {
  157
+    my $formattedline = $opt_p;
  158
+
  159
+    # I'm sure there must be a better way to do this, but this'll
  160
+    # work for the time being.
  161
+    $formattedline =~ s/%a/$artist/g;
  162
+    $formattedline =~ s/%b/$album/g;
  163
+    $formattedline =~ s/%d/$disc/g;
  164
+    $formattedline =~ s/%n/$track/g;
  165
+    $formattedline =~ s/%t/$title/g;
  166
+    $m3ulines .= $formattedline;
  167
+  }else{
  168
+    $m3ulines .= $artist." - ".$title;
  169
+  }
  170
+  $m3ulines .= "\n";
  171
+
155 172
   if ($opt_n) {
156 173
     my $templine = ($filename ^ $workDir);
157 174
     # Remove any leading NULL characters. They cause problems in some

0 notes on commit 808c9a5

Please sign in to comment.
Something went wrong with that request. Please try again.