mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-28 03:58:39 +00:00
mod: try-catch some requests
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -604,21 +604,24 @@ class BangumiIntroController extends CommonController {
|
|||||||
RxInt followStatus = (-1).obs;
|
RxInt followStatus = (-1).obs;
|
||||||
|
|
||||||
Future queryIsFollowed() async {
|
Future queryIsFollowed() async {
|
||||||
dynamic result = await Request().get(
|
try {
|
||||||
'https://www.bilibili.com/bangumi/play/ss$seasonId',
|
dynamic result = await Request().get(
|
||||||
);
|
'https://www.bilibili.com/bangumi/play/ss$seasonId',
|
||||||
dom.Document document = html_parser.parse(result.data);
|
);
|
||||||
dom.Element? scriptElement = document.querySelector('script#__NEXT_DATA__');
|
dom.Document document = html_parser.parse(result.data);
|
||||||
if (scriptElement != null) {
|
dom.Element? scriptElement =
|
||||||
dynamic scriptContent = jsonDecode(scriptElement.text);
|
document.querySelector('script#__NEXT_DATA__');
|
||||||
isFollowed.value =
|
if (scriptElement != null) {
|
||||||
scriptContent['props']['pageProps']['followState']['isFollowed'];
|
dynamic scriptContent = jsonDecode(scriptElement.text);
|
||||||
followStatus.value =
|
isFollowed.value =
|
||||||
scriptContent['props']['pageProps']['followState']['followStatus'];
|
scriptContent['props']['pageProps']['followState']['isFollowed'];
|
||||||
// int progress = scriptContent['props']['pageProps']['dehydratedState']
|
followStatus.value =
|
||||||
// ['queries'][0]['state']['data']['result']
|
scriptContent['props']['pageProps']['followState']['followStatus'];
|
||||||
// ['play_view_business_info']['user_status']['watch_progress']
|
// int progress = scriptContent['props']['pageProps']['dehydratedState']
|
||||||
// ['current_watch_progress'];
|
// ['queries'][0]['state']['data']['result']
|
||||||
}
|
// ['play_view_business_info']['user_status']['watch_progress']
|
||||||
|
// ['current_watch_progress'];
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,10 +105,12 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void querySearchDefault() async {
|
void querySearchDefault() async {
|
||||||
var res = await Request().get(Api.searchDefault);
|
try {
|
||||||
if (res.data['code'] == 0) {
|
var res = await Request().get(Api.searchDefault);
|
||||||
defaultSearch.value = res.data['data']['name'];
|
if (res.data['code'] == 0) {
|
||||||
}
|
defaultSearch.value = res.data['data']['name'];
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
showUserInfoDialog(context) {
|
showUserInfoDialog(context) {
|
||||||
|
|||||||
@@ -124,37 +124,41 @@ class MainController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future _queryPMUnread() async {
|
Future _queryPMUnread() async {
|
||||||
dynamic res = await Request().get(Api.msgUnread);
|
try {
|
||||||
if (res.data['code'] == 0) {
|
dynamic res = await Request().get(Api.msgUnread);
|
||||||
return {
|
if (res.data['code'] == 0) {
|
||||||
'status': true,
|
return {
|
||||||
'data': ((res.data['data']?['unfollow_unread'] as int?) ?? 0) +
|
'status': true,
|
||||||
((res.data['data']?['follow_unread'] as int?) ?? 0),
|
'data': ((res.data['data']?['unfollow_unread'] as int?) ?? 0) +
|
||||||
};
|
((res.data['data']?['follow_unread'] as int?) ?? 0),
|
||||||
} else {
|
};
|
||||||
return {
|
} else {
|
||||||
'status': false,
|
return {
|
||||||
'msg': res.data['message'],
|
'status': false,
|
||||||
};
|
'msg': res.data['message'],
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _queryMsgFeedUnread() async {
|
Future _queryMsgFeedUnread() async {
|
||||||
if (isLogin.value.not) {
|
if (isLogin.value.not) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dynamic res = await Request().get(Api.msgFeedUnread);
|
try {
|
||||||
if (res.data['code'] == 0) {
|
dynamic res = await Request().get(Api.msgFeedUnread);
|
||||||
return {
|
if (res.data['code'] == 0) {
|
||||||
'status': true,
|
return {
|
||||||
'data': res.data['data'],
|
'status': true,
|
||||||
};
|
'data': res.data['data'],
|
||||||
} else {
|
};
|
||||||
return {
|
} else {
|
||||||
'status': false,
|
return {
|
||||||
'msg': res.data['message'],
|
'status': false,
|
||||||
};
|
'msg': res.data['message'],
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getUnreadDynamic() async {
|
void getUnreadDynamic() async {
|
||||||
|
|||||||
Reference in New Issue
Block a user