搜索插件、代码仓与 APP 分类

插件详情v0.0.5

flutter_youtube_downloader

一个用于提取和下载 YouTube 视频 URL 的 Flutter 插件

AndroidiOS
近 30 天下载
261
喜欢数
71
Pub 分数
130

安装插件

flutter pub add flutter_youtube_downloader

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 插件,可实现从 YouTube 提取和下载视频 URL,支持 Android 和 iOS 平台。它允许开发者获取视频信息和下载链接,以便离线访问。该包可无缝集成到 Flutter 应用中,提供简单易用的 API 来处理 YouTube 内容。对于需要从 YouTube 获取视频而无需依赖官方 YouTube API 的媒体应用非常有用。源代码在 GitHub 上公开,便于透明化和自定义。

适合场景

  • 离线视频播放
  • 视频内容聚合
  • 教育类应用程序媒体下载
  • 自定义视频播放器集成
  • 用于个人用途的内容抓取

主要特点

  • 提取YouTube视频链接
  • 支持 Android 和 iOS
  • 提供视频元数据
  • 开源且拥有公共仓库
  • 与 Flutter 的简单集成

适合对象

  • 开发媒体应用的开发者
  • 需要离线视频访问的应用
  • 教育或教程平台
  • 需要YouTube内容检索的项目

使用建议

  • 需要遵守YouTube的服务条款
  • 可能受到YouTube反爬取措施的影响
  • 无官方 YouTube API 使用
  • YouTube 更新可能导致变更
  • 仅限视频URL提取,不支持完整视频下载

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

flutter_youtube_downloader

A flutter plugin for extracting and downloading youtube video url

Usage

[Example] (https://github.com/Destiny-Ed/flutter_youtube_downloader/blob/main/example/lib/main.dart)

To use this plugin : *add the dependency to your [pubspec.yaml] file

    dependencies:
        flutter:
            sdk : flutter
        flutter_youtube_downloader:

Add to your app manifest.xml file

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">  <!-- Add This line -->
    
    ...........
  
    <application
        ..............
        <!-- Add This line -->

        tools:replace="android:label" 
        android:requestLegacyExternalStorage="true"> <!-- Add This line if you are targeting android API 29+-->

        <activity>
            ...............
        </activity>
     
    </application>
</manifest>

Warning

Make sure you don't add ...(dots) after the video title name

[Example] Bad final result = await FlutterYoutubeDownloader.downloadVideo( youTube_link, "Video Title goes Here...", 18);

[Example] Good final result = await FlutterYoutubeDownloader.downloadVideo( youTube_link, "Video Title goes Here", 18);

How To Use

    import 'package:flutter/material.dart';
    import 'dart:async';

    import 'package:flutter/services.dart';
    import 'package:flutter_youtube_downloader/flutter_youtube_downloader.dart';

    void main() {
      runApp(MyApp());
    }

    class MyApp extends StatefulWidget {
      @override
      _MyAppState createState() => _MyAppState();
    }

    class _MyAppState extends State<MyApp> {
      String _extractedLink = 'Loading...';

      String youTube_link = "https://www.youtube.com/watch?v=nRhYQlg8fVw";

      @override
      void initState() {
        super.initState();
        extractYoutubeLink();
      }

      // Platform messages are asynchronous, so we initialize in an async method.
      Future<void> extractYoutubeLink() async {
        String link;
        // Platform messages may fail, so we use a try/catch PlatformException.
        try {
          link = await FlutterYoutubeDownloader.extractYoutubeLink(youTube_link, 18);
        } on PlatformException {
          link = 'Failed to Extract YouTube Video Link.';
        }

        // If the widget was removed from the tree while the asynchronous platform
        // message was in flight, we want to discard the reply rather than calling
        // setState to update our non-existent appearance.
        if (!mounted) return;

        setState(() {
          _extractedLink = link;
        });
      }

      Future<void> downloadVideo() async {
        final result = await FlutterYoutubeDownloader.downloadVideo(
            youTube_link, "Video Title goes Here", 18);
        print(result);
      }

      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              title: const Text('Flutter Youtube Link Downloader example app'),
            ),
            body: Center(
              child: Text('Extracted Link : $_extractedLink\n'),
            ),
            floatingActionButton: FloatingActionButton(
              onPressed: downloadVideo,
              child: const Icon(Icons.download_rounded),
            ),
          ),
        );
      }
    }

Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。