mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-30 15:25:47 +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
@@ -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