From aa034aa83054a4ad51afc6cb048cd89d26191b0b Mon Sep 17 00:00:00 2001 From: Mattia Date: Fri, 23 Jul 2021 13:10:13 +0200 Subject: [PATCH] Remove relatedQueries endpoint. --- .../pages/search_page.dart | 15 -- lib/src/search/related_query.dart | 18 -- lib/src/search/related_query.freezed.dart | 183 ------------------ lib/src/search/search.dart | 1 - lib/src/search/search_query.dart | 4 - test/search_test.dart | 1 - 6 files changed, 222 deletions(-) delete mode 100644 lib/src/search/related_query.dart delete mode 100644 lib/src/search/related_query.freezed.dart diff --git a/lib/src/reverse_engineering/pages/search_page.dart b/lib/src/reverse_engineering/pages/search_page.dart index d7e2de7..f317ee7 100644 --- a/lib/src/reverse_engineering/pages/search_page.dart +++ b/lib/src/reverse_engineering/pages/search_page.dart @@ -7,7 +7,6 @@ import '../../../youtube_explode_dart.dart'; import '../../extensions/helpers_extension.dart'; import '../../retry.dart'; import '../../search/base_search_content.dart'; -import '../../search/related_query.dart'; import '../../search/search_filter.dart'; import '../../search/search_video.dart'; import '../../videos/videos.dart'; @@ -119,20 +118,6 @@ class _InitialData extends InitialData { getContentContext()?.map(_parseContent).whereNotNull().toList() ?? const []; - List get relatedQueries => - getContentContext() - ?.where((e) => e['horizontalCardListRenderer'] != null) - .map((e) => e.get('horizontalCardListRenderer')?.getList('cards')) - .firstOrNull - ?.map((e) => e['searchRefinementCardRenderer']) - .map((e) => RelatedQuery( - e.searchEndpoint.searchEndpoint.query, - VideoId( - Uri.parse(e.thumbnail.thumbnails.first.url).pathSegments[1]))) - .toList() - .cast() ?? - const []; - List get relatedVideos => getContentContext() ?.where((e) => e['shelfRenderer'] != null) diff --git a/lib/src/search/related_query.dart b/lib/src/search/related_query.dart deleted file mode 100644 index 1a3aafb..0000000 --- a/lib/src/search/related_query.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -import '../videos/video_id.dart'; - -part 'related_query.freezed.dart'; - -/// -@freezed -class RelatedQuery with _$RelatedQuery { - /// Initialize a [RelatedQuery] instance. - const factory RelatedQuery( - - /// Query related to a search query. - String query, - - /// Video related to a search query. - VideoId videoId) = _RelatedQuery; -} diff --git a/lib/src/search/related_query.freezed.dart b/lib/src/search/related_query.freezed.dart deleted file mode 100644 index dc7fc02..0000000 --- a/lib/src/search/related_query.freezed.dart +++ /dev/null @@ -1,183 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target - -part of 'related_query.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); - -/// @nodoc -class _$RelatedQueryTearOff { - const _$RelatedQueryTearOff(); - - _RelatedQuery call(String query, VideoId videoId) { - return _RelatedQuery( - query, - videoId, - ); - } -} - -/// @nodoc -const $RelatedQuery = _$RelatedQueryTearOff(); - -/// @nodoc -mixin _$RelatedQuery { - /// Query related to a search query. - String get query => throw _privateConstructorUsedError; - - /// Video related to a search query. - VideoId get videoId => throw _privateConstructorUsedError; - - @JsonKey(ignore: true) - $RelatedQueryCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $RelatedQueryCopyWith<$Res> { - factory $RelatedQueryCopyWith( - RelatedQuery value, $Res Function(RelatedQuery) then) = - _$RelatedQueryCopyWithImpl<$Res>; - $Res call({String query, VideoId videoId}); - - $VideoIdCopyWith<$Res> get videoId; -} - -/// @nodoc -class _$RelatedQueryCopyWithImpl<$Res> implements $RelatedQueryCopyWith<$Res> { - _$RelatedQueryCopyWithImpl(this._value, this._then); - - final RelatedQuery _value; - // ignore: unused_field - final $Res Function(RelatedQuery) _then; - - @override - $Res call({ - Object? query = freezed, - Object? videoId = freezed, - }) { - return _then(_value.copyWith( - query: query == freezed - ? _value.query - : query // ignore: cast_nullable_to_non_nullable - as String, - videoId: videoId == freezed - ? _value.videoId - : videoId // ignore: cast_nullable_to_non_nullable - as VideoId, - )); - } - - @override - $VideoIdCopyWith<$Res> get videoId { - return $VideoIdCopyWith<$Res>(_value.videoId, (value) { - return _then(_value.copyWith(videoId: value)); - }); - } -} - -/// @nodoc -abstract class _$RelatedQueryCopyWith<$Res> - implements $RelatedQueryCopyWith<$Res> { - factory _$RelatedQueryCopyWith( - _RelatedQuery value, $Res Function(_RelatedQuery) then) = - __$RelatedQueryCopyWithImpl<$Res>; - @override - $Res call({String query, VideoId videoId}); - - @override - $VideoIdCopyWith<$Res> get videoId; -} - -/// @nodoc -class __$RelatedQueryCopyWithImpl<$Res> extends _$RelatedQueryCopyWithImpl<$Res> - implements _$RelatedQueryCopyWith<$Res> { - __$RelatedQueryCopyWithImpl( - _RelatedQuery _value, $Res Function(_RelatedQuery) _then) - : super(_value, (v) => _then(v as _RelatedQuery)); - - @override - _RelatedQuery get _value => super._value as _RelatedQuery; - - @override - $Res call({ - Object? query = freezed, - Object? videoId = freezed, - }) { - return _then(_RelatedQuery( - query == freezed - ? _value.query - : query // ignore: cast_nullable_to_non_nullable - as String, - videoId == freezed - ? _value.videoId - : videoId // ignore: cast_nullable_to_non_nullable - as VideoId, - )); - } -} - -/// @nodoc - -class _$_RelatedQuery implements _RelatedQuery { - const _$_RelatedQuery(this.query, this.videoId); - - @override - - /// Query related to a search query. - final String query; - @override - - /// Video related to a search query. - final VideoId videoId; - - @override - String toString() { - return 'RelatedQuery(query: $query, videoId: $videoId)'; - } - - @override - bool operator ==(dynamic other) { - return identical(this, other) || - (other is _RelatedQuery && - (identical(other.query, query) || - const DeepCollectionEquality().equals(other.query, query)) && - (identical(other.videoId, videoId) || - const DeepCollectionEquality().equals(other.videoId, videoId))); - } - - @override - int get hashCode => - runtimeType.hashCode ^ - const DeepCollectionEquality().hash(query) ^ - const DeepCollectionEquality().hash(videoId); - - @JsonKey(ignore: true) - @override - _$RelatedQueryCopyWith<_RelatedQuery> get copyWith => - __$RelatedQueryCopyWithImpl<_RelatedQuery>(this, _$identity); -} - -abstract class _RelatedQuery implements RelatedQuery { - const factory _RelatedQuery(String query, VideoId videoId) = _$_RelatedQuery; - - @override - - /// Query related to a search query. - String get query => throw _privateConstructorUsedError; - @override - - /// Video related to a search query. - VideoId get videoId => throw _privateConstructorUsedError; - @override - @JsonKey(ignore: true) - _$RelatedQueryCopyWith<_RelatedQuery> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/src/search/search.dart b/lib/src/search/search.dart index 77b8ac2..40055d3 100644 --- a/lib/src/search/search.dart +++ b/lib/src/search/search.dart @@ -3,7 +3,6 @@ /// {@category Search} library youtube_explode.search; -export 'related_query.dart'; export 'search_client.dart'; export 'search_filter.dart'; export 'search_list.dart'; diff --git a/lib/src/search/search_query.dart b/lib/src/search/search_query.dart index ad4f8f7..031d822 100644 --- a/lib/src/search/search_query.dart +++ b/lib/src/search/search_query.dart @@ -1,6 +1,5 @@ import '../reverse_engineering/pages/search_page.dart'; import '../reverse_engineering/youtube_http_client.dart'; -import 'related_query.dart'; /// class SearchQuery { @@ -39,9 +38,6 @@ class SearchQuery { /// Contains either [SearchVideo] or [SearchPlaylist] List get relatedVideos => _page.initialData.relatedVideos; - /// Returns the queries related to this search. - List get relatedQueries => _page.initialData.relatedQueries; - /// Returns the estimated search result count. int get estimatedResults => _page.initialData.estimatedResults; } diff --git a/test/search_test.dart b/test/search_test.dart index 4d2e131..8aa9bb2 100644 --- a/test/search_test.dart +++ b/test/search_test.dart @@ -41,7 +41,6 @@ void main() { // ignore: deprecated_member_use_from_same_package await yt!.search.queryFromPage('g;jghEOGHJeguEPOUIhjegoUEHGOGHPSASG'); expect(query.content, isEmpty); - expect(query.relatedQueries, isEmpty); expect(query.relatedVideos, isEmpty); var nextPage = await query.nextPage(); expect(nextPage, isNull);