Version v1.9.8

Fix #131
This commit is contained in:
Mattia 2021-07-02 00:48:10 +02:00
parent 4562de0ded
commit 4f9b38d7d2
6 changed files with 42 additions and 11 deletions

View File

@ -1,3 +1,6 @@
## 1.9.8
- Fix issue #131 (Cannot get publishDate or uploadDate)
## 1.9.7
- Fix issue #135 (Cannot use getUploadsFromPage on a channel with no uploads).

View File

@ -132,6 +132,13 @@ extension StringUtility2 on String? {
return DateTime.now().subtract(time);
}
DateTime? tryParseDateTime() {
if (this == null) {
return null;
}
return DateTime.parse(this!);
}
}
/// List decipher utility.

View File

@ -52,7 +52,6 @@ class Video with EquatableMixin {
/// Used internally.
/// Shouldn't be used in the code.
/// TODO: Deprecate this method
final WatchPage? watchPage;
/// Returns true if the watch page is available for this video.

View File

@ -1,5 +1,6 @@
import '../channels/channel_id.dart';
import '../common/common.dart';
import '../extensions/helpers_extension.dart';
import '../reverse_engineering/responses/responses.dart';
import '../reverse_engineering/youtube_http_client.dart';
import 'closed_captions/closed_caption_client.dart';
@ -37,8 +38,16 @@ class VideoClient {
playerResponse.videoTitle,
playerResponse.videoAuthor,
ChannelId(playerResponse.videoChannelId),
playerResponse.videoUploadDate,
playerResponse.videoPublishDate,
playerResponse.videoUploadDate ??
watchPage.root
.querySelector('meta[itemprop=uploadDate]')
?.attributes['content']
?.tryParseDateTime(),
playerResponse.videoPublishDate ??
watchPage.root
.querySelector('meta[itemprop=datePublished]')
?.attributes['content']
?.tryParseDateTime(),
playerResponse.videoDescription,
playerResponse.videoDuration,
ThumbnailSet(videoId.value),

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.9.7
version: 1.9.8+1
homepage: https://github.com/Hexer10/youtube_explode_dart

View File

@ -19,13 +19,13 @@ void main() {
expect(video.title, 'Aka no Ha [Another] +HDHR');
expect(video.channelId.value, 'UCEnBXANsKmyj2r9xVyKoDiQ');
expect(video.author, 'Tyrrrz');
/* var rangeMs = DateTime(2017, 09, 30, 17, 15, 26).millisecondsSinceEpoch;
var rangeMs = DateTime(2017, 09, 30, 17, 15, 26).millisecondsSinceEpoch;
// 1day margin since the uploadDate could differ from timezones
// YouTube now doesn't send the upload date/ publish date anymore.
expect(video.uploadDate!.millisecondsSinceEpoch,
inInclusiveRange(rangeMs - 86400000, rangeMs + 86400000));
expect(video.publishDate!.millisecondsSinceEpoch,
inInclusiveRange(rangeMs - 86400000, rangeMs + 86400000));*/
inInclusiveRange(rangeMs - 86400000, rangeMs + 86400000));
expect(video.description, contains('246pp'));
// Should be 1:38 but sometimes it differs
// so we're using a 10 seconds range from it.
@ -48,15 +48,28 @@ void main() {
group('Get metadata of any video', () {
for (final val in {
VideoId('9bZkp7q19f0'),
VideoId('SkRSXFQerZs'),
VideoId('5VGm0dczmHc'),
VideoId('ZGdLIwrGHG8'),
VideoId('5qap5aO4i9A')
VideoId('9bZkp7q19f0'), //Normal
VideoId('ZGdLIwrGHG8'), //Unlisted
VideoId('5qap5aO4i9A'), //LiveStream
VideoId('rsAAeyAr-9Y'), //LiveStreamRecording
VideoId('V5Fsj_sCKdg'), //ContainsHighQualityStreams
VideoId('AI7ULzgf8RU'), //ContainsDashManifest
VideoId('-xNN-bJQ4vI'), //Omnidirectional
VideoId('vX2vsvdq8nw'), //HighDynamicRange
VideoId('YltHGKX80Y8'), //ContainsClosedCaptions
VideoId('_kmeFXjjGfk'), //EmbedRestrictedByYouTube
VideoId('MeJVWBSsPAY'), //EmbedRestrictedByAuthor
VideoId('SkRSXFQerZs'), //AgeRestricted
VideoId('hySoCSoH-g8'), //AgeRestrictedEmbedRestricted
VideoId('5VGm0dczmHc'), //RatingDisabled
VideoId('p3dDcKOFXQg'), //RequiresPurchase
}) {
test('VideoId - ${val.value}', () async {
var video = await yt!.videos.get(val);
expect(video.id.value, val.value);
expect(video.uploadDate, isNotNull);
expect(video.publishDate, isNotNull);
});
}
});