opt: up主投稿跳转番剧
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/constants.dart';
|
||||
import 'package:pilipala/utils/image_save.dart';
|
||||
import 'package:pilipala/utils/route_push.dart';
|
||||
import 'package:pilipala/utils/url_utils.dart';
|
||||
import '../../http/search.dart';
|
||||
import '../../http/user.dart';
|
||||
import '../../http/video.dart';
|
||||
@ -52,6 +55,20 @@ class VideoCardH extends StatelessWidget {
|
||||
SmartDialog.showToast('课堂视频暂不支持播放');
|
||||
return;
|
||||
}
|
||||
if (showCharge && videoItem?.typeid == 33) {
|
||||
final String redirectUrl = await UrlUtils.parseRedirectUrl(
|
||||
'${HttpString.baseUrl}/video/$bvid/');
|
||||
final String lastPathSegment = redirectUrl.split('/').last;
|
||||
if (lastPathSegment.contains('ss')) {
|
||||
RoutePush.bangumiPush(
|
||||
Utils.matchNum(lastPathSegment).first, null);
|
||||
}
|
||||
if (lastPathSegment.contains('ep')) {
|
||||
RoutePush.bangumiPush(
|
||||
null, Utils.matchNum(lastPathSegment).first);
|
||||
}
|
||||
return;
|
||||
}
|
||||
final int cid =
|
||||
videoItem.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||
Get.toNamed('/video?bvid=$bvid&cid=$cid',
|
||||
|
@ -50,13 +50,6 @@ class ChatItem extends StatelessWidget {
|
||||
this.e_infos,
|
||||
});
|
||||
|
||||
static List<int> matchNum(String str) {
|
||||
final RegExp regExp = RegExp(r'\d+');
|
||||
final Iterable<Match> matches = regExp.allMatches(str);
|
||||
|
||||
return matches.map((Match match) => int.parse(match.group(0)!)).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isOwner =
|
||||
@ -183,9 +176,9 @@ class ChatItem extends StatelessWidget {
|
||||
if (url != null) {
|
||||
final String area = url.split('/').last;
|
||||
if (area.startsWith('ep')) {
|
||||
RoutePush.bangumiPush(null, matchNum(area).first);
|
||||
RoutePush.bangumiPush(null, Utils.matchNum(area).first);
|
||||
} else if (area.startsWith('ss')) {
|
||||
RoutePush.bangumiPush(matchNum(area).first, null);
|
||||
RoutePush.bangumiPush(Utils.matchNum(area).first, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,15 +144,15 @@ class PiliSchame {
|
||||
_videoPush(null, lastPathSegment);
|
||||
}
|
||||
if (lastPathSegment.contains('av')) {
|
||||
_videoPush(matchNum(lastPathSegment)[0], null);
|
||||
_videoPush(Utils.matchNum(lastPathSegment)[0], null);
|
||||
}
|
||||
}
|
||||
if (path.startsWith('/bangumi')) {
|
||||
if (lastPathSegment.contains('ss')) {
|
||||
RoutePush.bangumiPush(matchNum(lastPathSegment).first, null);
|
||||
RoutePush.bangumiPush(Utils.matchNum(lastPathSegment).first, null);
|
||||
}
|
||||
if (lastPathSegment.contains('ep')) {
|
||||
RoutePush.bangumiPush(null, matchNum(lastPathSegment).first);
|
||||
RoutePush.bangumiPush(null, Utils.matchNum(lastPathSegment).first);
|
||||
}
|
||||
}
|
||||
} else if (host.contains('live')) {
|
||||
@ -205,9 +205,9 @@ class PiliSchame {
|
||||
case 'bangumi':
|
||||
print('番剧');
|
||||
if (area.startsWith('ep')) {
|
||||
RoutePush.bangumiPush(null, matchNum(area).first);
|
||||
RoutePush.bangumiPush(null, Utils.matchNum(area).first);
|
||||
} else if (area.startsWith('ss')) {
|
||||
RoutePush.bangumiPush(matchNum(area).first, null);
|
||||
RoutePush.bangumiPush(Utils.matchNum(area).first, null);
|
||||
}
|
||||
break;
|
||||
case 'video':
|
||||
@ -223,7 +223,7 @@ class PiliSchame {
|
||||
break;
|
||||
case 'read':
|
||||
print('专栏');
|
||||
String id = 'cv${matchNum(query!['id']!).first}';
|
||||
String id = 'cv${Utils.matchNum(query!['id']!).first}';
|
||||
Get.toNamed('/htmlRender', parameters: {
|
||||
'url': value.dataString!,
|
||||
'title': '',
|
||||
@ -239,21 +239,14 @@ class PiliSchame {
|
||||
}
|
||||
}
|
||||
|
||||
static List<int> matchNum(String str) {
|
||||
final RegExp regExp = RegExp(r'\d+');
|
||||
final Iterable<Match> matches = regExp.allMatches(str);
|
||||
|
||||
return matches.map((Match match) => int.parse(match.group(0)!)).toList();
|
||||
}
|
||||
|
||||
static void _handleEpisodePath(String lastPathSegment, String redirectUrl) {
|
||||
final String seasonId = _extractIdFromPath(lastPathSegment);
|
||||
RoutePush.bangumiPush(null, matchNum(seasonId).first);
|
||||
RoutePush.bangumiPush(null, Utils.matchNum(seasonId).first);
|
||||
}
|
||||
|
||||
static void _handleSeasonPath(String lastPathSegment, String redirectUrl) {
|
||||
final String seasonId = _extractIdFromPath(lastPathSegment);
|
||||
RoutePush.bangumiPush(matchNum(seasonId).first, null);
|
||||
RoutePush.bangumiPush(Utils.matchNum(seasonId).first, null);
|
||||
}
|
||||
|
||||
static String _extractIdFromPath(String lastPathSegment) {
|
||||
|
@ -16,7 +16,7 @@ class UrlUtils {
|
||||
};
|
||||
try {
|
||||
final response = await dio.get(url);
|
||||
if (response.statusCode == 302) {
|
||||
if (response.statusCode == 302 || response.statusCode == 301) {
|
||||
redirectUrl = response.headers['location']?.first as String;
|
||||
if (redirectUrl.endsWith('/')) {
|
||||
redirectUrl = redirectUrl.substring(0, redirectUrl.length - 1);
|
||||
|
@ -383,4 +383,11 @@ class Utils {
|
||||
List<int> randomBytes = generateRandomBytes(minLength, maxLength);
|
||||
return base64.encode(randomBytes);
|
||||
}
|
||||
|
||||
static List<int> matchNum(String str) {
|
||||
final RegExp regExp = RegExp(r'\d+');
|
||||
final Iterable<Match> matches = regExp.allMatches(str);
|
||||
|
||||
return matches.map((Match match) => int.parse(match.group(0)!)).toList();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user