mod: 接口整理、增加up粉丝请求
This commit is contained in:
@ -5,8 +5,12 @@ class Api {
|
||||
static const String hotList = '/x/web-interface/popular';
|
||||
// 视频详情
|
||||
// 竖屏 https://api.bilibili.com/x/web-interface/view?aid=527403921
|
||||
static const String videoDetail = '/x/web-interface/view';
|
||||
static const String videoIntro = '/x/web-interface/view';
|
||||
|
||||
// 视频详情页 相关视频
|
||||
static const String relatedList = '/x/web-interface/archive/related';
|
||||
|
||||
// 用户(被)关注数、投稿数
|
||||
// https://api.bilibili.com/x/relation/stat?vmid=697166795
|
||||
static const String userStat = '/x/relation/stat';
|
||||
}
|
||||
|
||||
13
lib/http/user.dart
Normal file
13
lib/http/user.dart
Normal file
@ -0,0 +1,13 @@
|
||||
import 'package:pilipala/http/api.dart';
|
||||
import 'package:pilipala/http/init.dart';
|
||||
|
||||
class UserHttp {
|
||||
static Future<dynamic> userStat(mid) async {
|
||||
var res = await Request().get(Api.userStat, data: {'vmid': mid});
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,58 @@
|
||||
import 'package:pilipala/http/api.dart';
|
||||
import 'package:pilipala/http/init.dart';
|
||||
import 'package:pilipala/models/model_hot_video_item.dart';
|
||||
import 'package:pilipala/models/model_rec_video_item.dart';
|
||||
import 'package:pilipala/models/video_detail_res.dart';
|
||||
|
||||
/// res.data['code'] == 0 请求正常返回结果
|
||||
/// res.data['data'] 为结果
|
||||
/// 返回{'status': bool, 'data': List}
|
||||
/// view层根据 status 判断渲染逻辑
|
||||
class VideoHttp {
|
||||
// 首页推荐视频
|
||||
static Future rcmdVideoList(data) async {
|
||||
var res = await Request().get(
|
||||
Api.recommendList,
|
||||
data: {
|
||||
'feed_version': 'V3',
|
||||
'ps': data['ps'],
|
||||
'fresh_idx': data['fresh_idx']
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
List<RecVideoItemModel> list = [];
|
||||
for (var i in res.data['data']['item']) {
|
||||
list.add(RecVideoItemModel.fromJson(i));
|
||||
}
|
||||
return {'status': true, 'data': list};
|
||||
} else {
|
||||
return {'status': false, 'data': []};
|
||||
}
|
||||
}
|
||||
|
||||
// 最热视频
|
||||
static Future hotVideoList(data) async {
|
||||
var res = await Request().get(
|
||||
Api.hotList,
|
||||
data: {
|
||||
'pn': data['pn'],
|
||||
'ps': data['ps'],
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
List<HotVideoItemModel> list = [];
|
||||
for (var i in res.data['data']['list']) {
|
||||
list.add(HotVideoItemModel.fromJson(i));
|
||||
}
|
||||
return {'status': true, 'data': list};
|
||||
} else {
|
||||
return {'status': false, 'data': []};
|
||||
}
|
||||
}
|
||||
|
||||
// 视频信息 标题、简介
|
||||
static Future videoDetail(data) async {
|
||||
var res = await Request().get(Api.videoDetail, data: data);
|
||||
static Future videoIntro(aid) async {
|
||||
var res = await Request().get(Api.videoIntro, data: {'aid': aid});
|
||||
VideoDetailResponse result = VideoDetailResponse.fromJson(res.data);
|
||||
if (result.code == 0) {
|
||||
return {'status': true, 'data': result.data!};
|
||||
@ -25,8 +72,17 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future videoRecommend(data) async {
|
||||
var res = await Request().get(Api.relatedList, data: data);
|
||||
return res;
|
||||
// 相关视频
|
||||
static Future relatedVideoList(aid) async {
|
||||
var res = await Request().get(Api.relatedList, data: {'aid': aid});
|
||||
if (res.data['code'] == 0) {
|
||||
List<HotVideoItemModel> list = [];
|
||||
for (var i in res.data['data']) {
|
||||
list.add(HotVideoItemModel.fromJson(i));
|
||||
}
|
||||
return {'status': true, 'data': list};
|
||||
} else {
|
||||
return {'status': true, 'data': []};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user