Version 1.3.2

This commit is contained in:
Hexah 2020-06-23 10:12:08 +02:00
parent 358dd52fa1
commit fdd85a99fa
5 changed files with 27 additions and 53 deletions

View File

@ -1,3 +1,6 @@
## 1.3.2
- Minor caching changes.
## 1.3.1
- Implement caching of some results.

View File

@ -9,60 +9,40 @@ class PlayerResponse {
// Json parsed map
final Map<String, dynamic> _root;
String _playerabilityStatus;
bool _isVideoAvailable;
bool _isVideoPlayable;
String _videoTitle;
String _videoAuthor;
DateTime _videoUploadDate;
String _videoChannelId;
Duration _videoDuration;
Iterable<String> _videoKeywords;
String _videoDescription;
int _videoViewCount;
String _previewVideoId;
bool _isLive;
String _hlsManifestUrl;
String _dashManifestUrl;
Iterable<StreamInfoProvider> _muxedStreams;
Iterable<StreamInfoProvider> _adaptiveStreams;
List<StreamInfoProvider> _streams;
Iterable<ClosedCaptionTrack> _closedCaptionTrack;
String _videoPlayabilityError;
String get playabilityStatus =>
_playerabilityStatus ??= _root['playabilityStatus']['status'];
String get playabilityStatus => _root['playabilityStatus']['status'];
bool get isVideoAvailable =>
_isVideoAvailable ??= playabilityStatus.toLowerCase() != 'error';
bool get isVideoAvailable => playabilityStatus.toLowerCase() != 'error';
bool get isVideoPlayable =>
_isVideoAvailable ??= playabilityStatus.toLowerCase() == 'ok';
bool get isVideoPlayable => playabilityStatus.toLowerCase() == 'ok';
String get videoTitle => _videoTitle ??= _root['videoDetails']['title'];
String get videoTitle => _root['videoDetails']['title'];
String get videoAuthor => _videoAuthor ??= _root['videoDetails']['author'];
String get videoAuthor => _root['videoDetails']['author'];
DateTime get videoUploadDate => _videoUploadDate ??= DateTime.parse(
DateTime get videoUploadDate => DateTime.parse(
_root['microformat']['playerMicroformatRenderer']['uploadDate']);
String get videoChannelId =>
_videoChannelId ??= _root['videoDetails']['channelId'];
String get videoChannelId => _root['videoDetails']['channelId'];
Duration get videoDuration => _videoDuration ??=
Duration get videoDuration =>
Duration(seconds: int.parse(_root['videoDetails']['lengthSeconds']));
Iterable<String> get videoKeywords => _videoKeywords ??=
Iterable<String> get videoKeywords =>
_root['videoDetails']['keywords']?.cast<String>() ?? const [];
String get videoDescription =>
_videoDescription ??= _root['videoDetails']['shortDescription'];
String get videoDescription => _root['videoDetails']['shortDescription'];
int get videoViewCount =>
_videoViewCount ??= int.parse(_root['videoDetails']['viewCount']);
int get videoViewCount => int.parse(_root['videoDetails']['viewCount']);
// Can be null
String get previewVideoId => _previewVideoId ??= _root
String get previewVideoId =>
_root
.get('playabilityStatus')
?.get('errorScreen')
?.get('playerLegacyDesktopYpcTrailerRenderer')
@ -75,15 +55,14 @@ class PlayerResponse {
?.getValue('playerVars') ??
'')['video_id'];
bool get isLive =>
_isLive ??= _root.get('videoDetails')?.getValue('isLive') ?? false;
bool get isLive => _root.get('videoDetails')?.getValue('isLive') ?? false;
// Can be null
String get hlsManifestUrl => _hlsManifestUrl ??=
String get hlsManifestUrl =>
_root.get('streamingData')?.getValue('hlsManifestUrl');
// Can be null
String get dashManifestUrl => _dashManifestUrl ??=
String get dashManifestUrl =>
_root.get('streamingData')?.getValue('dashManifestUrl');
Iterable<StreamInfoProvider> get muxedStreams => _muxedStreams ??= _root
@ -124,19 +103,13 @@ class ClosedCaptionTrack {
// Json parsed map
final Map<String, dynamic> _root;
String _url;
String _languageCode;
String _languageName;
bool _autoGenerated;
String get url => _root['baseUrl'];
String get url => _url ??= _root['baseUrl'];
String get languageCode => _root['languageCode'];
String get languageCode => _languageCode ??= _root['languageCode'];
String get languageName => _root['name']['simpleText'];
String get languageName => _languageName ??= _root['name']['simpleText'];
bool get autoGenerated =>
_autoGenerated ??= _root['vssId'].toLowerCase().startsWith("a.");
bool get autoGenerated => _root['vssId'].toLowerCase().startsWith("a.");
ClosedCaptionTrack(this._root);
}

View File

@ -1,5 +1,4 @@
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
import '../../channels/channel_id.dart';
@ -27,11 +26,11 @@ class Comment with EquatableMixin {
final int replyCount;
/// Used internally.
@protected
/// Shouldn't be used in the code.
final String continuation;
/// Used internally.
@protected
/// Shouldn't be used in the code.
final String clicktrackingParams;
/// Initializes an instance of [Comment]

View File

@ -1,7 +1,6 @@
import 'dart:collection';
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
import '../common/common.dart';
import '../reverse_engineering/responses/responses.dart';
@ -40,7 +39,7 @@ class Video with EquatableMixin {
final Engagement engagement;
/// Used internally.
@protected
/// Shouldn't be used in the code.
final WatchPage watchPage;
/// Initializes an instance of [Video]

View File

@ -1,6 +1,6 @@
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.
version: 1.3.1
version: 1.3.2
homepage: https://github.com/Hexer10/youtube_explode_dart
environment: