Add `estimatedResults` in `SearchQuery`
This commit is contained in:
parent
d5fa69a445
commit
23e6e54245
|
@ -71,9 +71,9 @@ class SearchPage {
|
|||
return null;
|
||||
}
|
||||
return get(httpClient, queryString,
|
||||
ctoken: initialData.continuation,
|
||||
itct: initialData.clickTrackingParams,
|
||||
xsrfToken: xsfrToken);
|
||||
ctoken: initialData.continuation,
|
||||
itct: initialData.clickTrackingParams,
|
||||
xsrfToken: xsfrToken);
|
||||
}
|
||||
|
||||
static Future<SearchPage> get(
|
||||
|
@ -106,8 +106,6 @@ class SearchPage {
|
|||
}
|
||||
|
||||
class _InitialData {
|
||||
//TODO: Add total result
|
||||
|
||||
// Json parsed map
|
||||
final Map<String, dynamic> _root;
|
||||
|
||||
|
@ -190,6 +188,8 @@ class _InitialData {
|
|||
String get clickTrackingParams => _clickTrackingParams ??=
|
||||
getContinuationContext(_root)?.getValue('clickTrackingParams') ?? '';
|
||||
|
||||
int get estimatedResults => int.parse(_root['estimatedResults'] ?? 0);
|
||||
|
||||
dynamic _parseContent(dynamic content) {
|
||||
if (content == null) {
|
||||
return null;
|
||||
|
|
|
@ -108,4 +108,4 @@ class _StreamInfo extends StreamInfoProvider {
|
|||
|
||||
@override
|
||||
int get framerate => int.tryParse(_root['fps'] ?? '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@ class RelatedQuery {
|
|||
|
||||
/// Initialize a [RelatedQuery] instance.
|
||||
RelatedQuery(this.query, this.videoId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,4 +41,7 @@ class SearchQuery {
|
|||
|
||||
/// Returns the queries related to this search.
|
||||
List<RelatedQuery> get relatedQueries => _page.initialData.relatedQueries;
|
||||
|
||||
/// Returns the estimated search result count.
|
||||
int get estimatedResults => _page.initialData.estimatedResults;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ void main() {
|
|||
expect(videos, isNotEmpty);
|
||||
});
|
||||
test('SearchYouTubeVideosFromPage', () async {
|
||||
var searchQuery = await yt.search
|
||||
.queryFromPage('hello');
|
||||
var searchQuery = await yt.search.queryFromPage('hello');
|
||||
expect(searchQuery.content, isNotEmpty);
|
||||
expect(searchQuery.relatedVideos, isNotEmpty);
|
||||
expect(searchQuery.relatedQueries, isNotEmpty);
|
||||
|
|
Loading…
Reference in New Issue