- Timestamp:
- Jan 17, 2015, 5:06:09 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GenPlaylist.pas
r3 r4 2 2 3 3 uses 4 SysUtils ;4 SysUtils, Classes; 5 5 6 6 type … … 17 17 end; 18 18 19 procedure FileSearch( const PathName: string; ExtList: array of string; BasePath : string) ;19 procedure FileSearch(Files: TStringList; const PathName: string; ExtList: array of string; BasePath : string) ; 20 20 var 21 21 Rec: TSearchRec; … … 31 31 if Rec.Name = '..' then continue 32 32 else if Rec.Name = '.' then continue 33 else if (Rec.Attr and faDirectory) > 0 then FileSearch( Path + Rec.Name, ExtList, BasePAth)33 else if (Rec.Attr and faDirectory) > 0 then FileSearch(Files, Path + Rec.Name, ExtList, BasePAth) 34 34 else if InStrArray(LowerCase(ExtractFileExt(Rec.Name)), ExtList) then begin 35 35 //WriteLn('File: ' + Rec.Name); 36 36 ItemFileName := ParamStr(2) + Copy(Path + Rec.Name, Length(BasePath) + 2, High(Integer)); 37 37 //ItemFileName := StringReplace(ItemFileName, ' ', '%20', [rfReplaceAll]); 38 WriteLn(ItemFileName);38 Files.Add(ItemFileName); 39 39 end; 40 40 until FindNext(Rec) <> 0; … … 44 44 end; 45 45 46 procedure GenerateM3U; 47 var 48 Files: TStringList; 49 I: Integer; 46 50 begin 51 Files := TStringList.Create; 47 52 WriteLn('#EXTM3U'); 48 FileSearch(ParamStr(1), ['.mp3', '.ac3', '.flac', '.it', '.m4a', '.wma', '.s3m', '.ogg'], ParamStr(1)); 53 FileSearch(Files, ParamStr(1), ['.mp3', '.ac3', '.flac', '.it', '.m4a', '.wma', '.s3m', '.ogg'], ParamStr(1)); 54 for I := 0 to Files.Count - 1 do 55 WriteLn(Files[I]); 56 Files.Free; 57 end; 58 59 procedure GenerateXSPF; 60 var 61 Files: TStringList; 62 I: Integer; 63 FileName: string; 64 begin 65 Files := TStringList.Create; 66 WriteLn('<?xml version="1.0" encoding="UTF-8"?>'); 67 WriteLn('<playlist version="1" xmlns="http://xspf.org/ns/0/">'); 68 WriteLn('<trackList>'); 69 FileSearch(Files, ParamStr(1), ['.mp3', '.ac3', '.flac', '.it', '.m4a', '.wma', '.s3m', '.ogg'], ParamStr(1)); 70 for I := 0 to Files.Count - 1 do begin 71 FileName := StringReplace(Files[I], '&', '&', [rfReplaceAll]); 72 WriteLn('<track>'); 73 WriteLn('<title>' + Copy(ExtractFileName(FileName), 1, Length(ExtractFileName(FileName)) - Length(ExtractFileExt(FileName))) + '</title>'); 74 WriteLn('<location>' + FileName + '</location>'); 75 WriteLn('<album>' + ExtractFileName(ExtractFileDir(FileName)) + '</album>'); 76 WriteLn('</track>'); 77 end; 78 WriteLn('</trackList>'); 79 WriteLn('</playlist>'); 80 Files.Free; 81 end; 82 83 begin 84 GenerateXSPF; 49 85 end.
Note:
See TracChangeset
for help on using the changeset viewer.