opt: enum

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-05 15:06:19 +08:00
parent 4e68c765c5
commit 2f4c739f0b
116 changed files with 577 additions and 554 deletions

View File

@@ -0,0 +1,117 @@
// ignore_for_file: constant_identifier_names
//https://github.com/yujincheng08/BiliRoaming/blob/master/app/src/main/res/values/strings_raw.xml
//https://github.com/yujincheng08/BiliRoaming/blob/master/app/src/main/res/values/arrays.xml
enum CDNService {
baseUrl,
backupUrl,
ali,
alib,
alio1,
cos,
cosb,
coso1,
hw,
hwb,
hwo1,
hw_08c,
hw_08h,
hw_08ct,
tf_hw,
tf_tx,
akamai,
aliov,
cosov,
hwov,
hk_bcache,
}
extension CDNServiceDesc on CDNService {
static const List<String> _descList = [
'基础 URL不推荐',
'备用 URL',
'ali阿里云',
'alib阿里云',
'alio1阿里云',
'cos腾讯云',
'cosb腾讯云VOD 加速类型)',
'coso1腾讯云',
'hw华为云融合 CDN',
'hwb华为云融合 CDN',
'hwo1华为云融合 CDN',
'08c华为云融合 CDN',
'08h华为云融合 CDN',
'08ct华为云融合 CDN',
'tf_hw华为云',
'tf_tx腾讯云',
'akamaiAkamai 海外)',
'aliov阿里云海外',
'cosov腾讯云海外',
'hwov华为云海外',
'hk_bcacheBilibili海外',
];
String get description => _descList[index];
}
extension CDNServiceHost on CDNService {
static const List<String> _hostList = [
'',
'',
'upos-sz-mirrorali.bilivideo.com',
'upos-sz-mirroralib.bilivideo.com',
'upos-sz-mirroralio1.bilivideo.com',
'upos-sz-mirrorcos.bilivideo.com',
'upos-sz-mirrorcosb.bilivideo.com',
'upos-sz-mirrorcoso1.bilivideo.com',
'upos-sz-mirrorhw.bilivideo.com',
'upos-sz-mirrorhwb.bilivideo.com',
'upos-sz-mirrorhwo1.bilivideo.com',
'upos-sz-mirror08c.bilivideo.com',
'upos-sz-mirror08h.bilivideo.com',
'upos-sz-mirror08ct.bilivideo.com',
'upos-tf-all-hw.bilivideo.com',
'upos-tf-all-tx.bilivideo.com',
'upos-hz-mirrorakam.akamaized.net',
'upos-sz-mirroraliov.bilivideo.com',
'upos-sz-mirrorcosov.bilivideo.com',
'upos-sz-mirrorhwov.bilivideo.com',
'cn-hk-eq-bcache-01.bilivideo.com',
];
String get host => _hostList[index];
}
extension CDNServiceCode on CDNService {
static const List<String> _codeList = [
'baseUrl',
'backupUrl',
'ali',
'alib',
'alio1',
'cos',
'cosb',
'coso1',
'hw',
'hwb',
'hwo1',
'hw_08c',
'hw_08h',
'hw_08ct',
'tf_hw',
'tf_tx',
'akamai',
'aliov',
'cosov',
'hwov',
'hk_bcache',
];
String get code => _codeList[index];
static CDNService? fromCode(String code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return CDNService.values[index];
}
return null;
}
}

View File

@@ -0,0 +1,30 @@
// ignore_for_file: constant_identifier_names
enum AudioQuality { k64, k132, k192, dolby, hiRes }
extension AudioQualityExt on AudioQuality {
static const List<int> _codeList = [
30216,
30232,
30280,
30250,
30251,
];
int get code => _codeList[index];
static AudioQuality? fromCode(int code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return AudioQuality.values[index];
}
return null;
}
String get description => const [
'64K',
'132K',
'192K',
'杜比全景声',
'Hi-Res无损',
][index];
}

View File

@@ -0,0 +1,40 @@
enum LiveQuality {
dolby,
super4K,
origin,
bluRay,
superHD,
smooth,
flunt,
}
extension LiveQualityExt on LiveQuality {
static const List<int> _codeList = [
30000,
20000,
10000,
400,
250,
150,
80,
];
int get code => _codeList[index];
static LiveQuality? fromCode(int code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return LiveQuality.values[index];
}
return null;
}
String get description => const [
'杜比',
'4K',
'原画',
'蓝光',
'超清',
'高清',
'流畅',
][index];
}

View File

@@ -0,0 +1,21 @@
enum SubtitlePrefType { off, on, withoutAi, auto }
extension SubtitlePrefTypeExt on SubtitlePrefType {
String get description => const [
'默认不显示字幕',
'优先选择非自动生成(ai)字幕',
'跳过自动生成(ai)字幕,选择第一个可用字幕',
'静音时等同第二项,非静音时等同第三项'
][index];
static const List<String> _codeList = ['off', 'on', 'withoutAi', 'auto'];
String get code => _codeList[index];
static SubtitlePrefType? fromCode(String code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return SubtitlePrefType.values[index];
}
return null;
}
}

View File

@@ -0,0 +1,34 @@
// ignore_for_file: constant_identifier_names
enum VideoDecodeFormatType {
DVH1,
AV1,
HEVC,
AVC,
}
extension VideoDecodeFormatTypeExt on VideoDecodeFormatType {
String get description => const ['DVH1', 'AV1', 'HEVC', 'AVC'][index];
static const List<String> _codeList = ['dvh1', 'av01', 'hev1', 'avc1'];
String get code => _codeList[index];
static VideoDecodeFormatType? fromCode(String code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return VideoDecodeFormatType.values[index];
}
return null;
}
static VideoDecodeFormatType? fromString(String val) {
var result = VideoDecodeFormatType.values.first;
for (var i in _codeList) {
if (val.startsWith(i)) {
result = VideoDecodeFormatType.values[_codeList.indexOf(i)];
break;
}
}
return result;
}
}

View File

@@ -0,0 +1,55 @@
enum VideoQuality {
speed240,
fluent360,
clear480,
high720,
high72060,
high1080,
high1080plus,
high108060,
super4K,
hdr,
dolbyVision,
super8k
}
extension VideoQualityExt on VideoQuality {
static const List<int> _codeList = [
6,
16,
32,
64,
74,
80,
112,
116,
120,
125,
126,
127,
];
int get code => _codeList[index];
static VideoQuality? fromCode(int code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return VideoQuality.values[index];
}
return null;
}
String get description => const [
'240P 极速',
'360P 流畅',
'480P 清晰',
'720P 高清',
'720P60 高帧率',
'1080P 高清',
'1080P+ 高码率',
'1080P60 高帧率',
'4K 超清',
'HDR 真彩色',
'杜比视界',
'8K 超高清'
][index];
}