Skip to content

Commit cc5c677

Browse files
committed
fix playlist continuationToken retrieval
1 parent f31d3c0 commit cc5c677

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

lib/src/reverse_engineering/pages/playlist_page.dart

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,22 @@ class _InitialData extends InitialData {
157157
?.getT<String>('text')
158158
.parseInt();
159159

160-
late final String? continuationToken =
161-
(videosContent ?? playlistVideosContent)
162-
?.firstWhereOrNull((e) => e['continuationItemRenderer'] != null)
163-
?.get('continuationItemRenderer')
164-
?.get('continuationEndpoint')
165-
?.get('continuationCommand')
166-
?.getT<String>('token');
160+
String? get continuationToken {
161+
final continuationEndpoint = (videosContent ?? playlistVideosContent)
162+
?.firstWhereOrNull((e) => e['continuationItemRenderer'] != null)
163+
?.get('continuationItemRenderer')
164+
?.get('continuationEndpoint');
165+
166+
return continuationEndpoint
167+
?.get('continuationCommand')
168+
?.getT<String>('token') ??
169+
continuationEndpoint
170+
?.get('commandExecutorCommand')
171+
?.getList('commands')
172+
?.firstWhereOrNull((e) => e['continuationCommand'] != null)
173+
?.get('continuationCommand')
174+
?.getT<String>('token');
175+
}
167176

168177
List<JsonMap>? get playlistVideosContent =>
169178
root

test/playlist_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ void main() {
5656
expect(videos.length, greaterThan(100));
5757
});
5858

59+
test('Get a shit ton of items from a playlist', () async {
60+
final videos = await yt!.playlists
61+
.getVideos(
62+
PlaylistId(
63+
'https://www.youtube.com/playlist?list=PLI_eFW8NAFzYAXZ5DrU6E6mQ_XfhaLBUX',
64+
),
65+
)
66+
.toList();
67+
expect(videos.length, greaterThan(3500));
68+
}, timeout: Timeout(Duration(minutes: 3)));
69+
5970
group('Get videos in any playlist', () {
6071
for (final val in {
6172
PlaylistId('PLI5YfMzCfRtZ8eV576YoY3vIYrHjyVm_e'),

0 commit comments

Comments
 (0)