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/danmu.dart';
|
||||||
import 'package:pilipala/common/widgets/stat/view.dart';
|
import 'package:pilipala/common/widgets/stat/view.dart';
|
||||||
import 'package:pilipala/pages/rcmd/index.dart';
|
import 'package:pilipala/pages/rcmd/index.dart';
|
||||||
|
import 'package:pilipala/utils/id_utils.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
import 'package:pilipala/pages/home/controller.dart';
|
import 'package:pilipala/pages/home/controller.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
@ -45,8 +46,8 @@ class VideoCardV extends StatelessWidget {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Future.delayed(const Duration(milliseconds: 200));
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
print(videoItem.bvid);
|
String bvid = videoItem.bvid ?? IdUtils.av2bv(videoItem.aid);
|
||||||
Get.toNamed('/video?bvid=${videoItem.bvid}&cid=${videoItem.cid}',
|
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.cid}',
|
||||||
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
|
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -74,20 +75,22 @@ class VideoCardV extends StatelessWidget {
|
|||||||
height: maxHeight,
|
height: maxHeight,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
if (videoItem.stat.view is int &&
|
||||||
left: 0,
|
videoItem.stat.danmaku is int)
|
||||||
right: 0,
|
Positioned(
|
||||||
bottom: 0,
|
left: 0,
|
||||||
child: AnimatedOpacity(
|
right: 0,
|
||||||
opacity: 1,
|
bottom: 0,
|
||||||
duration: const Duration(milliseconds: 200),
|
child: AnimatedOpacity(
|
||||||
child: VideoStat(
|
opacity: 1,
|
||||||
view: videoItem.stat.view,
|
duration: const Duration(milliseconds: 200),
|
||||||
danmaku: videoItem.stat.danmaku,
|
child: VideoStat(
|
||||||
duration: videoItem.duration,
|
view: videoItem.stat.view,
|
||||||
|
danmaku: videoItem.stat.danmaku,
|
||||||
|
duration: videoItem.duration,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@ -131,7 +134,8 @@ class VideoContent extends StatelessWidget {
|
|||||||
height: 18,
|
height: 18,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (videoItem.rcmdReason.content != '') ...[
|
if (videoItem.rcmdReason != null &&
|
||||||
|
videoItem.rcmdReason.content != '') ...[
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.fromLTRB(3, 1, 3, 1),
|
padding: const EdgeInsets.fromLTRB(3, 1, 3, 1),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
class Api {
|
class Api {
|
||||||
// 推荐视频
|
// 推荐视频
|
||||||
// static const String recommendList =
|
static const String recommendListApp =
|
||||||
// 'https://app.bilibili.com/x/v2/feed/index?appkey=27eb53fc9058f8c3';
|
'https://app.bilibili.com/x/v2/feed/index';
|
||||||
static const String recommendList = '/x/web-interface/index/top/feed/rcmd';
|
static const String recommendList = '/x/web-interface/index/top/feed/rcmd';
|
||||||
|
|
||||||
// 热门视频
|
// 热门视频
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import 'dart:io';
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:cookie_jar/cookie_jar.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/utils/utils.dart';
|
||||||
import 'package:pilipala/http/constants.dart';
|
import 'package:pilipala/http/constants.dart';
|
||||||
import 'package:pilipala/http/interceptor.dart';
|
import 'package:pilipala/http/interceptor.dart';
|
||||||
@ -88,10 +90,14 @@ class Request {
|
|||||||
"app-key": 'android',
|
"app-key": 'android',
|
||||||
"x-bili-aurora-eid": 'UlMFQVcABlAH',
|
"x-bili-aurora-eid": 'UlMFQVcABlAH',
|
||||||
"x-bili-aurora-zone": 'sh001',
|
"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;
|
dio.options = options;
|
||||||
|
|
||||||
//添加拦截器
|
//添加拦截器
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'dart:developer';
|
|||||||
import 'package:pilipala/http/api.dart';
|
import 'package:pilipala/http/api.dart';
|
||||||
import 'package:pilipala/http/init.dart';
|
import 'package:pilipala/http/init.dart';
|
||||||
import 'package:pilipala/models/common/reply_type.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_hot_video_item.dart';
|
||||||
import 'package:pilipala/models/model_rec_video_item.dart';
|
import 'package:pilipala/models/model_rec_video_item.dart';
|
||||||
import 'package:pilipala/models/user/fav_folder.dart';
|
import 'package:pilipala/models/user/fav_folder.dart';
|
||||||
@ -20,9 +21,11 @@ class VideoHttp {
|
|||||||
var res = await Request().get(
|
var res = await Request().get(
|
||||||
Api.recommendList,
|
Api.recommendList,
|
||||||
data: {
|
data: {
|
||||||
|
'version': 1,
|
||||||
'feed_version': 'V3',
|
'feed_version': 'V3',
|
||||||
'ps': ps,
|
'ps': ps,
|
||||||
'fresh_idx': freshIdx,
|
'fresh_idx': freshIdx,
|
||||||
|
'fresh_type': 999999
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (res.data['code'] == 0) {
|
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 {
|
static Future hotVideoList({required int pn, required int ps}) async {
|
||||||
try {
|
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