Skip to content

Commit

Permalink
add bilibili support
Browse files Browse the repository at this point in the history
  • Loading branch information
kidozh committed Nov 28, 2024
1 parent 21c9e83 commit 90ee923
Show file tree
Hide file tree
Showing 12 changed files with 602 additions and 45 deletions.
68 changes: 68 additions & 0 deletions lib/JsonResult/BilibiliVideoResult.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@


import 'package:discuz_flutter/converter/SecondToDateTimeConverter.dart';
import 'package:json_annotation/json_annotation.dart';

part 'BilibiliVideoResult.g.dart';

@JsonSerializable()
class BilibiliVideoResult{

int code = 0;
String message = "";
int ttl = 0;

BilibiliVideoData data = BilibiliVideoData();



BilibiliVideoResult();

factory BilibiliVideoResult.fromJson(Map<String, dynamic> json) => _$BilibiliVideoResultFromJson(json);
}

@JsonSerializable()
class BilibiliVideoData{
@JsonKey(name: "View")
BilibiliVideoViewData viewData = BilibiliVideoViewData();

BilibiliVideoData();

factory BilibiliVideoData.fromJson(Map<String, dynamic> json) => _$BilibiliVideoDataFromJson(json);
}

@JsonSerializable()
class BilibiliVideoViewData{

String bvid = "";
int aid = 0;
int videos = 0;
int tid = 0;
String tname = "";
int copyright = 1;
String pic = "";
String title = "";
int pubdate = 0, ctime = 0;
String desc = "";
int state = 0;
int duration = 0, mission_id=0;

BilibiliVideoViewDataOwner owner = BilibiliVideoViewDataOwner();


BilibiliVideoViewData();

factory BilibiliVideoViewData.fromJson(Map<String, dynamic> json) => _$BilibiliVideoViewDataFromJson(json);
}

@JsonSerializable()
class BilibiliVideoViewDataOwner{

int mid = 0;
String name = "", face="";

BilibiliVideoViewDataOwner();

factory BilibiliVideoViewDataOwner.fromJson(Map<String, dynamic> json) => _$BilibiliVideoViewDataOwnerFromJson(json);

}
88 changes: 88 additions & 0 deletions lib/JsonResult/BilibiliVideoResult.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions lib/client/BilibiliApiClient.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@


import 'package:dio/dio.dart';
import 'package:discuz_flutter/JsonResult/BilibiliVideoResult.dart';
import 'package:retrofit/error_logger.dart';
import 'package:retrofit/http.dart';

part 'BilibiliApiClient.g.dart';

@RestApi(baseUrl: "https://api.bilibili.com")
abstract class BilibiliApiClient {
factory BilibiliApiClient(Dio dio, {required String baseUrl}) = _BilibiliApiClient;

@GET("/x/web-interface/view/detail")
Future<BilibiliVideoResult> getVideoResultByAid(
@Query("aid") String aid,
);

@GET("/x/web-interface/view/detail")
Future<BilibiliVideoResult> getVideoResultByBvid(
@Query("bvid") String bvid,
);
}
121 changes: 121 additions & 0 deletions lib/client/BilibiliApiClient.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/client/CheveretoApiClient.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/client/MobileApiClient.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/client/PushServiceClient.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/client/UtilityServiceApiClient.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 90ee923

Please sign in to comment.