mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: fallback to pgc api
Closes #156 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:developer';
|
|||||||
import 'package:PiliPlus/grpc/app/card/v1/card.pb.dart' as card;
|
import 'package:PiliPlus/grpc/app/card/v1/card.pb.dart' as card;
|
||||||
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import '../common/constants.dart';
|
import '../common/constants.dart';
|
||||||
@@ -216,6 +217,7 @@ class VideoHttp {
|
|||||||
int? qn,
|
int? qn,
|
||||||
dynamic epid,
|
dynamic epid,
|
||||||
dynamic seasonId,
|
dynamic seasonId,
|
||||||
|
bool? forcePgcApi,
|
||||||
}) async {
|
}) async {
|
||||||
Map<String, dynamic> data = {
|
Map<String, dynamic> data = {
|
||||||
if (avid != null) 'avid': avid,
|
if (avid != null) 'avid': avid,
|
||||||
@@ -243,15 +245,17 @@ class VideoHttp {
|
|||||||
'web_location': 1550101,
|
'web_location': 1550101,
|
||||||
});
|
});
|
||||||
|
|
||||||
late final isLogin = GStorage.isLogin;
|
final usePgcApi = forcePgcApi == true || GStorage.isLogin;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var res = await Request().get(
|
var res = await Request().get(
|
||||||
epid != null && isLogin ? Api.bangumiVideoUrl : Api.videoUrl,
|
epid != null && usePgcApi ? Api.bangumiVideoUrl : Api.videoUrl,
|
||||||
queryParameters: params);
|
queryParameters: params,
|
||||||
|
);
|
||||||
|
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
late PlayUrlModel data;
|
late PlayUrlModel data;
|
||||||
if (epid != null && isLogin) {
|
if (epid != null && usePgcApi) {
|
||||||
data = PlayUrlModel.fromJson(res.data['result']['video_info'])
|
data = PlayUrlModel.fromJson(res.data['result']['video_info'])
|
||||||
..lastPlayTime = res.data['result']['play_view_business_info']
|
..lastPlayTime = res.data['result']['play_view_business_info']
|
||||||
['user_status']['watch_progress']['current_watch_progress'];
|
['user_status']['watch_progress']['current_watch_progress'];
|
||||||
@@ -263,6 +267,17 @@ class VideoHttp {
|
|||||||
'data': data,
|
'data': data,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
if (epid != null && usePgcApi.not && forcePgcApi != true) {
|
||||||
|
return videoUrl(
|
||||||
|
avid: avid,
|
||||||
|
bvid: bvid,
|
||||||
|
cid: cid,
|
||||||
|
qn: qn,
|
||||||
|
epid: epid,
|
||||||
|
seasonId: seasonId,
|
||||||
|
forcePgcApi: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
'status': false,
|
'status': false,
|
||||||
'data': [],
|
'data': [],
|
||||||
|
|||||||
Reference in New Issue
Block a user