mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-01 23:59:50 +08:00
refa: cdn (#1743)
* refa: cdn * feat: live cdn (WIP) * tweaks Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * add live quality [skip ci] Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * mod: replace durl host * tweak [skip ci] Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> --------- Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
e589f27195
commit
27ae296b28
@@ -27,11 +27,84 @@ enum CDNService {
|
||||
hk_bcache('hk_bcache(Bilibili海外)', 'cn-hk-eq-bcache-01.bilivideo.com')
|
||||
;
|
||||
|
||||
String get code => name;
|
||||
static final fromCode = values.byName;
|
||||
|
||||
final String desc;
|
||||
final String host;
|
||||
final String? host;
|
||||
|
||||
const CDNService(this.desc, [this.host = '']);
|
||||
const CDNService(this.desc, [this.host]);
|
||||
}
|
||||
// from https://rec.danmuji.org/dev/cdn-info/
|
||||
// {
|
||||
// 'cn-ahwh-ct-': {'01': 16},
|
||||
// 'cn-cq-ct-': {'01': 35, '02': 2},
|
||||
// 'cn-gddg-ct-': {'01': 36},
|
||||
// 'cn-gdfs-ct-': {'01': 28},
|
||||
// 'cn-hblf-ct-': {'01': 21},
|
||||
// 'cn-hbyc-ct-': {'02': 35},
|
||||
// 'cn-hljheb-ct-': {'01': 12},
|
||||
// 'cn-hnld-ct-': {'01': 56},
|
||||
// 'cn-jsnt-ct-': {'01': 52},
|
||||
// 'cn-jsyz-ct-': {'03': 52},
|
||||
// 'cn-jxjj-ct-': {'01': 14},
|
||||
// 'cn-sccd-ct-': {'01': 32},
|
||||
// 'cn-sxxa-ct-': {'03': 14},
|
||||
// 'cn-xj-ct-': {'01': 6},
|
||||
// 'cn-zjjh-ct-': {'04': 37},
|
||||
// 'cn-gddg-cu-': {'01': 15},
|
||||
// 'cn-hncs-cu-': {'01': 14, 'v': 6},
|
||||
// 'cn-hnly-cu-': {'01': 35},
|
||||
// 'cn-jlcc-cu-': {'03': 16},
|
||||
// 'cn-jstz-cu-': {'01': 14},
|
||||
// 'cn-lnsy-cu-': {'01': 9, 'v': 4},
|
||||
// 'cn-nmghhht-cu-': {'01': 15, 'v': 11},
|
||||
// 'cn-sccd-cu-': {'01': 13},
|
||||
// 'cn-sdqd-cu-': {'01': 25},
|
||||
// 'cn-sxty-cu-': {'03': 10},
|
||||
// 'cn-sxxa-cu-': {'02': 8},
|
||||
// 'cn-zjhz-cu-': {'01': 8, 'v': 6},
|
||||
// 'cn-cq-cm-': {'01': 30},
|
||||
// 'cn-fjqz-cm-': {'01': 10},
|
||||
// 'cn-gddg-cm-': {'01': 14},
|
||||
// 'cn-gdst-cm-': {'01': 17},
|
||||
// 'cn-hbsjz-cm-': {'02': 16},
|
||||
// 'cn-hbwh-cm-': {'01': 23},
|
||||
// 'cn-hncs-cm-': {'03': 24},
|
||||
// 'cn-hnzz-cm-': {'01': 16},
|
||||
// 'cn-jssz-cm-': {'01': 24, '02': 62},
|
||||
// 'cn-jxnc-cm-': {'01': 20},
|
||||
// 'cn-lnsy-cm-': {'01': 11},
|
||||
// 'cn-nmghhht-cm-': {'01': 5},
|
||||
// 'cn-sccd-cm-': {'03': 26},
|
||||
// 'cn-sdjn-cm-': {'02': 14},
|
||||
// 'cn-sxxa-cm-': {'01': 14},
|
||||
// 'cn-tj-cm-': {'02': 16},
|
||||
// 'cn-xj-cm-': {'02': 6},
|
||||
// 'cn-zjhz-cm-': {'01': 29},
|
||||
// 'cn-cq-gd-': {'01': 20},
|
||||
// 'cn-gdgz-gd-': {'01': 20},
|
||||
// 'cn-gzgy-gd-': {'01': 6},
|
||||
// 'cn-hb-gd-': {'01': 4},
|
||||
// 'cn-hbwh-gd-': {'01': 6},
|
||||
// 'cn-hljheb-gd-': {'01': 2},
|
||||
// 'cn-hncs-gd-': {'01': 8},
|
||||
// 'cn-jlcc-gd-': {'01': 5},
|
||||
// 'cn-jsnj-gd-': {'01': 8},
|
||||
// 'cn-zjhz-gd-': {'02': 2},
|
||||
// 'cn-bj-fx-': {'01': 6},
|
||||
// 'cn-fjfz-fx-': {'01': 6},
|
||||
// 'cn-gdgz-fx-': {'01': 18},
|
||||
// 'cn-hbwh-fx-': {'01': 16},
|
||||
// 'cn-hncs-fx-': {'01': 6},
|
||||
// 'cn-hnzz-fx-': {'01': 8},
|
||||
// 'cn-jsnj-fx-': {'02': 6},
|
||||
// 'cn-sccd-fx-': {'01': 6},
|
||||
// 'cn-sdjn-fx-': {'01': 6},
|
||||
// 'cn-sh-fx-': {'01': 10},
|
||||
// 'cn-tj-fx-': {'01': 6},
|
||||
// 'cn-bj-se-': {'01': 8},
|
||||
// 'cn-bj-cc-': {'03': 18},
|
||||
// 'cn-gdfs-cc-': {'02': 21},
|
||||
// 'cn-sh-cc-': {'01': 15},
|
||||
// 'cn-zjhz-wasu-': {'03': 21, '04': 12},
|
||||
// 'cn-sh-ix-': {'01': 13},
|
||||
// 'cn-hk-eq-': {'01': 14}
|
||||
// }
|
||||
@@ -2,6 +2,7 @@ enum LiveQuality {
|
||||
dolby(30000, '杜比'),
|
||||
origin4K(25000, '4K 原画'),
|
||||
super4K(20000, '4K'),
|
||||
super2K(15000, '2K'),
|
||||
origin(10000, '原画'),
|
||||
bluRay(400, '蓝光'),
|
||||
superHD(250, '超清'),
|
||||
|
||||
@@ -196,23 +196,17 @@ class Durl {
|
||||
backupUrl: (json['backup_url'] as List?)?.fromCast<String>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final _ipRegExp = RegExp(r'^https?://\d{1,3}\.\d{1,3}');
|
||||
|
||||
bool _isMCDNorPCDN(String url) {
|
||||
return url.contains("upos-sz-302") ||
|
||||
url.contains("nexusedgeio.com") ||
|
||||
url.contains("ahdohpiechei.com") ||
|
||||
url.contains("szbdyd.com") ||
|
||||
url.contains(".mcdn.bilivideo") ||
|
||||
_ipRegExp.hasMatch(url);
|
||||
Iterable<String> get playUrls sync* {
|
||||
if (url?.isNotEmpty == true) yield url!;
|
||||
if (backupUrl?.isNotEmpty == true) yield* backupUrl!;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BaseItem {
|
||||
int? id;
|
||||
String? baseUrl;
|
||||
String? backupUrl;
|
||||
List<String>? backupUrl;
|
||||
int? bandWidth;
|
||||
String? mimeType;
|
||||
String? codecs;
|
||||
@@ -243,14 +237,8 @@ abstract class BaseItem {
|
||||
BaseItem.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
baseUrl = json['baseUrl'] ?? json['base_url'];
|
||||
final backupUrls = ((json['backupUrl'] ?? json['backup_url']) as List?)
|
||||
backupUrl = ((json['backupUrl'] ?? json['backup_url']) as List?)
|
||||
?.fromCast<String>();
|
||||
backupUrl = backupUrls != null && backupUrls.isNotEmpty
|
||||
? backupUrls.firstWhere(
|
||||
(i) => !_isMCDNorPCDN(i),
|
||||
orElse: () => backupUrls.first,
|
||||
)
|
||||
: null;
|
||||
bandWidth = json['bandWidth'] ?? json['bandwidth'];
|
||||
mimeType = json['mime_type'];
|
||||
codecs = json['codecs'];
|
||||
@@ -262,6 +250,11 @@ abstract class BaseItem {
|
||||
segmentBase = json['segmentBase'] ?? json['segment_base'];
|
||||
codecid = json['codecid'];
|
||||
}
|
||||
|
||||
Iterable<String> get playUrls sync* {
|
||||
if (baseUrl?.isNotEmpty == true) yield baseUrl!;
|
||||
if (backupUrl?.isNotEmpty == true) yield* backupUrl!;
|
||||
}
|
||||
}
|
||||
|
||||
class VideoItem extends BaseItem {
|
||||
|
||||
Reference in New Issue
Block a user