- Timestamp:
- Jan 13, 2016, 11:52:00 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GenPlaylist.pas
r5 r6 17 17 end; 18 18 19 procedure FileSearch(Files: TStringList; const PathName: string; ExtList: array of string ; BasePath : string);19 procedure FileSearch(Files: TStringList; const PathName: string; ExtList: array of string); 20 20 var 21 21 Rec: TSearchRec; 22 22 Path: string; 23 ItemFileName: string;24 23 begin 25 24 Path := IncludeTrailingPathDelimiter(PathName); … … 31 30 if Rec.Name = '..' then continue 32 31 else if Rec.Name = '.' then continue 33 else if (Rec.Attr and faDirectory) > 0 then FileSearch(Files, Path + Rec.Name, ExtList , BasePAth)32 else if (Rec.Attr and faDirectory) > 0 then FileSearch(Files, Path + Rec.Name, ExtList) 34 33 else if InStrArray(LowerCase(ExtractFileExt(Rec.Name)), ExtList) then begin 35 34 //WriteLn('File: ' + Rec.Name); 36 ItemFileName := ParamStr(2) + Copy(Path + Rec.Name, Length(BasePath) + 2, High(Integer)); 37 //ItemFileName := StringReplace(ItemFileName, ' ', '%20', [rfReplaceAll]); 38 Files.Add(ItemFileName); 35 Files.Add(Path + Rec.Name); 39 36 end; 40 37 until FindNext(Rec) <> 0; … … 51 48 Files := TStringList.Create; 52 49 WriteLn('#EXTM3U'); 53 FileSearch(Files, ParamStr(1), ['.mp3', '.ac3', '.flac', '.it', '.m4a', '.wma', '.s3m', '.ogg'] , ParamStr(1));50 FileSearch(Files, ParamStr(1), ['.mp3', '.ac3', '.flac', '.it', '.m4a', '.wma', '.s3m', '.ogg']); 54 51 for I := 0 to Files.Count - 1 do 55 52 WriteLn(Files[I]); 56 53 Files.Free; 54 end; 55 56 function FileDate(FileName: string): TDateTime; 57 var 58 fa: LongInt; 59 begin 60 fa := FileAge(FileName); 61 if Fa <> -1 then begin 62 Result := FileDateToDateTime(fa); 63 end else 64 raise Exception.Create('File ''' + FileName + ''' not found '); 57 65 end; 58 66 … … 70 78 Out: Integer; 71 79 NameRemoved: Boolean; 80 RemoteName: string; 72 81 begin 73 82 Files := TStringList.Create; … … 75 84 WriteLn('<playlist version="1" xmlns="http://xspf.org/ns/0/">'); 76 85 WriteLn('<trackList>'); 77 FileSearch(Files, ParamStr(1), ['.mp3', '.ac3', '.flac', '.it', '.m4a', '.wma', '.s3m', '.ogg'], ParamStr(1)); 78 for I := 0 to Files.Count - 1 do begin 79 LocationOriginal := StringReplace(Files[I], '&', '&', [rfReplaceAll]); 86 FileSearch(Files, ParamStr(1), ['.mp3', '.ac3', '.flac', '.it', '.m4a', '.wma', '.s3m', '.ogg']); 87 for I := 0 to Files.Count - 1 do begin 88 RemoteName := ParamStr(2) + Copy(Files[I], Length(ParamStr(1)) + 2, High(Integer)); 89 LocationOriginal := StringReplace(RemoteName, '&', '&', [rfReplaceAll]); 80 90 Location := StringReplace(LocationOriginal, '_', ' ', [rfReplaceAll]); 81 91 Album := ExtractFileName(ExtractFileDir(Location)); … … 119 129 WriteLn('<creator>' + Creator + '</creator>'); 120 130 WriteLn('<trackNum>' + TrackNum + '</trackNum>'); 131 WriteLn('<annotation>' + FormatDateTime('yyyy-mm-dd', FileDate(Files[I])) + '</annotation>'); 121 132 WriteLn('</track>'); 122 133 end;
Note:
See TracChangeset
for help on using the changeset viewer.