[clean] clean code
This commit is contained in:
parent
7bd09a3904
commit
3eb4d7b905
|
|
@ -42,3 +42,5 @@ app.*.map.json
|
||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
|
||||||
|
samples/
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"dart.analysisExcludedFolders": [
|
||||||
|
"C:\\Users\\Skapdat\\Projets\\Dev\\NoTube-Flutter\\notube\\samples"
|
||||||
|
],
|
||||||
|
"CodeGPT.apiKey": "Anthropic"
|
||||||
|
}
|
||||||
|
|
@ -2,11 +2,9 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:notube/models/Video.dart';
|
import 'package:notube/models/video.dart';
|
||||||
import 'package:notube/services/download.dart';
|
import 'package:notube/services/download.dart';
|
||||||
|
|
||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
part 'dl_form_state.dart';
|
part 'dl_form_state.dart';
|
||||||
|
|
||||||
class DlFormCubit extends Cubit<DlFormState> {
|
class DlFormCubit extends Cubit<DlFormState> {
|
||||||
|
|
@ -29,7 +27,7 @@ class DlFormCubit extends Cubit<DlFormState> {
|
||||||
|
|
||||||
void parseUrl() async {
|
void parseUrl() async {
|
||||||
dlService = await DLServices.init();
|
dlService = await DLServices.init();
|
||||||
var shellStream = await dlService.analyseUrl(state.url!);
|
var shellStream = await dlService.analyseUrl(state.url);
|
||||||
|
|
||||||
shellStream.listen((line) {
|
shellStream.listen((line) {
|
||||||
if (line[0] == '{') {
|
if (line[0] == '{') {
|
||||||
|
|
@ -41,12 +39,16 @@ class DlFormCubit extends Cubit<DlFormState> {
|
||||||
var playlistTitle = dataInfos['title'];
|
var playlistTitle = dataInfos['title'];
|
||||||
for (var videoTmp in dataInfos['entries']) {
|
for (var videoTmp in dataInfos['entries']) {
|
||||||
var video = Video.fromJson(videoTmp);
|
var video = Video.fromJson(videoTmp);
|
||||||
video.format = state.format;
|
video.copyWith(
|
||||||
|
format: state.format,
|
||||||
|
);
|
||||||
videos.add(video);
|
videos.add(video);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var video = Video.fromJson(dataInfos);
|
var video = Video.fromJson(dataInfos);
|
||||||
video.format = state.format;
|
video.copyWith(
|
||||||
|
format: state.format,
|
||||||
|
);
|
||||||
videos.add(video);
|
videos.add(video);
|
||||||
}
|
}
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:notube/dlForm/cubit/dl_form_cubit.dart';
|
import 'package:notube/dlForm/cubit/dl_form_cubit.dart';
|
||||||
import 'package:notube/dlForm/formComponents/formatDropdown.dart';
|
import 'package:notube/dlForm/formComponents/format_dropdown.dart';
|
||||||
import 'package:notube/dlForm/formComponents/submitButton.dart';
|
import 'package:notube/dlForm/formComponents/submit_button.dart';
|
||||||
import 'package:notube/dlForm/formComponents/urlTextField.dart';
|
import 'package:notube/dlForm/formComponents/url_text_field.dart';
|
||||||
|
|
||||||
class DlForm extends StatelessWidget {
|
class DlForm extends StatelessWidget {
|
||||||
const DlForm({super.key});
|
const DlForm({super.key});
|
||||||
|
|
@ -69,8 +69,8 @@ class DebugDlFormState extends StatelessWidget {
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text('Url: ${url}'),
|
Text('Url: $url'),
|
||||||
Text('Format: ${format}'),
|
Text('Format: $format'),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -3,17 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:notube/constants.dart';
|
import 'package:notube/constants.dart';
|
||||||
import 'package:notube/dlForm/cubit/dl_form_cubit.dart';
|
import 'package:notube/dlForm/cubit/dl_form_cubit.dart';
|
||||||
|
|
||||||
const List<String> formatList = <String>[
|
|
||||||
"MP3",
|
|
||||||
"MP3 HD",
|
|
||||||
"MP4",
|
|
||||||
"MP4 HD",
|
|
||||||
"MP4 2K",
|
|
||||||
"3GP",
|
|
||||||
"FLV",
|
|
||||||
"M4A",
|
|
||||||
];
|
|
||||||
|
|
||||||
class DropdownFormat extends StatelessWidget {
|
class DropdownFormat extends StatelessWidget {
|
||||||
const DropdownFormat({super.key});
|
const DropdownFormat({super.key});
|
||||||
|
|
||||||
|
|
@ -37,10 +26,10 @@ class DropdownFormat extends StatelessWidget {
|
||||||
context.read<DlFormCubit>().setFormat(value!);
|
context.read<DlFormCubit>().setFormat(value!);
|
||||||
},
|
},
|
||||||
underline: Container(),
|
underline: Container(),
|
||||||
items: formatList.map<DropdownMenuItem<String>>((String value) {
|
items: Format.values.map<DropdownMenuItem<String>>((Format format) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: value,
|
value: format.format,
|
||||||
child: Text(value),
|
child: Text(format.format),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
));
|
));
|
||||||
|
|
@ -2,9 +2,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:notube/constants.dart';
|
import 'package:notube/constants.dart';
|
||||||
import 'package:notube/models/Video.dart';
|
import 'package:notube/models/video.dart';
|
||||||
import 'package:notube/videoList/cubit/videos_cubit.dart';
|
import 'package:notube/videoList/cubit/videos_cubit.dart';
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:notube/dlForm/cubit/dl_form_cubit.dart';
|
import 'package:notube/dlForm/cubit/dl_form_cubit.dart';
|
||||||
|
|
||||||
class SubmitButton extends StatefulWidget {
|
class SubmitButton extends StatefulWidget {
|
||||||
|
|
@ -6,7 +6,6 @@ import 'package:window_manager/window_manager.dart';
|
||||||
import 'package:upgrader/upgrader.dart';
|
import 'package:upgrader/upgrader.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:notube/videoList/cubit/videos_cubit.dart';
|
import 'package:notube/videoList/cubit/videos_cubit.dart';
|
||||||
import 'package:notube/models/Video.dart';
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
@immutable
|
||||||
class Video extends Equatable {
|
class Video extends Equatable {
|
||||||
Video({
|
Video({
|
||||||
this.id = '',
|
this.id = '',
|
||||||
|
|
@ -17,19 +19,19 @@ class Video extends Equatable {
|
||||||
this.filename = '',
|
this.filename = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
String id;
|
final String id;
|
||||||
String url;
|
final String url;
|
||||||
String extractor;
|
final String extractor;
|
||||||
bool isParsed;
|
final bool isParsed;
|
||||||
String status;
|
final String status;
|
||||||
String format;
|
final String format;
|
||||||
String title;
|
final String title;
|
||||||
String thumbnail;
|
final String thumbnail;
|
||||||
String description;
|
final String description;
|
||||||
String duration;
|
final String duration;
|
||||||
String uploader;
|
final String uploader;
|
||||||
String uploadDate;
|
final String uploadDate;
|
||||||
String filename;
|
final String filename;
|
||||||
|
|
||||||
factory Video.fromJson(Map<String, dynamic> json) {
|
factory Video.fromJson(Map<String, dynamic> json) {
|
||||||
return Video(
|
return Video(
|
||||||
|
|
@ -45,6 +47,39 @@ class Video extends Equatable {
|
||||||
uploadDate: json['upload_date'] ?? '');
|
uploadDate: json['upload_date'] ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//set Status
|
||||||
|
Video copyWith({
|
||||||
|
String? id,
|
||||||
|
String? url,
|
||||||
|
String? extractor,
|
||||||
|
bool? isParsed,
|
||||||
|
String? status,
|
||||||
|
String? format,
|
||||||
|
String? title,
|
||||||
|
String? thumbnail,
|
||||||
|
String? description,
|
||||||
|
String? duration,
|
||||||
|
String? uploader,
|
||||||
|
String? uploadDate,
|
||||||
|
String? filename,
|
||||||
|
}) {
|
||||||
|
return Video(
|
||||||
|
id: id ?? this.id,
|
||||||
|
url: url ?? this.url,
|
||||||
|
extractor: extractor ?? this.extractor,
|
||||||
|
isParsed: isParsed ?? this.isParsed,
|
||||||
|
status: status ?? this.status,
|
||||||
|
format: format ?? this.format,
|
||||||
|
title: title ?? this.title,
|
||||||
|
thumbnail: thumbnail ?? this.thumbnail,
|
||||||
|
description: description ?? this.description,
|
||||||
|
duration: duration ?? this.duration,
|
||||||
|
uploader: uploader ?? this.uploader,
|
||||||
|
uploadDate: uploadDate ?? this.uploadDate,
|
||||||
|
filename: filename ?? this.filename,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [
|
List<Object> get props => [
|
||||||
id,
|
id,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:notube/constants.dart';
|
import 'package:notube/dlForm/dl_form.dart';
|
||||||
import 'package:notube/dlForm/dlForm.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:notube/videoList/cubit/videos_cubit.dart';
|
import 'package:notube/videoList/cubit/videos_cubit.dart';
|
||||||
import 'package:notube/models/Video.dart';
|
|
||||||
|
|
||||||
class Home extends StatelessWidget {
|
class Home extends StatelessWidget {
|
||||||
Home({super.key});
|
Home({super.key});
|
||||||
|
|
@ -52,7 +50,9 @@ class Home extends StatelessWidget {
|
||||||
fit: BoxFit.cover),
|
fit: BoxFit.cover),
|
||||||
),
|
),
|
||||||
title: Text(currentVideo.title),
|
title: Text(currentVideo.title),
|
||||||
subtitle: Text(currentVideo.status));
|
subtitle: Text(
|
||||||
|
'${currentVideo.status} - ${currentVideo.format}'),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
})),
|
})),
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:notube/constants.dart';
|
import 'package:notube/constants.dart';
|
||||||
import 'package:notube/models/Video.dart';
|
import 'package:notube/models/video.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:process_run/shell.dart';
|
import 'package:process_run/shell.dart';
|
||||||
|
|
||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
class DLServices {
|
class DLServices {
|
||||||
late Directory tempDir;
|
late Directory tempDir;
|
||||||
late String assetName;
|
late String assetName;
|
||||||
|
|
@ -71,7 +67,7 @@ class DLServices {
|
||||||
|
|
||||||
var cleanTitle = video.title.replaceAll(RegExp(r'[^\w\s]+'), '');
|
var cleanTitle = video.title.replaceAll(RegExp(r'[^\w\s]+'), '');
|
||||||
var command =
|
var command =
|
||||||
'${video.url.trim()} --sub-langs "all,-live_chat" --embed-subs --embed-thumbnail --embed-metadata --progress -o "temp/%(playlist)s/${cleanTitle}_${video.format}_tmp.%(ext)s" -f "$formatCmd"';
|
'${video.url.trim()} --sub-langs "all,-live_chat" --embed-subs --embed-thumbnail --embed-metadata --progress -o "temp/${video.id}_${video.format}_tmp.%(ext)s" -f "$formatCmd"';
|
||||||
|
|
||||||
var shellLinesController = ShellLinesController();
|
var shellLinesController = ShellLinesController();
|
||||||
var shell = Shell(stdout: shellLinesController.sink, verbose: false);
|
var shell = Shell(stdout: shellLinesController.sink, verbose: false);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.11.0"
|
version: "2.11.0"
|
||||||
bloc:
|
bloc:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: bloc
|
name: bloc
|
||||||
sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e"
|
sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e"
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ dependencies:
|
||||||
flutter_bloc: ^8.1.6
|
flutter_bloc: ^8.1.6
|
||||||
equatable: ^2.0.5
|
equatable: ^2.0.5
|
||||||
json_annotation: ^4.9.0
|
json_annotation: ^4.9.0
|
||||||
|
bloc: ^8.1.4
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue