Skip to content

Commit

Permalink
chore: save m3u paths as relative
Browse files Browse the repository at this point in the history
instead of absolute, as long they exist with the parent m3u
  • Loading branch information
MSOB7YY committed Oct 29, 2023
1 parent e84f15e commit da04489
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/controller/playlist_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class PlaylistController extends PlaylistManager<TrackWithDate> {
final path = params['path'] as String;
final tracks = params['tracks'] as List<TrackWithDate>;
final infoMap = params['infoMap'] as Map<String, String?>;
final relative = params['relative'] as bool? ?? true;

final file = File(path);
file.deleteIfExistsSync();
Expand All @@ -253,7 +254,7 @@ class PlaylistController extends PlaylistManager<TrackWithDate> {
final tr = trwd.track;
final trext = tr.track.toTrackExt();
final infoLine = infoMap[tr.path] ?? '#EXTINF:${trext.duration},${trext.originalArtist} - ${trext.title}';
final pathLine = tr.path;
final pathLine = relative ? tr.path.replaceFirst(path.getDirectoryPath, '') : tr.path;
sink.write("$infoLine\n$pathLine\n");
}

Expand Down

0 comments on commit da04489

Please sign in to comment.