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 ## 1.9.7
- Fix issue #135 (Cannot use getUploadsFromPage on a channel with no uploads). - 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); return DateTime.now().subtract(time);
} }
DateTime? tryParseDateTime() {
if (this == null) {
return null;
}
return DateTime.parse(this!);
}
} }
/// List decipher utility. /// List decipher utility.

View File

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

View File

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

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.9.7 version: 1.9.8+1
homepage: https://github.com/Hexer10/youtube_explode_dart 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.title, 'Aka no Ha [Another] +HDHR');
expect(video.channelId.value, 'UCEnBXANsKmyj2r9xVyKoDiQ'); expect(video.channelId.value, 'UCEnBXANsKmyj2r9xVyKoDiQ');
expect(video.author, 'Tyrrrz'); 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 // 1day margin since the uploadDate could differ from timezones
// YouTube now doesn't send the upload date/ publish date anymore. // YouTube now doesn't send the upload date/ publish date anymore.
expect(video.uploadDate!.millisecondsSinceEpoch, expect(video.uploadDate!.millisecondsSinceEpoch,
inInclusiveRange(rangeMs - 86400000, rangeMs + 86400000)); inInclusiveRange(rangeMs - 86400000, rangeMs + 86400000));
expect(video.publishDate!.millisecondsSinceEpoch, expect(video.publishDate!.millisecondsSinceEpoch,
inInclusiveRange(rangeMs - 86400000, rangeMs + 86400000));*/ inInclusiveRange(rangeMs - 86400000, rangeMs + 86400000));
expect(video.description, contains('246pp')); expect(video.description, contains('246pp'));
// Should be 1:38 but sometimes it differs // Should be 1:38 but sometimes it differs
// so we're using a 10 seconds range from it. // so we're using a 10 seconds range from it.
@ -48,15 +48,28 @@ void main() {
group('Get metadata of any video', () { group('Get metadata of any video', () {
for (final val in { for (final val in {
VideoId('9bZkp7q19f0'), VideoId('9bZkp7q19f0'), //Normal
VideoId('SkRSXFQerZs'), VideoId('ZGdLIwrGHG8'), //Unlisted
VideoId('5VGm0dczmHc'), VideoId('5qap5aO4i9A'), //LiveStream
VideoId('ZGdLIwrGHG8'), VideoId('rsAAeyAr-9Y'), //LiveStreamRecording
VideoId('5qap5aO4i9A') 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 { test('VideoId - ${val.value}', () async {
var video = await yt!.videos.get(val); var video = await yt!.videos.get(val);
expect(video.id.value, val.value); expect(video.id.value, val.value);
expect(video.uploadDate, isNotNull);
expect(video.publishDate, isNotNull);
}); });
} }
}); });