出于好奇我把站点排第一位 [gopeed](https://github.com/GopeedLab/gopeed) 的代码看了下才发现用的 getx ,所以在你质疑 getx 的时候,别人已经项目 star 13k 了。今天会来介绍下这个项目。 Gopeed,一款轻量原生的 Flutter 下载器,支持 HTTP、BitTorrent、Magnet 等协议,提供全平台高速下载体验。 本文将会讲解如何使用 gopeed, 以及项目代码分析讲解。

IDM 平替 Gopeed Flutter 开源免费下载工具

视频

https://youtu.be/m206G5lVXPM

https://www.bilibili.com/video/BV1Lz421k7Zp/

前言

原文 https://ducafecat.com/blog/flutter-gopeed-downloader-idm-replace

flutter ducafecat gopeed

https://flutter.ducafecat.com/github/repo/GopeedLab/gopeed

出于好奇我把站点排第一位 gopeed 的代码看了下才发现用的 getx ,所以在你质疑 getx 的时候,别人已经项目 star 13k 了。今天会来介绍下这个项目。

Gopeed,一款轻量原生的 Flutter 下载器,支持 HTTP、BitTorrent、Magnet 等协议,提供全平台高速下载体验。

本文将会讲解如何使用 gopeed, 以及项目代码分析讲解。

系统学习 flutter getx 请关注 https://ducafecat.com/course/flutter-woo。

参考

https://flutter.ducafecat.com/github/repo/GopeedLab/gopeed

https://github.com/GopeedLab/gopeed

https://github.com/search?q=topic%3Agopeed-extension&type=repositories

安装

多平台安装

https://github.com/GopeedLab/gopeed/releases/tag/v1.5.6

gopeed/releases/tag/v1.5.6

APP 配置

设置下载目录,并发数量

gopeed 基础设置

可设置代理

proxy

各种下载插件

https://github.com/search?q=topic%3Agopeed-extension&type=repositories

gopeed-extension

gopeed-extension-youtube

浏览器插件

https://chromewebstore.google.com/detail/gopeed/mijpgljlfcapndmchhjffkpckknofcnd

app 设置 API

gopeed api

安全起见可以设置令牌

插件添加服务器设置

gopeed api server

设置完之后,当你页面中点击触发下载后就会启动插件,把任务提交到 gopeed。

gopeed download

代码编译

gopeed 结构

环境

  1. Golang 1.21+
  2. Flutter 3.16+

go server

这里我以 macos 举例

go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/macos/Frameworks/libgopeed.dylib github.com/GopeedLab/gopeed/bind/desktop

gopeed build

flutter ui

cd ui/flutter
flutter build macos

gopeed flutter build

代码分析

gopeed go server 服务端

go 代码目录

gopeed go

分析包文件 go.mod

module github.com/GopeedLab/gopeed

go 1.21

require (
    github.com/anacrolix/missinggo/v2 v2.7.3
    github.com/anacrolix/torrent v1.53.3
    github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
    github.com/dop251/goja v0.0.0-20231027120936-b396bb4c349d
    github.com/dop251/goja_nodejs v0.0.0-20231122114759-e84d9a924c5c
    github.com/go-git/go-git/v5 v5.8.1
    github.com/gorilla/handlers v1.5.1
    github.com/gorilla/mux v1.8.0
    github.com/matoous/go-nanoid/v2 v2.0.0
    github.com/pkg/errors v0.9.1
    github.com/rs/zerolog v1.31.0
    github.com/virtuald/go-paniclog v0.0.0-20190812204905-43a7fa316459
    go.etcd.io/bbolt v1.3.8
    golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
    golang.org/x/sync v0.6.0
)

require (
    dario.cat/mergo v1.0.0 // indirect
    github.com/Microsoft/go-winio v0.6.1 // indirect
    github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
    github.com/RoaringBitmap/roaring v1.7.0 // indirect
    github.com/acomagu/bufpipe v1.0.4 // indirect
    github.com/ajwerner/btree v0.0.0-20211221152037-f427b3e689c0 // indirect
    github.com/alecthomas/atomic v0.1.0-alpha2 // indirect
    github.com/anacrolix/chansync v0.4.0 // indirect
    github.com/anacrolix/dht/v2 v2.21.0 // indirect
    github.com/anacrolix/envpprof v1.3.0 // indirect
    github.com/anacrolix/generics v0.0.0-20230911070922-5dd7545c6b13 // indirect
    github.com/anacrolix/go-libutp v1.3.1 // indirect
    github.com/anacrolix/log v0.14.6-0.20231202035202-ed7a02cad0b4 // indirect
    github.com/anacrolix/missinggo v1.3.0 // indirect
    github.com/anacrolix/missinggo/perf v1.0.0 // indirect
    github.com/anacrolix/mmsg v1.0.0 // indirect
    github.com/anacrolix/multiless v0.3.1-0.20221221005021-2d12701f83f7 // indirect
    github.com/anacrolix/stm v0.5.0 // indirect
    github.com/anacrolix/sync v0.5.1 // indirect
    github.com/anacrolix/upnp v0.1.3 // indirect
    github.com/anacrolix/utp v0.2.0 // indirect
    github.com/bahlo/generic-list-go v0.2.0 // indirect
    github.com/benbjohnson/immutable v0.4.3 // indirect
    github.com/bits-and-blooms/bitset v1.13.0 // indirect
    github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
    github.com/cloudflare/circl v1.3.3 // indirect
    github.com/davecgh/go-spew v1.1.1 // indirect
    github.com/dlclark/regexp2 v1.10.0 // indirect
    github.com/dustin/go-humanize v1.0.1 // indirect
    github.com/edsrzf/mmap-go v1.1.0 // indirect
    github.com/emirpasic/gods v1.18.1 // indirect
    github.com/felixge/httpsnoop v1.0.1 // indirect
    github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
    github.com/go-git/go-billy/v5 v5.4.1 // indirect
    github.com/go-llsqlite/adapter v0.1.0 // indirect
    github.com/go-llsqlite/crawshaw v0.5.0 // indirect
    github.com/go-logr/logr v1.4.1 // indirect
    github.com/go-logr/stdr v1.2.2 // indirect
    github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
    github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
    github.com/google/btree v1.1.2 // indirect
    github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a // indirect
    github.com/google/uuid v1.5.0 // indirect
    github.com/gorilla/websocket v1.5.1 // indirect
    github.com/huandu/xstrings v1.4.0 // indirect
    github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
    github.com/kevinburke/ssh_config v1.2.0 // indirect
    github.com/mattn/go-colorable v0.1.13 // indirect
    github.com/mattn/go-isatty v0.0.20 // indirect
    github.com/mschoch/smat v0.2.0 // indirect
    github.com/pion/datachannel v1.5.5 // indirect
    github.com/pion/dtls/v2 v2.2.9 // indirect
    github.com/pion/ice/v2 v2.3.12 // indirect
    github.com/pion/interceptor v0.1.25 // indirect
    github.com/pion/logging v0.2.2 // indirect
    github.com/pion/mdns v0.0.9 // indirect
    github.com/pion/randutil v0.1.0 // indirect
    github.com/pion/rtcp v1.2.13 // indirect
    github.com/pion/rtp v1.8.3 // indirect
    github.com/pion/sctp v1.8.9 // indirect
    github.com/pion/sdp/v3 v3.0.6 // indirect
    github.com/pion/srtp/v2 v2.0.18 // indirect
    github.com/pion/stun v0.6.1 // indirect
    github.com/pion/transport/v2 v2.2.4 // indirect
    github.com/pion/turn/v2 v2.1.4 // indirect
    github.com/pion/webrtc/v3 v3.2.24 // indirect
    github.com/pjbgf/sha1cd v0.3.0 // indirect
    github.com/pmezard/go-difflib v1.0.0 // indirect
    github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
    github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 // indirect
    github.com/sergi/go-diff v1.1.0 // indirect
    github.com/skeema/knownhosts v1.2.0 // indirect
    github.com/stretchr/testify v1.8.4 // indirect
    github.com/tidwall/btree v1.7.0 // indirect
    github.com/xanzy/ssh-agent v0.3.3 // indirect
    github.com/xiaoqidun/setft v0.0.0-20220310121541-be86327699ad // indirect
    go.opentelemetry.io/otel v1.22.0 // indirect
    go.opentelemetry.io/otel/metric v1.22.0 // indirect
    go.opentelemetry.io/otel/trace v1.22.0 // indirect
    golang.org/x/crypto v0.18.0 // indirect
    golang.org/x/mod v0.14.0 // indirect
    golang.org/x/net v0.20.0 // indirect
    golang.org/x/sys v0.16.0 // indirect
    golang.org/x/text v0.14.0 // indirect
    golang.org/x/time v0.5.0 // indirect
    golang.org/x/tools v0.17.0 // indirect
    gopkg.in/warnings.v0 v0.1.2 // indirect
    gopkg.in/yaml.v3 v3.0.1 // indirect
    modernc.org/libc v1.40.6 // indirect
    modernc.org/mathutil v1.6.0 // indirect
    modernc.org/memory v1.7.2 // indirect
    modernc.org/sqlite v1.28.0 // indirect
    zombiezen.com/go/sqlite v1.1.0 // indirect
)

支持的协议有 BitTorrent、SOCKS5、Http

NodeJS 引擎 ECMAScript、Node.js

gopeed flutter 前端

目录包

ui/flutter/pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  get: ^4.6.5
  lottie: ^1.4.2
  styled_widget: ^0.4.0+3
  context_menus: ^1.0.2
  json_annotation: ^4.8.1
  dio: ^5.2.1
  path_provider: ^2.1.1
  file_picker: 5.3.1
  macos_secure_bookmarks: ^0.2.1
  rounded_loading_button_plus: ^3.0.1
  url_launcher: ^6.1.6
  logger: ^1.3.0
  desktop_drop: ^0.4.3
  package_info_plus: ^4.0.0
  fluent_ui: ^4.4.0
  path: any
  badges: ^3.0.3
  app_links: ^3.4.2
  uri_to_file: ^0.2.0
  window_manager: ^0.3.4
  autoscale_tabbarview: ^1.0.2
  share_plus: ^7.1.0
  flutter_form_builder: ^9.1.1
  form_builder_validators: ^9.0.0
  flutter_foreground_task: ^6.1.2
  open_filex: ^4.3.4
  tray_manager: ^0.2.1
  lecle_downloads_path_provider: ^0.0.2+8
  hive: ^2.2.3
dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0
  ffigen: ^8.0.2
  # build json model: dart run build_runner build --delete-conflicting-outputs
  build_runner: ^2.2.1
  json_serializable: ^6.3.2
  flutter_launcher_icons: ^0.13.1

ffigen 方式读取 go 动态库

dio 拉取数据

fluent_ui 组件库

getx 方式管理路由、响应数据

styled_widget 简化前端视图代码

hive 前端本地数据

build_runner、json_serializable 自动化实例 entity 对象

程序启动时开启服务

gopeed start server

代码

https://github.com/GopeedLab/gopeed

小结

Gopeed 是一款基于 Flutter 开发的现代化下载工具,具有轻量、原生、全平台支持以及高速下载的特点。它不仅美观易用,而且开源,并且支持多种下载协议,包括 HTTP、BitTorrent、Magnet 等。无论是对于 Flutter 开发者还是下载工具用户,Gopeed 都是一个值得关注和尝试的项目。

感谢阅读本文

如果有什么建议,请在评论中让我知道。我很乐意改进。


flutter 学习路径


© 猫哥 ducafecat.com

end