Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

fix-anime-get

lauirf8b77b2892baa
diff --git a/lib/pages/timeline/timeline_controller.dart b/lib/pages/timeline/timeline_controller.dart
index 4de546c1..7d74e45e 100644
--- a/lib/pages/timeline/timeline_controller.dart
+++ b/lib/pages/timeline/timeline_controller.dart
@@ -21,6 +21,20 @@ abstract class _TimelineController with Store {
}
Future<void> getSchedulesBySeason() async {
- bangumiCalendar = await BangumiHTTP.getCalendarBySearch(AnimeSeason(selectedDate).toSeasonStartAndEnd());
+ // 4次获取,每次最多20部
+ var time = 0;
+ const maxTime = 4;
+ const limit = 20;
+ bangumiCalendar = List.generate(7, (_) => <BangumiItem>[]);
+ for (time = 0; time < maxTime; time++) {
+ final offset = time * limit;
+ var newList = await BangumiHTTP.getCalendarBySearch(
+ AnimeSeason(selectedDate).toSeasonStartAndEnd(), limit, offset);
+ for (int i = 0; i < bangumiCalendar.length; ++i) {
+ bangumiCalendar[i].addAll(newList[i]);
+ }
+ // MobX
+ bangumiCalendar = List.from(bangumiCalendar);
+ }
}
}
\ No newline at end of file
diff --git a/lib/request/api.dart b/lib/request/api.dart
index 9c94601f..61bf19ec 100644
--- a/lib/request/api.dart
+++ b/lib/request/api.dart
@@ -21,7 +21,7 @@ class Api {
// 番剧检索 (弃用)
static const String bangumiSearch = 'https://api.bgm.tv/search/subject/';
// 条目搜索
- static const String bangumiRankSearch = 'https://api.bgm.tv/v0/search/subjects?limit=100';
+ static const String bangumiRankSearch = 'https://api.bgm.tv/v0/search/subjects?limit={0}&offset={1}';
// 从条目ID获取详细信息
static const String bangumiInfoByID = 'https://api.bgm.tv/v0/subjects/';
// 从条目ID获取剧集ID
@@ -33,4 +33,11 @@ class Api {
static const String dandanAPI = "https://api.dandanplay.net/api/v2/comment/";
static const String dandanSearch = "https://api.dandanplay.net/api/v2/search/anime";
static const String dandanInfo = "https://api.dandanplay.net/api/v2/bangumi/";
+
+ static String formatUrl(String url, List<dynamic> params) {
+ for (int i = 0; i < params.length; i++) {
+ url = url.replaceAll('{$i}', params[i].toString());
+ }
+ return url;
+ }
}
\ No newline at end of file
diff --git a/lib/request/bangumi.dart b/lib/request/bangumi.dart
index 2a0325bd..11300f0d 100644
--- a/lib/request/bangumi.dart
+++ b/lib/request/bangumi.dart
@@ -43,7 +43,7 @@ class BangumiHTTP {
// Get clander by search API, we need a list of strings (the start of the season and the end of the season) eg: ["2024-07-01", "2024-10-01"]
// because the air date is the launch date of the anime, it is usually a few days before the start of the season
// So we usually use the start of the season month -1 and the end of the season month -1
- static Future<List<List<BangumiItem>>> getCalendarBySearch(List<String> dateRange) async {
+ static Future<List<List<BangumiItem>>> getCalendarBySearch(List<String> dateRange, int limit, int offset) async {
List<BangumiItem> bangumiList = [];
List<List<BangumiItem>> bangumiCalendar = [];
var params = <String, dynamic>{
@@ -57,7 +57,8 @@ class BangumiHTTP {
}
};
try {
- final res = await Request().post(Api.bangumiRankSearch,
+ final url = Api.formatUrl(Api.bangumiRankSearch, [limit, offset]);
+ final res = await Request().post(url,
data: params,
options: Options(
headers: bangumiHTTPHeader, contentType: 'application/json'));