From c2ab736a544eceab40f5c30d3d25507722e22c03 Mon Sep 17 00:00:00 2001 From: jscampucci Date: Tue, 2 Jul 2024 15:39:41 +0200 Subject: [PATCH] [playlist] add playlist name --- lib/dlForm/cubit/dl_form_cubit.dart | 3 ++- lib/dlForm/dl_form.dart | 2 +- lib/models/Video.dart | 5 +++++ lib/screens/home.dart | 7 ------- lib/videoList/cubit/videos_cubit.dart | 9 +++++++++ pubspec.yaml | 4 ++-- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/dlForm/cubit/dl_form_cubit.dart b/lib/dlForm/cubit/dl_form_cubit.dart index 0f32d70..3fd26a9 100644 --- a/lib/dlForm/cubit/dl_form_cubit.dart +++ b/lib/dlForm/cubit/dl_form_cubit.dart @@ -45,7 +45,8 @@ class DlFormCubit extends Cubit { 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); diff --git a/lib/dlForm/dl_form.dart b/lib/dlForm/dl_form.dart index 01707b2..02a4903 100644 --- a/lib/dlForm/dl_form.dart +++ b/lib/dlForm/dl_form.dart @@ -50,7 +50,7 @@ class DlForm extends StatelessWidget { DropdownFormat(), SubmitButton(), ]), - DebugDlFormState(), + //DebugDlFormState(), ], ); } diff --git a/lib/models/Video.dart b/lib/models/Video.dart index df8ce40..6f7c05a 100644 --- a/lib/models/Video.dart +++ b/lib/models/Video.dart @@ -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 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, ]; } diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 180019d..cf84900 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -74,10 +74,3 @@ class Home extends StatelessWidget { })); } } -/* -SingleChildScrollView( - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: viewportConstraints.maxHeight), - child: - */ \ No newline at end of file diff --git a/lib/videoList/cubit/videos_cubit.dart b/lib/videoList/cubit/videos_cubit.dart index eaf2e4a..c22bb83 100644 --- a/lib/videoList/cubit/videos_cubit.dart +++ b/lib/videoList/cubit/videos_cubit.dart @@ -91,6 +91,15 @@ class VideosCubit extends Cubit { 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}'); diff --git a/pubspec.yaml b/pubspec.yaml index 81fe2bf..b5afae2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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"