Merge remote-tracking branch 'origin/master'

This commit is contained in:
Mattia 2021-09-01 16:04:54 +02:00
commit c70ac16007
6 changed files with 27 additions and 11 deletions

View File

@ -26,14 +26,14 @@ class EmbeddedPlayerClient {
late final Iterable<_StreamInfo> muxedStreams = root late final Iterable<_StreamInfo> muxedStreams = root
.get('streamingData') .get('streamingData')
?.getList('formats') ?.getList('formats')
?.map((e) => _StreamInfo(e)) ?? ?.map((e) => _StreamInfo(e, StreamSource.muxed)) ??
const []; const [];
/// ///
late final Iterable<_StreamInfo> adaptiveStreams = root late final Iterable<_StreamInfo> adaptiveStreams = root
.get('streamingData') .get('streamingData')
?.getList('adaptiveFormats') ?.getList('adaptiveFormats')
?.map((e) => _StreamInfo(e)) ?? ?.map((e) => _StreamInfo(e, StreamSource.adaptive)) ??
const []; const [];
/// ///
@ -131,5 +131,9 @@ class _StreamInfo extends StreamInfoProvider {
@override @override
late final int? framerate = root['fps'] ?? 0; late final int? framerate = root['fps'] ?? 0;
_StreamInfo(this.root);
@override
final StreamSource source;
_StreamInfo(this.root, this.source);
} }

View File

@ -47,6 +47,9 @@ class _StreamInfo extends StreamInfoProvider {
_StreamInfo(this.root); _StreamInfo(this.root);
@override
StreamSource get source => StreamSource.dash;
@override @override
late final int tag = int.parse(root.getAttribute('id')!); late final int tag = int.parse(root.getAttribute('id')!);

View File

@ -1,8 +1,13 @@
enum StreamSource { muxed, adaptive, dash }
/// ///
abstract class StreamInfoProvider { abstract class StreamInfoProvider {
/// ///
static final RegExp contentLenExp = RegExp(r'clen=(\d+)'); static final RegExp contentLenExp = RegExp(r'clen=(\d+)');
///
StreamSource get source;
/// ///
int get tag; int get tag;

View File

@ -96,7 +96,7 @@ class PlayerResponse {
late final List<StreamInfoProvider> muxedStreams = root late final List<StreamInfoProvider> muxedStreams = root
.get('streamingData') .get('streamingData')
?.getList('formats') ?.getList('formats')
?.map((e) => _StreamInfo(e)) ?.map((e) => _StreamInfo(e, StreamSource.muxed))
.cast<StreamInfoProvider>() .cast<StreamInfoProvider>()
.toList() ?? .toList() ??
const <StreamInfoProvider>[]; const <StreamInfoProvider>[];
@ -105,7 +105,7 @@ class PlayerResponse {
late final List<StreamInfoProvider> adaptiveStreams = root late final List<StreamInfoProvider> adaptiveStreams = root
.get('streamingData') .get('streamingData')
?.getList('adaptiveFormats') ?.getList('adaptiveFormats')
?.map((e) => _StreamInfo(e)) ?.map((e) => _StreamInfo(e, StreamSource.adaptive))
.cast<StreamInfoProvider>() .cast<StreamInfoProvider>()
.toList() ?? .toList() ??
const []; const [];
@ -238,5 +238,8 @@ class _StreamInfo extends StreamInfoProvider {
return codecs.last; return codecs.last;
} }
_StreamInfo(this.root); @override
final StreamSource source;
_StreamInfo(this.root, this.source);
} }

View File

@ -156,9 +156,9 @@ class StreamsClient {
await _httpClient.getContentLength(url, validate: false) ?? await _httpClient.getContentLength(url, validate: false) ??
0; 0;
if (contentLength <= 0) { // if (contentLength <= 0) {
continue; // continue;
} // }
// Common // Common
var container = StreamContainer.parse(streamInfo.container!); var container = StreamContainer.parse(streamInfo.container!);
@ -184,7 +184,8 @@ class StreamsClient {
: videoQuality.toVideoResolution(); : videoQuality.toVideoResolution();
// Muxed // Muxed
if (!audioCodec.isNullOrWhiteSpace) { if (!audioCodec.isNullOrWhiteSpace &&
streamInfo.source != StreamSource.adaptive) {
streams[tag] = MuxedStreamInfo( streams[tag] = MuxedStreamInfo(
tag, tag,
url, url,

View File

@ -1,6 +1,6 @@
name: youtube_explode_dart name: youtube_explode_dart
description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key. description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key.
version: 1.10.6 version: 1.10.7-dev.1
homepage: https://github.com/Hexer10/youtube_explode_dart homepage: https://github.com/Hexer10/youtube_explode_dart