mirror of
https://github.com/simon-ding/polaris.git
synced 2026-04-21 03:07:30 +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{
|
history, err := s.db.SaveHistoryRecord(ent.History{
|
||||||
MediaID: media.ID,
|
MediaID: media.ID,
|
||||||
EpisodeID: ep.ID,
|
EpisodeID: ep.ID,
|
||||||
SourceTitle: media.NameCn,
|
SourceTitle: in.Name,
|
||||||
TargetDir: "./",
|
TargetDir: "./",
|
||||||
Status: history.StatusRunning,
|
Status: history.StatusRunning,
|
||||||
Size: in.Size,
|
Size: in.Size,
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ class _NestedTabBarState extends ConsumerState<NestedTabBar>
|
|||||||
ref
|
ref
|
||||||
.read(movieTorrentsDataProvider(widget.id)
|
.read(movieTorrentsDataProvider(widget.id)
|
||||||
.notifier)
|
.notifier)
|
||||||
.download(torrent.link!)
|
.download(torrent)
|
||||||
.whenComplete(() =>
|
.whenComplete(() =>
|
||||||
Utils.showSnakeBar("开始下载:${torrent.name}"))
|
Utils.showSnakeBar("开始下载:${torrent.name}"))
|
||||||
.onError((error, trace) =>
|
.onError((error, trace) =>
|
||||||
|
|||||||
@@ -181,24 +181,23 @@ class MediaDetail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SearchResult {
|
class SearchResult {
|
||||||
SearchResult({
|
SearchResult(
|
||||||
required this.backdropPath,
|
{required this.backdropPath,
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.originalName,
|
required this.originalName,
|
||||||
required this.overview,
|
required this.overview,
|
||||||
required this.posterPath,
|
required this.posterPath,
|
||||||
required this.mediaType,
|
required this.mediaType,
|
||||||
required this.adult,
|
required this.adult,
|
||||||
required this.originalLanguage,
|
required this.originalLanguage,
|
||||||
required this.genreIds,
|
required this.genreIds,
|
||||||
required this.popularity,
|
required this.popularity,
|
||||||
required this.firstAirDate,
|
required this.firstAirDate,
|
||||||
required this.voteAverage,
|
required this.voteAverage,
|
||||||
required this.voteCount,
|
required this.voteCount,
|
||||||
required this.originCountry,
|
required this.originCountry,
|
||||||
this.inWatchlist
|
this.inWatchlist});
|
||||||
});
|
|
||||||
|
|
||||||
final String? backdropPath;
|
final String? backdropPath;
|
||||||
final int? id;
|
final int? id;
|
||||||
@@ -258,10 +257,12 @@ class MovieTorrentResource
|
|||||||
return (rsp.data as List).map((v) => TorrentResource.fromJson(v)).toList();
|
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();
|
final dio = await APIs.getDio();
|
||||||
var resp = await dio.post(APIs.availableMoviesUrl,
|
var resp = await dio.post(APIs.availableMoviesUrl, data: m);
|
||||||
data: {"media_id": int.parse(mediaId!), "link": link});
|
|
||||||
var rsp = ServerResponse.fromJson(resp.data);
|
var rsp = ServerResponse.fromJson(resp.data);
|
||||||
if (rsp.code != 0) {
|
if (rsp.code != 0) {
|
||||||
throw rsp.message;
|
throw rsp.message;
|
||||||
@@ -286,4 +287,11 @@ class TorrentResource {
|
|||||||
peers: json["peers"],
|
peers: json["peers"],
|
||||||
link: json["link"]);
|
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