From b908911417aecb847a9f493b063852a8939a9140 Mon Sep 17 00:00:00 2001 From: jscampucci Date: Fri, 14 Jun 2024 10:41:27 +0200 Subject: [PATCH] [archi] base archi dl --- .gitignore | 1 + .vscode/launch.json | 25 ++++++++ lib/models/Video.dart | 32 +++++++++++ lib/services/download.dart | 112 ++++++++++++++++++++++++++++++++++++ lib/states/dlFormState.dart | 40 +++---------- 5 files changed, 177 insertions(+), 33 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 lib/models/Video.dart create mode 100644 lib/services/download.dart diff --git a/.gitignore b/.gitignore index 29a3a50..6b48af0 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ migrate_working_dir/ .pub-cache/ .pub/ /build/ +temp/ # Symbolication related app.*.symbols diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..31032cd --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "notube", + "request": "launch", + "type": "dart" + }, + { + "name": "notube (profile mode)", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "notube (release mode)", + "request": "launch", + "type": "dart", + "flutterMode": "release" + } + ] +} diff --git a/lib/models/Video.dart b/lib/models/Video.dart new file mode 100644 index 0000000..a4fe910 --- /dev/null +++ b/lib/models/Video.dart @@ -0,0 +1,32 @@ +import 'dart:developer' as developer; + +class Video { + String id; + String title; + String thumbnail; + String description; + String duration; + String uploader; + String uploadDate; + + Video({ + required this.id, + required this.title, + this.thumbnail = '', + this.description = '', + this.duration = '0:00', + required this.uploader, + required this.uploadDate, + }); + + factory Video.fromJson(Map json) { + return Video( + id: json['id'], + title: json['title'], + thumbnail: json['thumbnails']![0]['url'], + description: json['description'] ?? '', + duration: json['duration_string'] ?? '0:00', + uploader: json['uploader'] ?? '', + uploadDate: json['upload_date'] ?? ''); + } +} diff --git a/lib/services/download.dart b/lib/services/download.dart new file mode 100644 index 0000000..6f9a0a7 --- /dev/null +++ b/lib/services/download.dart @@ -0,0 +1,112 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:notube/models/Video.dart'; +import 'package:notube/states/dlFormState.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:process_run/shell.dart'; +import 'package:provider/provider.dart'; + +import 'dart:developer'; + +class DLServices { + late Directory tempDir; + late String assetName; + late String ytDlpPath; + + String extractor = ''; + String url = ''; + + bool isPlaylist = false; + String playlistTitle = ''; + + List