Changeset 5
- Timestamp:
- Feb 2, 2015, 10:50:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GenPlaylist.pas
r4 r5 61 61 Files: TStringList; 62 62 I: Integer; 63 FileName: string; 63 Creator: string; 64 Album: string; 65 Location: string; 66 LocationOriginal: string; 67 Title: string; 68 Part: string; 69 TrackNum: string; 70 Out: Integer; 71 NameRemoved: Boolean; 64 72 begin 65 73 Files := TStringList.Create; … … 68 76 WriteLn('<trackList>'); 69 77 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]); 78 for I := 0 to Files.Count - 1 do begin 79 LocationOriginal := StringReplace(Files[I], '&', '&', [rfReplaceAll]); 80 Location := StringReplace(LocationOriginal, '_', ' ', [rfReplaceAll]); 81 Album := ExtractFileName(ExtractFileDir(Location)); 82 NameRemoved := False; 83 84 // Detect Creator from directory name 85 if Pos(' - ', Album) > 0 then begin 86 Creator := Copy(Album, 1, Pos(' - ', Album) - 1); 87 Delete(Album, 1, Length(Creator) + 3); 88 end else Creator := Album; 89 Title := Copy(ExtractFileName(Location), 1, Length(ExtractFileName(Location)) - Length(ExtractFileExt(Location))); 90 91 // Remove starting with album name from title 92 Part := Creator + ' - '; 93 if Copy(Title, 1, Length(Part)) = Part then begin 94 Delete(Title, 1, Length(Part)); 95 NameRemoved := True; 96 end; 97 98 // Try to load Creator from name 99 if (Pos(' - ', Title) > 0) and (not NameRemoved) then begin 100 Part := Copy(Title, 1, Pos(' - ', Title) - 1); 101 // Avoid track number which can be first title part 102 if not TryStrToInt(Part, Out) then begin 103 Creator := Part; 104 Delete(Title, 1, Length(Creator) + 3); 105 end; 106 end; 107 // Detect track number from title 108 if Pos(' - ', Title) > 0 then begin 109 TrackNum := Copy(Title, 1, Pos(' - ', Title) - 1); 110 if TryStrToInt(TrackNum, Out) then 111 Delete(Title, 1, Length(TrackNum) + 3) 112 else TrackNum := ''; 113 end else TrackNum := ''; 114 72 115 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>'); 116 WriteLn('<title>' + Title + '</title>'); 117 WriteLn('<location>' + LocationOriginal + '</location>'); 118 WriteLn('<album>' + Album + '</album>'); 119 WriteLn('<creator>' + Creator + '</creator>'); 120 WriteLn('<trackNum>' + TrackNum + '</trackNum>'); 76 121 WriteLn('</track>'); 77 122 end;
Note:
See TracChangeset
for help on using the changeset viewer.