Skip to content

Commit

Permalink
Update tests and fix comments api.
Browse files Browse the repository at this point in the history
This closes Hexer10#216
  • Loading branch information
Hexer10 committed Sep 21, 2022
1 parent 2a4a56f commit e4b8e59
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
2 changes: 2 additions & 0 deletions lib/src/reverse_engineering/clients/comments_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class CommentsClient {
return CommentsClient(data);
}

/*
onResponseReceivedEndpoints[1].reloadContinuationItemsCommand.continuationItems[2].commentThreadRenderer.comment.commentRenderer.contentText.runs[0].text */
List<JsonMap> _getCommentRenderers() {
return root
.getList('onResponseReceivedEndpoints')!
Expand Down
5 changes: 4 additions & 1 deletion lib/src/reverse_engineering/pages/watch_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ class _InitialData extends InitialData {
return null;
}

/*
contents.twoColumnWatchNextResults.results.results.contents[3].itemSectionRenderer.contents[0].continuationItemRenderer.continuationEndpoint.continuationCommand.token
*/
JsonMap? getContinuationContext() {
if (root['contents'] != null) {
return root
Expand All @@ -223,7 +226,7 @@ class _InitialData extends InitialData {
?.get('results')
?.get('results')
?.getList('contents')
?.firstWhereOrNull((e) => e['itemSectionRenderer'] != null)
?.lastWhereOrNull((e) => e['itemSectionRenderer'] != null)
?.get('itemSectionRenderer')
?.getList('contents')
?.firstOrNull
Expand Down
8 changes: 5 additions & 3 deletions lib/src/reverse_engineering/youtube_http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,11 @@ class YoutubeHttpClient extends http.BaseClient {
final body = {
'context': const {
'client': {
'hl': 'en',
'clientName': 'WEB',
'clientVersion': '2.20200911.04.00'
'browserName': 'Chrome',
'browserVersion': '105.0.0.0',
'clientFormFactor': 'UNKNOWN_FORM_FACTOR',
'clientName': "WEB",
'clientVersion': "2.20220921.00.00"
}
},
'continuation': token
Expand Down
4 changes: 2 additions & 2 deletions test/channel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void main() {
.getUploads(ChannelId(
'https://www.youtube.com/channel/UCEnBXANsKmyj2r9xVyKoDiQ'))
.toList();
expect(videos.length, greaterThanOrEqualTo(75));
expect(videos.length, greaterThanOrEqualTo(50));
});

group('Get the videos of any youtube channel', () {
Expand Down Expand Up @@ -84,7 +84,7 @@ void main() {
expect(aboutPage.description, isNotEmpty);
expect(aboutPage.thumbnails, isNotEmpty); // Avatar list
expect(aboutPage.channelLinks, isNotNull);
expect(aboutPage.country, 'United States');
expect(aboutPage.country, 'Japan');
expect(aboutPage.joinDate, 'Apr 29, 2010');
});
}
2 changes: 1 addition & 1 deletion test/closed_caption_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ void main() {
caption.text,
anyOf('how about this black there are some',
'there are some really nice colors here')); // Seems like sometimes the text changes.
expect(captionPart?.text, anyOf(' about', ' some'));
expect(captionPart?.text, anyOf(' about', ' some', ' are'));
});
}
14 changes: 7 additions & 7 deletions test/playlist_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ void main() {

test('Get metadata of a playlist', () async {
var playlistUrl =
'https://www.youtube.com/playlist?list=PLr-IftNTIujSF-8tlGbZBQyGIT6TCF6Yd';
'https://www.youtube.com/playlist?list=PLxTcxOtc5WIPFIyrYAvGqGhfAOmKJB0V3';
var playlist = await yt!.playlists.get(PlaylistId(playlistUrl));
expect(playlist.id.value, 'PLr-IftNTIujSF-8tlGbZBQyGIT6TCF6Yd');
expect(playlist.id.value, 'PLxTcxOtc5WIPFIyrYAvGqGhfAOmKJB0V3');
expect(playlist.url, playlistUrl);
expect(playlist.title, 'osu! Highlights');
expect(playlist.author, 'Tyrrrz');
expect(playlist.description, 'My best osu! plays');
expect(playlist.engagement.viewCount, greaterThanOrEqualTo(133));
expect(playlist.title, 'Tutorial');
expect(playlist.author, 'Hexah');
expect(playlist.description, '');
expect(playlist.engagement.viewCount, greaterThanOrEqualTo(2));
expect(playlist.engagement.likeCount, isNull);
expect(playlist.engagement.dislikeCount, isNull);
expect(playlist.thumbnails.lowResUrl, isNotEmpty);
expect(playlist.thumbnails.mediumResUrl, isNotEmpty);
expect(playlist.thumbnails.highResUrl, isNotEmpty);
expect(playlist.thumbnails.standardResUrl, isNotEmpty);
expect(playlist.thumbnails.maxResUrl, isNotEmpty);
expect(playlist.videoCount, greaterThanOrEqualTo(20));
expect(playlist.videoCount, greaterThanOrEqualTo(3));
});
group('Get metadata of any playlist', () {
for (final val in {
Expand Down
2 changes: 1 addition & 1 deletion test/streams_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void main() {
test('Get the hls manifest of a live stream', () async {
expect(
await yt!.videos.streamsClient
.getHttpLiveStreamUrl(VideoId('5qap5aO4i9A')),
.getHttpLiveStreamUrl(VideoId('jfKfPfyJRdk')),
isNotEmpty);
});

Expand Down

0 comments on commit e4b8e59

Please sign in to comment.