youtube_explode/lib/src/youtube_explode_base.dart

38 lines
1.1 KiB
Dart
Raw Permalink Normal View History

2020-06-05 20:08:04 +02:00
library youtube_explode.base;
2020-06-03 23:02:21 +02:00
import 'channels/channels.dart';
import 'playlists/playlist_client.dart';
import 'reverse_engineering/youtube_http_client.dart';
2020-06-06 11:28:36 +02:00
import 'search/search_client.dart';
2020-06-03 23:02:21 +02:00
import 'videos/video_client.dart';
/// Library entry point.
class YoutubeExplode {
2021-10-04 13:00:22 +02:00
final YoutubeHttpClient _httpClient;
2020-06-03 23:02:21 +02:00
/// Queries related to YouTube videos.
2021-03-11 14:20:10 +01:00
late final VideoClient videos;
2020-06-03 23:02:21 +02:00
/// Queries related to YouTube playlists.
2021-03-11 14:20:10 +01:00
late final PlaylistClient playlists;
2020-06-03 23:02:21 +02:00
/// Queries related to YouTube channels.
2021-03-11 14:20:10 +01:00
late final ChannelClient channels;
2020-06-03 23:02:21 +02:00
/// YouTube search queries.
2021-03-11 14:20:10 +01:00
late final SearchClient search;
2020-06-03 23:02:21 +02:00
2020-06-06 11:28:36 +02:00
/// Initializes an instance of [YoutubeClient].
2021-03-11 14:20:10 +01:00
YoutubeExplode([YoutubeHttpClient? httpClient])
2021-10-04 13:00:22 +02:00
: _httpClient = httpClient ?? YoutubeHttpClient() {
videos = VideoClient(_httpClient);
playlists = PlaylistClient(_httpClient);
channels = ChannelClient(_httpClient);
search = SearchClient(_httpClient);
2020-06-03 23:02:21 +02:00
}
/// Closes the HttpClient assigned to this [YoutubeHttpClient].
/// Should be called after this is not used anymore.
2021-10-04 13:00:22 +02:00
void close() => _httpClient.close();
2020-06-03 23:02:21 +02:00
}