Skip to content
View Joaov7016's full-sized avatar

Block or report Joaov7016

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Joaov7016/README.md

import 'dart:async'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; import 'package:youtube_explode_dart/youtube_explode_dart.dart' as yt;

void main() => runApp(MyApp());

class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'YouTube Audio Downloader', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(), ); } }

class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); }

class _MyHomePageState extends State { String _link = ''; String _destinationFolder = ''; String _status = ''; double _progressValue = 0.0;

void _chooseFolder() async { Directory directory = await getExternalStorageDirectory(); setState(() { _destinationFolder = directory.path; _status = "Pasta de destino selecionada: $_destinationFolder"; }); }

Future _downloadAudio() async { if (_link.isEmpty) { setState(() { _status = "Por favor, insira um link válido."; }); return; }

if (_destinationFolder.isEmpty) {
  setState(() {
    _status = "Por favor, escolha uma pasta de destino.";
  });
  return;
}

final yt.YoutubeExplode ytExplode = yt.YoutubeExplode();
final yt.Video video = await ytExplode.videos.get(_link);
final yt.AudioStreamInfo audio = video.audio.first;
final File file = File('$_destinationFolder/${video.title}.wav');

await for (final List<int> chunk in ytExplode.videos.streamsClient.get(audio)) {
  file.writeAsBytesSync(chunk, mode: FileMode.append);
}

setState(() {
  _status = "Download completo: ${file.path}";
});

await ytExplode.close();

}

@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('YouTube Audio Downloader'), ), body: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ TextField( onChanged: (value) { setState(() { _link = value; }); }, decoration: InputDecoration(labelText: 'Link do vídeo'), ), SizedBox(height: 16.0), RaisedButton( onPressed: _chooseFolder, child: Text('Escolher Pasta'), ), SizedBox(height: 16.0), RaisedButton( onPressed: _downloadAudio, child: Text('Baixar Áudio'), ), SizedBox(height: 16.0), LinearProgressIndicator(value: _progressValue), SizedBox(height: 16.0), Text(_status), ], ), ), ); } }

Popular repositories Loading

  1. flutter_catalog flutter_catalog Public

    Forked from X-Wei/flutter_catalog

    An app showcasing Flutter components, with side-by-side source code view.

    Dart

  2. Joaov7016 Joaov7016 Public

    Config files for my GitHub profile.