Skip to content

Commit e4b8e59

Browse files
committed
Update tests and fix comments api.
This closes Hexer10#216
1 parent 2a4a56f commit e4b8e59

File tree

7 files changed

+22
-15
lines changed

7 files changed

+22
-15
lines changed

lib/src/reverse_engineering/clients/comments_client.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class CommentsClient {
4040
return CommentsClient(data);
4141
}
4242

43+
/*
44+
onResponseReceivedEndpoints[1].reloadContinuationItemsCommand.continuationItems[2].commentThreadRenderer.comment.commentRenderer.contentText.runs[0].text */
4345
List<JsonMap> _getCommentRenderers() {
4446
return root
4547
.getList('onResponseReceivedEndpoints')!

lib/src/reverse_engineering/pages/watch_page.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ class _InitialData extends InitialData {
215215
return null;
216216
}
217217

218+
/*
219+
contents.twoColumnWatchNextResults.results.results.contents[3].itemSectionRenderer.contents[0].continuationItemRenderer.continuationEndpoint.continuationCommand.token
220+
*/
218221
JsonMap? getContinuationContext() {
219222
if (root['contents'] != null) {
220223
return root
@@ -223,7 +226,7 @@ class _InitialData extends InitialData {
223226
?.get('results')
224227
?.get('results')
225228
?.getList('contents')
226-
?.firstWhereOrNull((e) => e['itemSectionRenderer'] != null)
229+
?.lastWhereOrNull((e) => e['itemSectionRenderer'] != null)
227230
?.get('itemSectionRenderer')
228231
?.getList('contents')
229232
?.firstOrNull

lib/src/reverse_engineering/youtube_http_client.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@ class YoutubeHttpClient extends http.BaseClient {
222222
final body = {
223223
'context': const {
224224
'client': {
225-
'hl': 'en',
226-
'clientName': 'WEB',
227-
'clientVersion': '2.20200911.04.00'
225+
'browserName': 'Chrome',
226+
'browserVersion': '105.0.0.0',
227+
'clientFormFactor': 'UNKNOWN_FORM_FACTOR',
228+
'clientName': "WEB",
229+
'clientVersion': "2.20220921.00.00"
228230
}
229231
},
230232
'continuation': token

test/channel_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void main() {
5050
.getUploads(ChannelId(
5151
'https://www.youtube.com/channel/UCEnBXANsKmyj2r9xVyKoDiQ'))
5252
.toList();
53-
expect(videos.length, greaterThanOrEqualTo(75));
53+
expect(videos.length, greaterThanOrEqualTo(50));
5454
});
5555

5656
group('Get the videos of any youtube channel', () {
@@ -84,7 +84,7 @@ void main() {
8484
expect(aboutPage.description, isNotEmpty);
8585
expect(aboutPage.thumbnails, isNotEmpty); // Avatar list
8686
expect(aboutPage.channelLinks, isNotNull);
87-
expect(aboutPage.country, 'United States');
87+
expect(aboutPage.country, 'Japan');
8888
expect(aboutPage.joinDate, 'Apr 29, 2010');
8989
});
9090
}

test/closed_caption_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ void main() {
6363
caption.text,
6464
anyOf('how about this black there are some',
6565
'there are some really nice colors here')); // Seems like sometimes the text changes.
66-
expect(captionPart?.text, anyOf(' about', ' some'));
66+
expect(captionPart?.text, anyOf(' about', ' some', ' are'));
6767
});
6868
}

test/playlist_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ void main() {
1313

1414
test('Get metadata of a playlist', () async {
1515
var playlistUrl =
16-
'https://www.youtube.com/playlist?list=PLr-IftNTIujSF-8tlGbZBQyGIT6TCF6Yd';
16+
'https://www.youtube.com/playlist?list=PLxTcxOtc5WIPFIyrYAvGqGhfAOmKJB0V3';
1717
var playlist = await yt!.playlists.get(PlaylistId(playlistUrl));
18-
expect(playlist.id.value, 'PLr-IftNTIujSF-8tlGbZBQyGIT6TCF6Yd');
18+
expect(playlist.id.value, 'PLxTcxOtc5WIPFIyrYAvGqGhfAOmKJB0V3');
1919
expect(playlist.url, playlistUrl);
20-
expect(playlist.title, 'osu! Highlights');
21-
expect(playlist.author, 'Tyrrrz');
22-
expect(playlist.description, 'My best osu! plays');
23-
expect(playlist.engagement.viewCount, greaterThanOrEqualTo(133));
20+
expect(playlist.title, 'Tutorial');
21+
expect(playlist.author, 'Hexah');
22+
expect(playlist.description, '');
23+
expect(playlist.engagement.viewCount, greaterThanOrEqualTo(2));
2424
expect(playlist.engagement.likeCount, isNull);
2525
expect(playlist.engagement.dislikeCount, isNull);
2626
expect(playlist.thumbnails.lowResUrl, isNotEmpty);
2727
expect(playlist.thumbnails.mediumResUrl, isNotEmpty);
2828
expect(playlist.thumbnails.highResUrl, isNotEmpty);
2929
expect(playlist.thumbnails.standardResUrl, isNotEmpty);
3030
expect(playlist.thumbnails.maxResUrl, isNotEmpty);
31-
expect(playlist.videoCount, greaterThanOrEqualTo(20));
31+
expect(playlist.videoCount, greaterThanOrEqualTo(3));
3232
});
3333
group('Get metadata of any playlist', () {
3434
for (final val in {

test/streams_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void main() {
4747
test('Get the hls manifest of a live stream', () async {
4848
expect(
4949
await yt!.videos.streamsClient
50-
.getHttpLiveStreamUrl(VideoId('5qap5aO4i9A')),
50+
.getHttpLiveStreamUrl(VideoId('jfKfPfyJRdk')),
5151
isNotEmpty);
5252
});
5353

0 commit comments

Comments
 (0)