mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-24 12:40:45 +08:00
feat: submit all torrent info to server
This commit is contained in:
@@ -309,7 +309,7 @@ func (s *Server) DownloadMovieTorrent(c *gin.Context) (interface{}, error) {
|
||||
history, err := s.db.SaveHistoryRecord(ent.History{
|
||||
MediaID: media.ID,
|
||||
EpisodeID: ep.ID,
|
||||
SourceTitle: media.NameCn,
|
||||
SourceTitle: in.Name,
|
||||
TargetDir: "./",
|
||||
Status: history.StatusRunning,
|
||||
Size: in.Size,
|
||||
|
||||
@@ -252,7 +252,7 @@ class _NestedTabBarState extends ConsumerState<NestedTabBar>
|
||||
ref
|
||||
.read(movieTorrentsDataProvider(widget.id)
|
||||
.notifier)
|
||||
.download(torrent.link!)
|
||||
.download(torrent)
|
||||
.whenComplete(() =>
|
||||
Utils.showSnakeBar("开始下载:${torrent.name}"))
|
||||
.onError((error, trace) =>
|
||||
|
||||
@@ -181,24 +181,23 @@ class MediaDetail {
|
||||
}
|
||||
|
||||
class SearchResult {
|
||||
SearchResult({
|
||||
required this.backdropPath,
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.originalName,
|
||||
required this.overview,
|
||||
required this.posterPath,
|
||||
required this.mediaType,
|
||||
required this.adult,
|
||||
required this.originalLanguage,
|
||||
required this.genreIds,
|
||||
required this.popularity,
|
||||
required this.firstAirDate,
|
||||
required this.voteAverage,
|
||||
required this.voteCount,
|
||||
required this.originCountry,
|
||||
this.inWatchlist
|
||||
});
|
||||
SearchResult(
|
||||
{required this.backdropPath,
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.originalName,
|
||||
required this.overview,
|
||||
required this.posterPath,
|
||||
required this.mediaType,
|
||||
required this.adult,
|
||||
required this.originalLanguage,
|
||||
required this.genreIds,
|
||||
required this.popularity,
|
||||
required this.firstAirDate,
|
||||
required this.voteAverage,
|
||||
required this.voteCount,
|
||||
required this.originCountry,
|
||||
this.inWatchlist});
|
||||
|
||||
final String? backdropPath;
|
||||
final int? id;
|
||||
@@ -258,10 +257,12 @@ class MovieTorrentResource
|
||||
return (rsp.data as List).map((v) => TorrentResource.fromJson(v)).toList();
|
||||
}
|
||||
|
||||
Future<void> download(String link) async {
|
||||
Future<void> download(TorrentResource res) async {
|
||||
var m = res.toJson();
|
||||
m["media_id"] = int.parse(mediaId!);
|
||||
|
||||
final dio = await APIs.getDio();
|
||||
var resp = await dio.post(APIs.availableMoviesUrl,
|
||||
data: {"media_id": int.parse(mediaId!), "link": link});
|
||||
var resp = await dio.post(APIs.availableMoviesUrl, data: m);
|
||||
var rsp = ServerResponse.fromJson(resp.data);
|
||||
if (rsp.code != 0) {
|
||||
throw rsp.message;
|
||||
@@ -286,4 +287,11 @@ class TorrentResource {
|
||||
peers: json["peers"],
|
||||
link: json["link"]);
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['name'] = name;
|
||||
data['size'] = size;
|
||||
data["link"] = link;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user