1
1
import 'package:collection/collection.dart' ;
2
2
import 'package:html/parser.dart' as parser;
3
+ import '../../channels/video_type.dart' ;
3
4
4
5
import '../../channels/channel_video.dart' ;
5
6
import '../../exceptions/exceptions.dart' ;
@@ -15,10 +16,12 @@ class ChannelUploadPage extends YoutubePage<_InitialData> {
15
16
///
16
17
final String channelId;
17
18
19
+ final VideoType type;
20
+
18
21
late final List <ChannelVideo > uploads = initialData.uploads;
19
22
20
23
/// InitialData
21
- ChannelUploadPage .id (this .channelId, super .initialData)
24
+ ChannelUploadPage .id (this .channelId, this .type, super .initialData)
22
25
: super .fromInitialData ();
23
26
24
27
///
@@ -28,30 +31,33 @@ class ChannelUploadPage extends YoutubePage<_InitialData> {
28
31
}
29
32
30
33
final data = await httpClient.sendContinuation ('browse' , initialData.token);
31
- return ChannelUploadPage .id (channelId, _InitialData (data));
34
+ return ChannelUploadPage .id (channelId, type, _InitialData (data, type ));
32
35
}
33
36
34
37
///
35
38
static Future <ChannelUploadPage > get (
36
39
YoutubeHttpClient httpClient,
37
40
String channelId,
38
41
String sorting,
42
+ VideoType type,
39
43
) {
40
44
final url =
41
- 'https://www.youtube.com/channel/$channelId /videos ?view=0&sort=$sorting &flow=grid' ;
45
+ 'https://www.youtube.com/channel/$channelId /${ type . name } ?view=0&sort=$sorting &flow=grid' ;
42
46
return retry (httpClient, () async {
43
47
final raw = await httpClient.getString (url);
44
- return ChannelUploadPage .parse (raw, channelId);
48
+ return ChannelUploadPage .parse (raw, channelId, type );
45
49
});
46
50
}
47
51
48
52
///
49
- ChannelUploadPage .parse (String raw, this .channelId)
50
- : super (parser.parse (raw), (root) => _InitialData (root));
53
+ ChannelUploadPage .parse (String raw, this .channelId, this .type )
54
+ : super (parser.parse (raw), (root) => _InitialData (root, type ));
51
55
}
52
56
53
57
class _InitialData extends InitialData {
54
- _InitialData (super .root);
58
+ _InitialData (super .root, this .type);
59
+
60
+ final VideoType type;
55
61
56
62
late final JsonMap ? continuationContext = getContinuationContext ();
57
63
@@ -175,8 +181,10 @@ class _InitialData extends InitialData {
175
181
if (content.containsKey ('gridVideoRenderer' )) {
176
182
video = content.get ('gridVideoRenderer' );
177
183
} else if (content.containsKey ('richItemRenderer' )) {
178
- video =
179
- content.get ('richItemRenderer' )? .get ('content' )? .get ('videoRenderer' );
184
+ video = content
185
+ .get ('richItemRenderer' )
186
+ ? .get ('content' )
187
+ ? .get (type.youtubeRenderText);
180
188
}
181
189
182
190
if (video == null ) {
0 commit comments