diff --git a/assets/executable/ffmpeg.exe b/assets/executable/ffmpeg.exe new file mode 100644 index 0000000..a0fa8d9 Binary files /dev/null and b/assets/executable/ffmpeg.exe differ diff --git a/lib/constants.dart b/lib/constants.dart index c6d9f42..f4e93b4 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -6,3 +6,29 @@ const colorMainGrey = Color(0xFF333333); const colorMainRed = Color.fromRGBO(204, 0, 0, 1); const colorDarkRed = Color.fromRGBO(153, 0, 0, 1); const colorMainBlue = Color(0xFF1f74ad); + +enum Format { + mp3(format: 'MP3'), + mp3HD(format: 'MP3 HD'), + mp4(format: 'MP4'), + mp4HD( + ytCmd: + "bestvideo[height=1080][ext=mp4][vcodec~='^(avc|h264)']+bestaudio[ext=m4a]/bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", + format: 'MP4 HD'), + mp42K( + ytCmd: + "bestvideo[height=1440][ext=mp4]+bestaudio[ext=m4a]/bestvideo[height<=1080][ext=mp4][vcodec~='^(avc|h264)']+bestaudio[ext=m4a]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", + format: 'MP4 2K'), + tGP(format: '3GP'), + flv(format: 'FLV'), + m4a; + + final String ytCmd; + final String format; + + const Format({ + this.ytCmd = + '"18/22/bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"', + this.format = 'MP4', + }); +} diff --git a/lib/dlForm/cubit/dl_form_cubit.dart b/lib/dlForm/cubit/dl_form_cubit.dart index 06c686e..6f8091a 100644 --- a/lib/dlForm/cubit/dl_form_cubit.dart +++ b/lib/dlForm/cubit/dl_form_cubit.dart @@ -1,5 +1,8 @@ +import 'dart:convert'; + import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:notube/models/Video.dart'; import 'package:notube/services/download.dart'; import 'dart:developer'; @@ -24,8 +27,41 @@ class DlFormCubit extends Cubit { )); } - void download() async { + void parseUrl() async { dlService = await DLServices.init(); - await dlService.analyseUrl(state.url!); + var shellStream = await dlService.analyseUrl(state.url!); + + shellStream.listen((line) { + if (line[0] == '{') { + var dataInfos = jsonDecode(line); + var extractor = dataInfos['extractor_key']; + var isPlaylist = dataInfos['_type'] == 'playlist'; + var videos =