[playlist] add playlist name

This commit is contained in:
jscampucci 2024-07-02 15:39:41 +02:00
parent 4ac4ce0d7e
commit c2ab736a54
6 changed files with 19 additions and 11 deletions

View File

@ -45,7 +45,8 @@ class DlFormCubit extends Cubit<DlFormState> {
var video = Video.fromJson(videoTmp);
videos.add(video.copyWith(
format: state.format,
filename: '${video.id}_${state.format.format}'));
filename: '${video.id}_${state.format.format}',
playlistTitle: playlistTitle));
}
} else {
var video = Video.fromJson(dataInfos);

View File

@ -50,7 +50,7 @@ class DlForm extends StatelessWidget {
DropdownFormat(),
SubmitButton(),
]),
DebugDlFormState(),
//DebugDlFormState(),
],
);
}

View File

@ -18,6 +18,7 @@ class Video extends Equatable {
this.uploader = '',
this.uploadDate = '',
this.filename = '',
this.playlistTitle = '',
});
final String id;
@ -33,6 +34,7 @@ class Video extends Equatable {
final String uploader;
final String uploadDate;
final String filename;
final String playlistTitle;
factory Video.fromJson(Map<String, dynamic> json) {
return Video(
@ -63,6 +65,7 @@ class Video extends Equatable {
String? uploader,
String? uploadDate,
String? filename,
String? playlistTitle,
}) {
return Video(
id: id ?? this.id,
@ -78,6 +81,7 @@ class Video extends Equatable {
uploader: uploader ?? this.uploader,
uploadDate: uploadDate ?? this.uploadDate,
filename: filename ?? this.filename,
playlistTitle: playlistTitle ?? this.playlistTitle,
);
}
@ -95,5 +99,6 @@ class Video extends Equatable {
url,
isParsed,
filename,
playlistTitle,
];
}

View File

@ -74,10 +74,3 @@ class Home extends StatelessWidget {
}));
}
}
/*
SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: viewportConstraints.maxHeight),
child:
*/

View File

@ -91,6 +91,15 @@ class VideosCubit extends Cubit<VideosState> {
final tmpFile =
File('temp/${video.filename}_done.${video.format.extension}');
var playlistTitle = video.playlistTitle;
await Directory('${downloadDirectory.path}/$playlistTitle')
.create(recursive: true)
.catchError((e) => debugPrint('Error creating directory: $e'));
debugPrint('Playlist title: $playlistTitle');
if (playlistTitle.isNotEmpty && playlistTitle != '') {
cleanTitle = playlistTitle + '/' + cleanTitle;
}
final newFile = File(
'${downloadDirectory.path}/$cleanTitle.${video.format.extension}');

View File

@ -1,9 +1,9 @@
name: notube
description: NoTube
description: noTube
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 0.0.1+1
version: 0.0.18
environment:
sdk: ">=3.0.0 <4.0.0"