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

插件详情v0.3.3

direct_link

从 URL 直接提取链接以直接流式传输和下载。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
142
喜欢数
84
Pub 分数
150

安装插件

flutter pub add direct_link

插件介绍

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

一个 Flutter/Dart 包,可从 URL 中提取直接下载链接,实现跨多个平台的媒体文件无缝流式传输和下载。它简化了从各种来源获取原始文件 URL 的过程,非常适合需要离线访问或实时播放的应用程序。该包支持 Android、iOS、Web、macOS、Windows 和 Linux,确保广泛的兼容性。专为开发多媒体应用程序的开发者设计,无需复杂的解析逻辑即可简化内容获取。

适合场景

  • 流式传输媒体文件
  • 从共享链接下载文件
  • 构建离线内容应用
  • 与媒体播放器集成
  • 从社交媒体链接获取资源
  • 创建文件下载管理器

主要特点

  • 从URL中提取直接链接
  • 支持跨平台部署
  • 启用流媒体和下载
  • 简单 API 集成
  • 适用于各种URL源
  • 轻便高效

适合对象

  • 媒体应用开发者
  • 文件下载工具
  • 离线内容提供者
  • 内容聚合应用
  • 需要直接文件访问的应用程序

使用建议

  • 依赖源URL结构
  • 可能需要处理速率限制
  • 并非所有链接都能解析为直接流
  • 依赖外部服务的可用性
  • 需要对失败的请求进行适当的错误处理
  • 仅限支持的 URL 格式

原始 README

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

direct_link

pub package Last Commits GitHub repo size License
Uploaded By

direct_link is a Flutter package for extracting direct media links and basic metadata from supported public page URLs.

Use it when you need to build a downloader, media preview, or media utility app that can resolve a shared social/video URL into playable or downloadable links.

Features

  • Extract direct media links from supported websites.
  • Return media metadata such as title, thumbnail, and duration when available.
  • Return multiple qualities or formats when the source provides them.
  • Simple null-safe API with a single check method.

Supported websites

  • Facebook
  • Instagram
  • YouTube
  • Twitter/X
  • Dailymotion
  • Vimeo
  • VK
  • SoundCloud
  • TikTok
  • Reddit
  • Threads

Support depends on the upstream website response and the extraction service used internally. A supported website can still return null when the URL is private, removed, region-blocked, unsupported by the upstream service, or temporarily unavailable.

Platform support

This package currently depends on Flutter and flutter_inappwebview, so it is intended for Flutter apps.

Screenshot

direct_link example screenshot

Installation

Add direct_link to your Flutter project's pubspec.yaml:

dependencies:
  direct_link: ^0.3.3

Then run:

flutter pub get

Import the package:

import 'package:direct_link/direct_link.dart';

Usage

Create a DirectLink instance and call check with a supported page URL:

final directLink = DirectLink();

final data = await directLink.check(
  'https://www.youtube.com/watch?v=kzOO_uplPdk',
);

if (data == null) {
  // No media link was found, or the upstream service could not resolve it.
  return;
}

print(data.title);
print(data.thumbnail);
print(data.duration);

for (final link in data.links ?? []) {
  print(link.quality);
  print(link.type);
  print(link.link);
}

API

DirectLink.check
Future<SiteModel?> check(String url, {double? timeoutInterval});

Resolves a supported public page URL into a SiteModel.

Returns null when no media link can be extracted.

SiteModel
class SiteModel {
  final String? title;
  final String? thumbnail;
  final String? duration;
  final List<Link>? links;
}
Link
class Link {
  final String quality;
  final String link;
  final String? type;
}

Notes and limitations

  • This package resolves public media URLs only.
  • Private, deleted, age-restricted, login-required, or region-blocked content may not resolve.
  • Website markup and upstream extraction behavior can change without notice.
  • The returned link list and quality labels depend on the source website and upstream service response.
  • Network-based social website checks are integration tests and are not run by default.

Testing

Run deterministic unit tests:

flutter test

Run real-site integration tests explicitly:

flutter test integration_test/social_test.dart

Integration tests depend on live third-party websites and may fail because of network issues, rate limits, region restrictions, or upstream website changes.

Contributing

Issues and pull requests are welcome.

  • Report bugs on the issue tracker.
  • Include a reproducible URL when reporting extraction failures.
  • Keep unit tests deterministic. Put live website checks in integration_test/.

License

This package is released under the MIT License.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。