mod: app端首页推荐接口
This commit is contained in:
@ -4,6 +4,7 @@ import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/widgets/stat/danmu.dart';
|
||||
import 'package:pilipala/common/widgets/stat/view.dart';
|
||||
import 'package:pilipala/pages/rcmd/index.dart';
|
||||
import 'package:pilipala/utils/id_utils.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'package:pilipala/pages/home/controller.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
@ -45,8 +46,8 @@ class VideoCardV extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
print(videoItem.bvid);
|
||||
Get.toNamed('/video?bvid=${videoItem.bvid}&cid=${videoItem.cid}',
|
||||
String bvid = videoItem.bvid ?? IdUtils.av2bv(videoItem.aid);
|
||||
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.cid}',
|
||||
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
|
||||
},
|
||||
child: Column(
|
||||
@ -74,20 +75,22 @@ class VideoCardV extends StatelessWidget {
|
||||
height: maxHeight,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: AnimatedOpacity(
|
||||
opacity: 1,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: VideoStat(
|
||||
view: videoItem.stat.view,
|
||||
danmaku: videoItem.stat.danmaku,
|
||||
duration: videoItem.duration,
|
||||
if (videoItem.stat.view is int &&
|
||||
videoItem.stat.danmaku is int)
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: AnimatedOpacity(
|
||||
opacity: 1,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: VideoStat(
|
||||
view: videoItem.stat.view,
|
||||
danmaku: videoItem.stat.danmaku,
|
||||
duration: videoItem.duration,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
@ -131,7 +134,8 @@ class VideoContent extends StatelessWidget {
|
||||
height: 18,
|
||||
child: Row(
|
||||
children: [
|
||||
if (videoItem.rcmdReason.content != '') ...[
|
||||
if (videoItem.rcmdReason != null &&
|
||||
videoItem.rcmdReason.content != '') ...[
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(3, 1, 3, 1),
|
||||
decoration: BoxDecoration(
|
||||
|
@ -1,7 +1,7 @@
|
||||
class Api {
|
||||
// 推荐视频
|
||||
// static const String recommendList =
|
||||
// 'https://app.bilibili.com/x/v2/feed/index?appkey=27eb53fc9058f8c3';
|
||||
static const String recommendListApp =
|
||||
'https://app.bilibili.com/x/v2/feed/index';
|
||||
static const String recommendList = '/x/web-interface/index/top/feed/rcmd';
|
||||
|
||||
// 热门视频
|
||||
|
@ -4,6 +4,8 @@ import 'dart:io';
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:cookie_jar/cookie_jar.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'package:pilipala/http/constants.dart';
|
||||
import 'package:pilipala/http/interceptor.dart';
|
||||
@ -88,10 +90,14 @@ class Request {
|
||||
"app-key": 'android',
|
||||
"x-bili-aurora-eid": 'UlMFQVcABlAH',
|
||||
"x-bili-aurora-zone": 'sh001',
|
||||
// "x-bili-mid": ''
|
||||
'referer': 'https://www.bilibili.com/',
|
||||
},
|
||||
);
|
||||
|
||||
Box user = GStrorage.user;
|
||||
if (user.get(UserBoxKey.userMid) != null) {
|
||||
options.headers['x-bili-mid'] = user.get(UserBoxKey.userMid).toString();
|
||||
}
|
||||
dio.options = options;
|
||||
|
||||
//添加拦截器
|
||||
|
@ -3,6 +3,7 @@ import 'dart:developer';
|
||||
import 'package:pilipala/http/api.dart';
|
||||
import 'package:pilipala/http/init.dart';
|
||||
import 'package:pilipala/models/common/reply_type.dart';
|
||||
import 'package:pilipala/models/home/rcmd/result.dart';
|
||||
import 'package:pilipala/models/model_hot_video_item.dart';
|
||||
import 'package:pilipala/models/model_rec_video_item.dart';
|
||||
import 'package:pilipala/models/user/fav_folder.dart';
|
||||
@ -20,9 +21,11 @@ class VideoHttp {
|
||||
var res = await Request().get(
|
||||
Api.recommendList,
|
||||
data: {
|
||||
'version': 1,
|
||||
'feed_version': 'V3',
|
||||
'ps': ps,
|
||||
'fresh_idx': freshIdx,
|
||||
'fresh_type': 999999
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
@ -39,6 +42,35 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future rcmdVideoListApp(
|
||||
{required int ps, required int freshIdx}) async {
|
||||
try {
|
||||
var res = await Request().get(
|
||||
Api.recommendListApp,
|
||||
data: {
|
||||
'idx': freshIdx,
|
||||
'flush': '5',
|
||||
'column': '4',
|
||||
'device': 'pad',
|
||||
'device_type': 0,
|
||||
'device_name': 'vivo',
|
||||
'pull': freshIdx == 0 ? 'true' : 'false',
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
List<RecVideoItemAppModel> list = [];
|
||||
for (var i in res.data['data']['items']) {
|
||||
list.add(RecVideoItemAppModel.fromJson(i));
|
||||
}
|
||||
return {'status': true, 'data': list};
|
||||
} else {
|
||||
return {'status': false, 'data': [], 'msg': ''};
|
||||
}
|
||||
} catch (err) {
|
||||
return {'status': false, 'data': [], 'msg': err.toString()};
|
||||
}
|
||||
}
|
||||
|
||||
// 最热视频
|
||||
static Future hotVideoList({required int pn, required int ps}) async {
|
||||
try {
|
||||
|
65
lib/models/home/rcmd/result.dart
Normal file
65
lib/models/home/rcmd/result.dart
Normal file
@ -0,0 +1,65 @@
|
||||
class RecVideoItemAppModel {
|
||||
RecVideoItemAppModel({
|
||||
this.id,
|
||||
this.aid,
|
||||
this.bvid,
|
||||
this.cid,
|
||||
this.pic,
|
||||
this.stat,
|
||||
this.duration,
|
||||
this.title,
|
||||
this.isFollowed,
|
||||
this.owner,
|
||||
this.rcmdReason,
|
||||
});
|
||||
|
||||
int? id;
|
||||
int? aid;
|
||||
int? bvid;
|
||||
int? cid;
|
||||
String? pic;
|
||||
Stat? stat;
|
||||
int? duration;
|
||||
String? title;
|
||||
int? isFollowed;
|
||||
Owner? owner;
|
||||
String? rcmdReason;
|
||||
|
||||
RecVideoItemAppModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['player_args']['aid'];
|
||||
aid = json['player_args']['aid'];
|
||||
cid = json['player_args']['cid'];
|
||||
pic = json['cover'];
|
||||
stat = Stat.fromJson(json);
|
||||
duration = json['player_args']['duration'];
|
||||
title = json['title'];
|
||||
isFollowed = 0;
|
||||
owner = Owner.fromJson(json);
|
||||
}
|
||||
}
|
||||
|
||||
class Stat {
|
||||
Stat({
|
||||
this.view,
|
||||
this.like,
|
||||
this.danmaku,
|
||||
});
|
||||
String? view;
|
||||
String? like;
|
||||
String? danmaku;
|
||||
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
view = json["cover_left_text_1"];
|
||||
danmaku = json['cover_left_text_2'];
|
||||
}
|
||||
}
|
||||
|
||||
class Owner {
|
||||
Owner({this.name});
|
||||
|
||||
String? name;
|
||||
|
||||
Owner.fromJson(Map<String, dynamic> json) {
|
||||
name = json['args']['up_name'];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user