diff --git a/CHANGELOG.md b/CHANGELOG.md index 3088cdd..72895ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.3.2 +- Minor caching changes. + ## 1.3.1 - Implement caching of some results. diff --git a/lib/src/reverse_engineering/responses/player_response.dart b/lib/src/reverse_engineering/responses/player_response.dart index 0eab853..b4ecd67 100644 --- a/lib/src/reverse_engineering/responses/player_response.dart +++ b/lib/src/reverse_engineering/responses/player_response.dart @@ -9,60 +9,40 @@ class PlayerResponse { // Json parsed map final Map _root; - String _playerabilityStatus; - bool _isVideoAvailable; - bool _isVideoPlayable; - String _videoTitle; - String _videoAuthor; - DateTime _videoUploadDate; - String _videoChannelId; - Duration _videoDuration; - Iterable _videoKeywords; - String _videoDescription; - int _videoViewCount; - String _previewVideoId; - bool _isLive; - String _hlsManifestUrl; - String _dashManifestUrl; Iterable _muxedStreams; Iterable _adaptiveStreams; List _streams; Iterable _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 get videoKeywords => _videoKeywords ??= + Iterable get videoKeywords => _root['videoDetails']['keywords']?.cast() ?? 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 get muxedStreams => _muxedStreams ??= _root @@ -124,19 +103,13 @@ class ClosedCaptionTrack { // Json parsed map final Map _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); } diff --git a/lib/src/videos/comments/comment.dart b/lib/src/videos/comments/comment.dart index 10de820..5f53b13 100644 --- a/lib/src/videos/comments/comment.dart +++ b/lib/src/videos/comments/comment.dart @@ -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] diff --git a/lib/src/videos/video.dart b/lib/src/videos/video.dart index 218ff12..ae559be 100644 --- a/lib/src/videos/video.dart +++ b/lib/src/videos/video.dart @@ -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] diff --git a/pubspec.yaml b/pubspec.yaml index 6aadc52..cf0723a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: