搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。