Thread Anfänger (9 answers)
Opened by Friedel at 2014-03-15 18:55

GwenDragon
 2014-03-16 09:27
#174157 #174157
User since
2005-01-17
14746 Artikel
Admin1
[Homepage]
user image
Erzeugt eine Playlist für Windows Media Player:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
use strict; 
use warnings;

use File::Find;
use Cwd;
use Getopt::Long;

sub gen_playlist {
   my @files = @_;
   
   my $num_files = @files;
   my $plist;
   
   return if not @files;   
   
   $plist = <<XML;
<?wpl version="1.0"?>
<smil>
    <head>
        <meta name="Generator" content="Microsoft Windows Media Player -- 11.0.5721.5145"/>
        <meta name="ItemCount" content="$num_files"/>
        <author/>
        <title>Playlist generated by Perl</title>
    </head>
    <body>
        <seq>
XML
    
        for my $file (@files) {
           $plist .= qq(            <media src="$file"/>\n);
    }   
        
        $plist .= <<XML;
        </seq>
    </body>
</smil>
XML

        return $plist;
}

sub help {
        print <<'TXT';

findplay VERZECIHNIS DATEITYP

  Findet Musikdateien und erzeugt Windows Media Player Playlist


  findplay VERZECIHNIS DATEITYP
  
  Aufrufbeispiel: 
    
  * Suche mit Angabe von Verzeichnis und typ
          
        findplay -dir "C:\Users\Test\Music" -type=.mp3
          
  * Suche im aktuellen Verzeichnis mit Typ .mp3
        
        findplay

TXT
        exit 255;
}


# -----------------------------
my $dir = cwd();
my $file_type = '.mp3';
my $verbose = 0;
my $result = GetOptions (
        "dir=s" => \$dir, 
        "type=s"  => \$file_type,
        "help|?" => \&help
);  

my @files = <*$file_type> or die qq(Fehler: Keine Dateien mit Endung $file_type in "$dir"\n);

print gen_playlist(@files);

__END__

=pod

* commandline 

wmplayer /Playlist NameOfPlayList

* WPL PlayList format

<?wpl version="1.0"?>
<smil>
    <head>
        <meta name="Generator" content="Microsoft Windows Media Player -- 11.0.5721.5145"/>
        <meta name="AverageRating" content="33"/>
        <meta name="TotalDuration" content="1102"/>
        <meta name="ItemCount" content="3"/>
        <author/>
        <title>Bach Organ Works</title>
    </head>
    <body>
        <seq>
            <media src="\\server\vol\music\Classical\Bach\OrganWorks\cd03\track01.mp3"/>
            <media src="\\server\vol\music\Classical\Bach\OrganWorks\cd03\track02.mp3"/>
            <media src="SR15.mp3" tid="{35B39D45-94D8-40E1-8FC2-9F6714191E47}"/>
        </seq>
    </body>
</smil>

=cut

View full thread Anfänger