From fd20ae95b1d517bdb5b43293c592f61eb94733ec Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Tue, 18 Oct 2022 09:39:16 +0100 Subject: [PATCH] Add replyCount in comments and unauthenticated feed api. --- .openapi-generator/FILES | 12 + README.md | 21 +- doc/ChannelApi.md | 191 ++++++++++++++++ doc/Comment.md | 1 + doc/FeedApi.md | 57 +++++ doc/SearchApi.md | 107 +++++++++ doc/UnauthenticatedApi.md | 56 ++++- doc/VideoApi.md | 147 ++++++++++++ lib/piped_api.dart | 4 + lib/src/api.dart | 28 +++ lib/src/api/channel_api.dart | 326 +++++++++++++++++++++++++++ lib/src/api/feed_api.dart | 102 +++++++++ lib/src/api/search_api.dart | 190 ++++++++++++++++ lib/src/api/unauthenticated_api.dart | 85 ++++++- lib/src/api/video_api.dart | 252 +++++++++++++++++++++ lib/src/model/comment.dart | 19 ++ lib/src/model/comment.g.dart | 29 ++- lib/src/serializers.dart | 4 + test/channel_api_test.dart | 47 ++++ test/feed_api_test.dart | 20 ++ test/search_api_test.dart | 29 +++ test/video_api_test.dart | 38 ++++ 22 files changed, 1743 insertions(+), 22 deletions(-) create mode 100644 doc/ChannelApi.md create mode 100644 doc/FeedApi.md create mode 100644 doc/SearchApi.md create mode 100644 doc/VideoApi.md create mode 100644 lib/src/api/channel_api.dart create mode 100644 lib/src/api/feed_api.dart create mode 100644 lib/src/api/search_api.dart create mode 100644 lib/src/api/video_api.dart create mode 100644 test/channel_api_test.dart create mode 100644 test/feed_api_test.dart create mode 100644 test/search_api_test.dart create mode 100644 test/video_api_test.dart diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index f0f08f2..590c584 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,13 +1,16 @@ .gitignore README.md analysis_options.yaml +doc/ChannelApi.md doc/ChannelInfo.md doc/ChannelItem.md doc/Comment.md doc/CommentsPage.md doc/ExceptionError.md +doc/FeedApi.md doc/PlaylistItem.md doc/Regions.md +doc/SearchApi.md doc/SearchFilter.md doc/SearchItem.md doc/SearchPage.md @@ -16,10 +19,15 @@ doc/StreamItem.md doc/StreamsPage.md doc/Subtitle.md doc/UnauthenticatedApi.md +doc/VideoApi.md doc/VideoInfo.md lib/piped_api.dart lib/src/api.dart +lib/src/api/channel_api.dart +lib/src/api/feed_api.dart +lib/src/api/search_api.dart lib/src/api/unauthenticated_api.dart +lib/src/api/video_api.dart lib/src/api_util.dart lib/src/auth/api_key_auth.dart lib/src/auth/auth.dart @@ -45,3 +53,7 @@ lib/src/model/subtitle.dart lib/src/model/video_info.dart lib/src/serializers.dart pubspec.yaml +test/channel_api_test.dart +test/feed_api_test.dart +test/search_api_test.dart +test/video_api_test.dart diff --git a/README.md b/README.md index 6f01a79..b23a476 100644 --- a/README.md +++ b/README.md @@ -47,14 +47,14 @@ Please follow the [installation procedure](#installation--usage) and then run th import 'package:piped_api/piped_api.dart'; -final api = PipedApi().getUnauthenticatedApi(); +final api = PipedApi().getChannelApi(); final String channelId = UCs6KfncB4OV6Vug4o_bzijg; // String | The channel ID of the YouTube channel you want to get information about. try { final response = await api.channelInfoId(channelId); print(response); } catch on DioError (e) { - print("Exception when calling UnauthenticatedApi->channelInfoId: $e\n"); + print("Exception when calling ChannelApi->channelInfoId: $e\n"); } ``` @@ -65,16 +65,27 @@ All URIs are relative to *https://pipedapi.kavin.rocks* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelInfoId**](doc/UnauthenticatedApi.md#channelinfoid) | **GET** /channel/{channelId} | Gets Channel Information -[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelInfoName**](doc/UnauthenticatedApi.md#channelinfoname) | **GET** /c/{name} | Gets Channel Information -[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelInfoUsername**](doc/UnauthenticatedApi.md#channelinfousername) | **GET** /user/{username} | Gets Channel Information +[*ChannelApi*](doc/ChannelApi.md) | [**channelInfoId**](doc/ChannelApi.md#channelinfoid) | **GET** /channel/{channelId} | Gets Channel Information from ID. +[*ChannelApi*](doc/ChannelApi.md) | [**channelInfoName**](doc/ChannelApi.md#channelinfoname) | **GET** /c/{name} | Gets Channel Information from name. +[*ChannelApi*](doc/ChannelApi.md) | [**channelInfoUsername**](doc/ChannelApi.md#channelinfousername) | **GET** /user/{username} | Gets Channel Information from username. +[*ChannelApi*](doc/ChannelApi.md) | [**channelNextPage**](doc/ChannelApi.md#channelnextpage) | **GET** /nextpage/channel/{channelId} | Gets more channel videos +[*FeedApi*](doc/FeedApi.md) | [**feedUnauthenticated**](doc/FeedApi.md#feedunauthenticated) | **GET** /feed/unauthenticated | Generate a feed while unauthenticated, from a list of channelIds. +[*SearchApi*](doc/SearchApi.md) | [**search**](doc/SearchApi.md#search) | **GET** /search | Searches for videos, channels, and playlists. +[*SearchApi*](doc/SearchApi.md) | [**searchNextPage**](doc/SearchApi.md#searchnextpage) | **GET** /nextpage/search | Gets more search results +[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelInfoId**](doc/UnauthenticatedApi.md#channelinfoid) | **GET** /channel/{channelId} | Gets Channel Information from ID. +[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelInfoName**](doc/UnauthenticatedApi.md#channelinfoname) | **GET** /c/{name} | Gets Channel Information from name. +[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelInfoUsername**](doc/UnauthenticatedApi.md#channelinfousername) | **GET** /user/{username} | Gets Channel Information from username. [*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**channelNextPage**](doc/UnauthenticatedApi.md#channelnextpage) | **GET** /nextpage/channel/{channelId} | Gets more channel videos [*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**comments**](doc/UnauthenticatedApi.md#comments) | **GET** /comments/{videoId} | Gets Comments [*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**commentsNextPage**](doc/UnauthenticatedApi.md#commentsnextpage) | **GET** /nextpage/comments/{videoId} | Gets more comments +[*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**feedUnauthenticated**](doc/UnauthenticatedApi.md#feedunauthenticated) | **GET** /feed/unauthenticated | Generate a feed while unauthenticated, from a list of channelIds. [*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**search**](doc/UnauthenticatedApi.md#search) | **GET** /search | Searches for videos, channels, and playlists. [*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**searchNextPage**](doc/UnauthenticatedApi.md#searchnextpage) | **GET** /nextpage/search | Gets more search results [*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**streamInfo**](doc/UnauthenticatedApi.md#streaminfo) | **GET** /streams/{videoId} | Gets Video Information [*UnauthenticatedApi*](doc/UnauthenticatedApi.md) | [**trending**](doc/UnauthenticatedApi.md#trending) | **GET** /trending | Gets all Trending Videos +[*VideoApi*](doc/VideoApi.md) | [**comments**](doc/VideoApi.md#comments) | **GET** /comments/{videoId} | Gets Comments +[*VideoApi*](doc/VideoApi.md) | [**commentsNextPage**](doc/VideoApi.md#commentsnextpage) | **GET** /nextpage/comments/{videoId} | Gets more comments +[*VideoApi*](doc/VideoApi.md) | [**streamInfo**](doc/VideoApi.md#streaminfo) | **GET** /streams/{videoId} | Gets Video Information ## Documentation For Models diff --git a/doc/ChannelApi.md b/doc/ChannelApi.md new file mode 100644 index 0000000..b41d8b6 --- /dev/null +++ b/doc/ChannelApi.md @@ -0,0 +1,191 @@ +# piped_api.api.ChannelApi + +## Load the API package +```dart +import 'package:piped_api/api.dart'; +``` + +All URIs are relative to *https://pipedapi.kavin.rocks* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**channelInfoId**](ChannelApi.md#channelinfoid) | **GET** /channel/{channelId} | Gets Channel Information from ID. +[**channelInfoName**](ChannelApi.md#channelinfoname) | **GET** /c/{name} | Gets Channel Information from name. +[**channelInfoUsername**](ChannelApi.md#channelinfousername) | **GET** /user/{username} | Gets Channel Information from username. +[**channelNextPage**](ChannelApi.md#channelnextpage) | **GET** /nextpage/channel/{channelId} | Gets more channel videos + + +# **channelInfoId** +> ChannelInfo channelInfoId(channelId) + +Gets Channel Information from ID. + +Gets all available Channel information about a channel. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getChannelApi(); +final String channelId = UCs6KfncB4OV6Vug4o_bzijg; // String | The channel ID of the YouTube channel you want to get information about. + +try { + final response = api.channelInfoId(channelId); + print(response); +} catch on DioError (e) { + print('Exception when calling ChannelApi->channelInfoId: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **channelId** | **String**| The channel ID of the YouTube channel you want to get information about. | + +### Return type + +[**ChannelInfo**](ChannelInfo.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **channelInfoName** +> ChannelInfo channelInfoName(name) + +Gets Channel Information from name. + +Gets all available Channel information about a channel. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getChannelApi(); +final String name = Dream; // String | The name of the YouTube channel you want to get information about. + +try { + final response = api.channelInfoName(name); + print(response); +} catch on DioError (e) { + print('Exception when calling ChannelApi->channelInfoName: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **name** | **String**| The name of the YouTube channel you want to get information about. | + +### Return type + +[**ChannelInfo**](ChannelInfo.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **channelInfoUsername** +> ChannelInfo channelInfoUsername(username) + +Gets Channel Information from username. + +Gets all available Channel information about a channel. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getChannelApi(); +final String username = DreamTraps; // String | The username of the YouTube channel you want to get information about. + +try { + final response = api.channelInfoUsername(username); + print(response); +} catch on DioError (e) { + print('Exception when calling ChannelApi->channelInfoUsername: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The username of the YouTube channel you want to get information about. | + +### Return type + +[**ChannelInfo**](ChannelInfo.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **channelNextPage** +> StreamsPage channelNextPage(channelId, nextpage) + +Gets more channel videos + +Gets more channel videos. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getChannelApi(); +final String channelId = UCs6KfncB4OV6Vug4o_bzijg; // String | The channel ID of the YouTube channel you want to get more videos from. +final String nextpage = nextpage_example; // String | The next page token to get more videos from. + +try { + final response = api.channelNextPage(channelId, nextpage); + print(response); +} catch on DioError (e) { + print('Exception when calling ChannelApi->channelNextPage: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **channelId** | **String**| The channel ID of the YouTube channel you want to get more videos from. | + **nextpage** | **String**| The next page token to get more videos from. | + +### Return type + +[**StreamsPage**](StreamsPage.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/doc/Comment.md b/doc/Comment.md index 60f8acd..bfcc6f6 100644 --- a/doc/Comment.md +++ b/doc/Comment.md @@ -16,6 +16,7 @@ Name | Type | Description | Notes **commentorUrl** | **String** | The relative URL of the author of the comment. | [optional] **repliesPage** | **String** | The parameter used as the nextpage to fetch replies for this comment. | [optional] **likeCount** | **int** | The number of likes the comment has. | [optional] +**replyCount** | **int** | The number of replies the comment has. | [optional] **hearted** | **bool** | Whether the comment was hearted by the video's uploader. | [optional] **pinned** | **bool** | Whether the comment was pinned by the video's uploader. | [optional] **verified** | **bool** | Whether the author of the comment is verified. | [optional] diff --git a/doc/FeedApi.md b/doc/FeedApi.md new file mode 100644 index 0000000..209425b --- /dev/null +++ b/doc/FeedApi.md @@ -0,0 +1,57 @@ +# piped_api.api.FeedApi + +## Load the API package +```dart +import 'package:piped_api/api.dart'; +``` + +All URIs are relative to *https://pipedapi.kavin.rocks* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**feedUnauthenticated**](FeedApi.md#feedunauthenticated) | **GET** /feed/unauthenticated | Generate a feed while unauthenticated, from a list of channelIds. + + +# **feedUnauthenticated** +> BuiltList feedUnauthenticated(channels) + +Generate a feed while unauthenticated, from a list of channelIds. + +Generates a user feed while unauthenticated. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getFeedApi(); +final BuiltList channels = ["UCs6KfncB4OV6Vug4o_bzijg","UClcE-kVhqyiHCcjYwcpfj9w"]; // BuiltList | A list of channelIds to generate a feed from. + +try { + final response = api.feedUnauthenticated(channels); + print(response); +} catch on DioError (e) { + print('Exception when calling FeedApi->feedUnauthenticated: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **channels** | [**BuiltList<String>**](String.md)| A list of channelIds to generate a feed from. | + +### Return type + +[**BuiltList<StreamItem>**](StreamItem.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/doc/SearchApi.md b/doc/SearchApi.md new file mode 100644 index 0000000..9b82a56 --- /dev/null +++ b/doc/SearchApi.md @@ -0,0 +1,107 @@ +# piped_api.api.SearchApi + +## Load the API package +```dart +import 'package:piped_api/api.dart'; +``` + +All URIs are relative to *https://pipedapi.kavin.rocks* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**search**](SearchApi.md#search) | **GET** /search | Searches for videos, channels, and playlists. +[**searchNextPage**](SearchApi.md#searchnextpage) | **GET** /nextpage/search | Gets more search results + + +# **search** +> SearchPage search(q, filter) + +Searches for videos, channels, and playlists. + +Searches for videos, channels, and playlists. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getSearchApi(); +final String q = Techlore; // String | The search query string. +final SearchFilter filter = ; // SearchFilter | The filter parameter specifies a filter query that restricts the results to items that match the filter. + +try { + final response = api.search(q, filter); + print(response); +} catch on DioError (e) { + print('Exception when calling SearchApi->search: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **q** | **String**| The search query string. | + **filter** | [**SearchFilter**](.md)| The filter parameter specifies a filter query that restricts the results to items that match the filter. | + +### Return type + +[**SearchPage**](SearchPage.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **searchNextPage** +> SearchPage searchNextPage(nextpage, q, filter) + +Gets more search results + +Gets more search results. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getSearchApi(); +final String nextpage = nextpage_example; // String | The next page token to get more search results from. +final String q = Techlore; // String | The search query string. +final SearchFilter filter = ; // SearchFilter | The filter parameter specifies a filter query that restricts the results to items that match the filter. + +try { + final response = api.searchNextPage(nextpage, q, filter); + print(response); +} catch on DioError (e) { + print('Exception when calling SearchApi->searchNextPage: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **nextpage** | **String**| The next page token to get more search results from. | + **q** | **String**| The search query string. | + **filter** | [**SearchFilter**](.md)| The filter parameter specifies a filter query that restricts the results to items that match the filter. | + +### Return type + +[**SearchPage**](SearchPage.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/doc/UnauthenticatedApi.md b/doc/UnauthenticatedApi.md index 2c2905d..b2d2af0 100644 --- a/doc/UnauthenticatedApi.md +++ b/doc/UnauthenticatedApi.md @@ -9,12 +9,13 @@ All URIs are relative to *https://pipedapi.kavin.rocks* Method | HTTP request | Description ------------- | ------------- | ------------- -[**channelInfoId**](UnauthenticatedApi.md#channelinfoid) | **GET** /channel/{channelId} | Gets Channel Information -[**channelInfoName**](UnauthenticatedApi.md#channelinfoname) | **GET** /c/{name} | Gets Channel Information -[**channelInfoUsername**](UnauthenticatedApi.md#channelinfousername) | **GET** /user/{username} | Gets Channel Information +[**channelInfoId**](UnauthenticatedApi.md#channelinfoid) | **GET** /channel/{channelId} | Gets Channel Information from ID. +[**channelInfoName**](UnauthenticatedApi.md#channelinfoname) | **GET** /c/{name} | Gets Channel Information from name. +[**channelInfoUsername**](UnauthenticatedApi.md#channelinfousername) | **GET** /user/{username} | Gets Channel Information from username. [**channelNextPage**](UnauthenticatedApi.md#channelnextpage) | **GET** /nextpage/channel/{channelId} | Gets more channel videos [**comments**](UnauthenticatedApi.md#comments) | **GET** /comments/{videoId} | Gets Comments [**commentsNextPage**](UnauthenticatedApi.md#commentsnextpage) | **GET** /nextpage/comments/{videoId} | Gets more comments +[**feedUnauthenticated**](UnauthenticatedApi.md#feedunauthenticated) | **GET** /feed/unauthenticated | Generate a feed while unauthenticated, from a list of channelIds. [**search**](UnauthenticatedApi.md#search) | **GET** /search | Searches for videos, channels, and playlists. [**searchNextPage**](UnauthenticatedApi.md#searchnextpage) | **GET** /nextpage/search | Gets more search results [**streamInfo**](UnauthenticatedApi.md#streaminfo) | **GET** /streams/{videoId} | Gets Video Information @@ -24,7 +25,7 @@ Method | HTTP request | Description # **channelInfoId** > ChannelInfo channelInfoId(channelId) -Gets Channel Information +Gets Channel Information from ID. Gets all available Channel information about a channel. @@ -67,7 +68,7 @@ No authorization required # **channelInfoName** > ChannelInfo channelInfoName(name) -Gets Channel Information +Gets Channel Information from name. Gets all available Channel information about a channel. @@ -110,7 +111,7 @@ No authorization required # **channelInfoUsername** > ChannelInfo channelInfoUsername(username) -Gets Channel Information +Gets Channel Information from username. Gets all available Channel information about a channel. @@ -283,6 +284,49 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **feedUnauthenticated** +> BuiltList feedUnauthenticated(channels) + +Generate a feed while unauthenticated, from a list of channelIds. + +Generates a user feed while unauthenticated. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getUnauthenticatedApi(); +final BuiltList channels = ["UCs6KfncB4OV6Vug4o_bzijg","UClcE-kVhqyiHCcjYwcpfj9w"]; // BuiltList | A list of channelIds to generate a feed from. + +try { + final response = api.feedUnauthenticated(channels); + print(response); +} catch on DioError (e) { + print('Exception when calling UnauthenticatedApi->feedUnauthenticated: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **channels** | [**BuiltList<String>**](String.md)| A list of channelIds to generate a feed from. | + +### Return type + +[**BuiltList<StreamItem>**](StreamItem.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **search** > SearchPage search(q, filter) diff --git a/doc/VideoApi.md b/doc/VideoApi.md new file mode 100644 index 0000000..d8369d2 --- /dev/null +++ b/doc/VideoApi.md @@ -0,0 +1,147 @@ +# piped_api.api.VideoApi + +## Load the API package +```dart +import 'package:piped_api/api.dart'; +``` + +All URIs are relative to *https://pipedapi.kavin.rocks* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**comments**](VideoApi.md#comments) | **GET** /comments/{videoId} | Gets Comments +[**commentsNextPage**](VideoApi.md#commentsnextpage) | **GET** /nextpage/comments/{videoId} | Gets more comments +[**streamInfo**](VideoApi.md#streaminfo) | **GET** /streams/{videoId} | Gets Video Information + + +# **comments** +> CommentsPage comments(videoId) + +Gets Comments + +Gets the comments for a video. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getVideoApi(); +final String videoId = dQw4w9WgXcQ; // String | The video ID of the YouTube video you want to get comments from. + +try { + final response = api.comments(videoId); + print(response); +} catch on DioError (e) { + print('Exception when calling VideoApi->comments: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **videoId** | **String**| The video ID of the YouTube video you want to get comments from. | + +### Return type + +[**CommentsPage**](CommentsPage.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **commentsNextPage** +> CommentsPage commentsNextPage(videoId, nextpage) + +Gets more comments + +Gets more comments. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getVideoApi(); +final String videoId = dQw4w9WgXcQ; // String | The video ID of the YouTube video you want to get more comments from. +final String nextpage = nextpage_example; // String | The next page token to get more comments from. + +try { + final response = api.commentsNextPage(videoId, nextpage); + print(response); +} catch on DioError (e) { + print('Exception when calling VideoApi->commentsNextPage: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **videoId** | **String**| The video ID of the YouTube video you want to get more comments from. | + **nextpage** | **String**| The next page token to get more comments from. | + +### Return type + +[**CommentsPage**](CommentsPage.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **streamInfo** +> VideoInfo streamInfo(videoId) + +Gets Video Information + +Gets all available Stream information about a video. + +### Example +```dart +import 'package:piped_api/api.dart'; + +final api = PipedApi().getVideoApi(); +final String videoId = dQw4w9WgXcQ; // String | The video ID of the YouTube video you want to get information about. + +try { + final response = api.streamInfo(videoId); + print(response); +} catch on DioError (e) { + print('Exception when calling VideoApi->streamInfo: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **videoId** | **String**| The video ID of the YouTube video you want to get information about. | + +### Return type + +[**VideoInfo**](VideoInfo.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/lib/piped_api.dart b/lib/piped_api.dart index def5332..3ace921 100644 --- a/lib/piped_api.dart +++ b/lib/piped_api.dart @@ -9,7 +9,11 @@ export 'package:piped_api/src/auth/oauth.dart'; export 'package:piped_api/src/serializers.dart'; export 'package:piped_api/src/model/date.dart'; +export 'package:piped_api/src/api/channel_api.dart'; +export 'package:piped_api/src/api/feed_api.dart'; +export 'package:piped_api/src/api/search_api.dart'; export 'package:piped_api/src/api/unauthenticated_api.dart'; +export 'package:piped_api/src/api/video_api.dart'; export 'package:piped_api/src/model/channel_info.dart'; export 'package:piped_api/src/model/channel_item.dart'; diff --git a/lib/src/api.dart b/lib/src/api.dart index 1c2a280..b50ff86 100644 --- a/lib/src/api.dart +++ b/lib/src/api.dart @@ -9,7 +9,11 @@ import 'package:piped_api/src/auth/api_key_auth.dart'; import 'package:piped_api/src/auth/basic_auth.dart'; import 'package:piped_api/src/auth/bearer_auth.dart'; import 'package:piped_api/src/auth/oauth.dart'; +import 'package:piped_api/src/api/channel_api.dart'; +import 'package:piped_api/src/api/feed_api.dart'; +import 'package:piped_api/src/api/search_api.dart'; import 'package:piped_api/src/api/unauthenticated_api.dart'; +import 'package:piped_api/src/api/video_api.dart'; class PipedApi { static const String basePath = r'https://pipedapi.kavin.rocks'; @@ -65,9 +69,33 @@ class PipedApi { } } + /// Get ChannelApi instance, base route and serializer can be overridden by a given but be careful, + /// by doing that all interceptors will not be executed + ChannelApi getChannelApi() { + return ChannelApi(dio, serializers); + } + + /// Get FeedApi instance, base route and serializer can be overridden by a given but be careful, + /// by doing that all interceptors will not be executed + FeedApi getFeedApi() { + return FeedApi(dio, serializers); + } + + /// Get SearchApi instance, base route and serializer can be overridden by a given but be careful, + /// by doing that all interceptors will not be executed + SearchApi getSearchApi() { + return SearchApi(dio, serializers); + } + /// Get UnauthenticatedApi instance, base route and serializer can be overridden by a given but be careful, /// by doing that all interceptors will not be executed UnauthenticatedApi getUnauthenticatedApi() { return UnauthenticatedApi(dio, serializers); } + + /// Get VideoApi instance, base route and serializer can be overridden by a given but be careful, + /// by doing that all interceptors will not be executed + VideoApi getVideoApi() { + return VideoApi(dio, serializers); + } } diff --git a/lib/src/api/channel_api.dart b/lib/src/api/channel_api.dart new file mode 100644 index 0000000..b0bfd8f --- /dev/null +++ b/lib/src/api/channel_api.dart @@ -0,0 +1,326 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'dart:async'; + +import 'package:built_value/serializer.dart'; +import 'package:dio/dio.dart'; + +import 'package:piped_api/src/api_util.dart'; +import 'package:piped_api/src/model/channel_info.dart'; +import 'package:piped_api/src/model/exception_error.dart'; +import 'package:piped_api/src/model/streams_page.dart'; + +class ChannelApi { + + final Dio _dio; + + final Serializers _serializers; + + const ChannelApi(this._dio, this._serializers); + + /// Gets Channel Information from ID. + /// Gets all available Channel information about a channel. + /// + /// Parameters: + /// * [channelId] - The channel ID of the YouTube channel you want to get information about. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [ChannelInfo] as data + /// Throws [DioError] if API call or serialization fails + Future> channelInfoId({ + required String channelId, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/channel/{channelId}'.replaceAll('{' r'channelId' '}', channelId.toString()); + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _response = await _dio.request( + _path, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + ChannelInfo _responseData; + + try { + const _responseType = FullType(ChannelInfo); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as ChannelInfo; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Gets Channel Information from name. + /// Gets all available Channel information about a channel. + /// + /// Parameters: + /// * [name] - The name of the YouTube channel you want to get information about. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [ChannelInfo] as data + /// Throws [DioError] if API call or serialization fails + Future> channelInfoName({ + required String name, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/c/{name}'.replaceAll('{' r'name' '}', name.toString()); + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _response = await _dio.request( + _path, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + ChannelInfo _responseData; + + try { + const _responseType = FullType(ChannelInfo); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as ChannelInfo; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Gets Channel Information from username. + /// Gets all available Channel information about a channel. + /// + /// Parameters: + /// * [username] - The username of the YouTube channel you want to get information about. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [ChannelInfo] as data + /// Throws [DioError] if API call or serialization fails + Future> channelInfoUsername({ + required String username, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/user/{username}'.replaceAll('{' r'username' '}', username.toString()); + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _response = await _dio.request( + _path, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + ChannelInfo _responseData; + + try { + const _responseType = FullType(ChannelInfo); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as ChannelInfo; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Gets more channel videos + /// Gets more channel videos. + /// + /// Parameters: + /// * [channelId] - The channel ID of the YouTube channel you want to get more videos from. + /// * [nextpage] - The next page token to get more videos from. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [StreamsPage] as data + /// Throws [DioError] if API call or serialization fails + Future> channelNextPage({ + required String channelId, + required String nextpage, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/nextpage/channel/{channelId}'.replaceAll('{' r'channelId' '}', channelId.toString()); + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _queryParameters = { + r'nextpage': encodeQueryParameter(_serializers, nextpage, const FullType(String)), + }; + + final _response = await _dio.request( + _path, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + StreamsPage _responseData; + + try { + const _responseType = FullType(StreamsPage); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as StreamsPage; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + +} diff --git a/lib/src/api/feed_api.dart b/lib/src/api/feed_api.dart new file mode 100644 index 0000000..14026ad --- /dev/null +++ b/lib/src/api/feed_api.dart @@ -0,0 +1,102 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'dart:async'; + +import 'package:built_value/serializer.dart'; +import 'package:dio/dio.dart'; + +import 'package:built_collection/built_collection.dart'; +import 'package:piped_api/src/api_util.dart'; +import 'package:piped_api/src/model/exception_error.dart'; +import 'package:piped_api/src/model/stream_item.dart'; + +class FeedApi { + + final Dio _dio; + + final Serializers _serializers; + + const FeedApi(this._dio, this._serializers); + + /// Generate a feed while unauthenticated, from a list of channelIds. + /// Generates a user feed while unauthenticated. + /// + /// Parameters: + /// * [channels] - A list of channelIds to generate a feed from. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [BuiltList] as data + /// Throws [DioError] if API call or serialization fails + Future>> feedUnauthenticated({ + required BuiltList channels, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/feed/unauthenticated'; + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _queryParameters = { + r'channels': encodeCollectionQueryParameter(_serializers, channels, const FullType(BuiltList, [FullType(String)]), format: ListFormat.csv,), + }; + + final _response = await _dio.request( + _path, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + BuiltList _responseData; + + try { + const _responseType = FullType(BuiltList, [FullType(StreamItem)]); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as BuiltList; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response>( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + +} diff --git a/lib/src/api/search_api.dart b/lib/src/api/search_api.dart new file mode 100644 index 0000000..1a69e83 --- /dev/null +++ b/lib/src/api/search_api.dart @@ -0,0 +1,190 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'dart:async'; + +import 'package:built_value/serializer.dart'; +import 'package:dio/dio.dart'; + +import 'package:piped_api/src/api_util.dart'; +import 'package:piped_api/src/model/exception_error.dart'; +import 'package:piped_api/src/model/search_filter.dart'; +import 'package:piped_api/src/model/search_page.dart'; + +class SearchApi { + + final Dio _dio; + + final Serializers _serializers; + + const SearchApi(this._dio, this._serializers); + + /// Searches for videos, channels, and playlists. + /// Searches for videos, channels, and playlists. + /// + /// Parameters: + /// * [q] - The search query string. + /// * [filter] - The filter parameter specifies a filter query that restricts the results to items that match the filter. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [SearchPage] as data + /// Throws [DioError] if API call or serialization fails + Future> search({ + required String q, + required SearchFilter filter, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/search'; + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _queryParameters = { + r'q': encodeQueryParameter(_serializers, q, const FullType(String)), + r'filter': encodeQueryParameter(_serializers, filter, const FullType(SearchFilter)), + }; + + final _response = await _dio.request( + _path, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + SearchPage _responseData; + + try { + const _responseType = FullType(SearchPage); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as SearchPage; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Gets more search results + /// Gets more search results. + /// + /// Parameters: + /// * [nextpage] - The next page token to get more search results from. + /// * [q] - The search query string. + /// * [filter] - The filter parameter specifies a filter query that restricts the results to items that match the filter. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [SearchPage] as data + /// Throws [DioError] if API call or serialization fails + Future> searchNextPage({ + required String nextpage, + required String q, + required SearchFilter filter, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/nextpage/search'; + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _queryParameters = { + r'nextpage': encodeQueryParameter(_serializers, nextpage, const FullType(String)), + r'q': encodeQueryParameter(_serializers, q, const FullType(String)), + r'filter': encodeQueryParameter(_serializers, filter, const FullType(SearchFilter)), + }; + + final _response = await _dio.request( + _path, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + SearchPage _responseData; + + try { + const _responseType = FullType(SearchPage); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as SearchPage; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + +} diff --git a/lib/src/api/unauthenticated_api.dart b/lib/src/api/unauthenticated_api.dart index 1c865c6..1cb0a09 100644 --- a/lib/src/api/unauthenticated_api.dart +++ b/lib/src/api/unauthenticated_api.dart @@ -27,7 +27,7 @@ class UnauthenticatedApi { const UnauthenticatedApi(this._dio, this._serializers); - /// Gets Channel Information + /// Gets Channel Information from ID. /// Gets all available Channel information about a channel. /// /// Parameters: @@ -101,7 +101,7 @@ class UnauthenticatedApi { ); } - /// Gets Channel Information + /// Gets Channel Information from name. /// Gets all available Channel information about a channel. /// /// Parameters: @@ -175,7 +175,7 @@ class UnauthenticatedApi { ); } - /// Gets Channel Information + /// Gets Channel Information from username. /// Gets all available Channel information about a channel. /// /// Parameters: @@ -485,6 +485,85 @@ class UnauthenticatedApi { ); } + /// Generate a feed while unauthenticated, from a list of channelIds. + /// Generates a user feed while unauthenticated. + /// + /// Parameters: + /// * [channels] - A list of channelIds to generate a feed from. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [BuiltList] as data + /// Throws [DioError] if API call or serialization fails + Future>> feedUnauthenticated({ + required BuiltList channels, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/feed/unauthenticated'; + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _queryParameters = { + r'channels': encodeCollectionQueryParameter(_serializers, channels, const FullType(BuiltList, [FullType(String)]), format: ListFormat.csv,), + }; + + final _response = await _dio.request( + _path, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + BuiltList _responseData; + + try { + const _responseType = FullType(BuiltList, [FullType(StreamItem)]); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as BuiltList; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response>( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + /// Searches for videos, channels, and playlists. /// Searches for videos, channels, and playlists. /// diff --git a/lib/src/api/video_api.dart b/lib/src/api/video_api.dart new file mode 100644 index 0000000..ab67015 --- /dev/null +++ b/lib/src/api/video_api.dart @@ -0,0 +1,252 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'dart:async'; + +import 'package:built_value/serializer.dart'; +import 'package:dio/dio.dart'; + +import 'package:piped_api/src/api_util.dart'; +import 'package:piped_api/src/model/comments_page.dart'; +import 'package:piped_api/src/model/exception_error.dart'; +import 'package:piped_api/src/model/video_info.dart'; + +class VideoApi { + + final Dio _dio; + + final Serializers _serializers; + + const VideoApi(this._dio, this._serializers); + + /// Gets Comments + /// Gets the comments for a video. + /// + /// Parameters: + /// * [videoId] - The video ID of the YouTube video you want to get comments from. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [CommentsPage] as data + /// Throws [DioError] if API call or serialization fails + Future> comments({ + required String videoId, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/comments/{videoId}'.replaceAll('{' r'videoId' '}', videoId.toString()); + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _response = await _dio.request( + _path, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + CommentsPage _responseData; + + try { + const _responseType = FullType(CommentsPage); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as CommentsPage; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Gets more comments + /// Gets more comments. + /// + /// Parameters: + /// * [videoId] - The video ID of the YouTube video you want to get more comments from. + /// * [nextpage] - The next page token to get more comments from. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [CommentsPage] as data + /// Throws [DioError] if API call or serialization fails + Future> commentsNextPage({ + required String videoId, + required String nextpage, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/nextpage/comments/{videoId}'.replaceAll('{' r'videoId' '}', videoId.toString()); + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _queryParameters = { + r'nextpage': encodeQueryParameter(_serializers, nextpage, const FullType(String)), + }; + + final _response = await _dio.request( + _path, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + CommentsPage _responseData; + + try { + const _responseType = FullType(CommentsPage); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as CommentsPage; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Gets Video Information + /// Gets all available Stream information about a video. + /// + /// Parameters: + /// * [videoId] - The video ID of the YouTube video you want to get information about. + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [VideoInfo] as data + /// Throws [DioError] if API call or serialization fails + Future> streamInfo({ + required String videoId, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/streams/{videoId}'.replaceAll('{' r'videoId' '}', videoId.toString()); + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _response = await _dio.request( + _path, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + VideoInfo _responseData; + + try { + const _responseType = FullType(VideoInfo); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as VideoInfo; + + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.other, + error: error, + )..stackTrace = stackTrace; + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + +} diff --git a/lib/src/model/comment.dart b/lib/src/model/comment.dart index cd082e1..21f6fc4 100644 --- a/lib/src/model/comment.dart +++ b/lib/src/model/comment.dart @@ -19,6 +19,7 @@ part 'comment.g.dart'; /// * [commentorUrl] - The relative URL of the author of the comment. /// * [repliesPage] - The parameter used as the nextpage to fetch replies for this comment. /// * [likeCount] - The number of likes the comment has. +/// * [replyCount] - The number of replies the comment has. /// * [hearted] - Whether the comment was hearted by the video's uploader. /// * [pinned] - Whether the comment was pinned by the video's uploader. /// * [verified] - Whether the author of the comment is verified. @@ -56,6 +57,10 @@ abstract class Comment implements Built { @BuiltValueField(wireName: r'likeCount') int? get likeCount; + /// The number of replies the comment has. + @BuiltValueField(wireName: r'replyCount') + int? get replyCount; + /// Whether the comment was hearted by the video's uploader. @BuiltValueField(wireName: r'hearted') bool? get hearted; @@ -147,6 +152,13 @@ class _$CommentSerializer implements PrimitiveSerializer { specifiedType: const FullType(int), ); } + if (object.replyCount != null) { + yield r'replyCount'; + yield serializers.serialize( + object.replyCount, + specifiedType: const FullType(int), + ); + } if (object.hearted != null) { yield r'hearted'; yield serializers.serialize( @@ -247,6 +259,13 @@ class _$CommentSerializer implements PrimitiveSerializer { ) as int; result.likeCount = valueDes; break; + case r'replyCount': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(int), + ) as int; + result.replyCount = valueDes; + break; case r'hearted': final valueDes = serializers.deserialize( value, diff --git a/lib/src/model/comment.g.dart b/lib/src/model/comment.g.dart index bd5b8c5..d47a6e8 100644 --- a/lib/src/model/comment.g.dart +++ b/lib/src/model/comment.g.dart @@ -24,6 +24,8 @@ class _$Comment extends Comment { @override final int? likeCount; @override + final int? replyCount; + @override final bool? hearted; @override final bool? pinned; @@ -42,6 +44,7 @@ class _$Comment extends Comment { this.commentorUrl, this.repliesPage, this.likeCount, + this.replyCount, this.hearted, this.pinned, this.verified}) @@ -66,6 +69,7 @@ class _$Comment extends Comment { commentorUrl == other.commentorUrl && repliesPage == other.repliesPage && likeCount == other.likeCount && + replyCount == other.replyCount && hearted == other.hearted && pinned == other.pinned && verified == other.verified; @@ -82,14 +86,16 @@ class _$Comment extends Comment { $jc( $jc( $jc( - $jc($jc(0, author.hashCode), - thumbnail.hashCode), - commentId.hashCode), - commentText.hashCode), - commentedTime.hashCode), - commentorUrl.hashCode), - repliesPage.hashCode), - likeCount.hashCode), + $jc( + $jc($jc(0, author.hashCode), + thumbnail.hashCode), + commentId.hashCode), + commentText.hashCode), + commentedTime.hashCode), + commentorUrl.hashCode), + repliesPage.hashCode), + likeCount.hashCode), + replyCount.hashCode), hearted.hashCode), pinned.hashCode), verified.hashCode)); @@ -106,6 +112,7 @@ class _$Comment extends Comment { ..add('commentorUrl', commentorUrl) ..add('repliesPage', repliesPage) ..add('likeCount', likeCount) + ..add('replyCount', replyCount) ..add('hearted', hearted) ..add('pinned', pinned) ..add('verified', verified)) @@ -149,6 +156,10 @@ class CommentBuilder implements Builder { int? get likeCount => _$this._likeCount; set likeCount(int? likeCount) => _$this._likeCount = likeCount; + int? _replyCount; + int? get replyCount => _$this._replyCount; + set replyCount(int? replyCount) => _$this._replyCount = replyCount; + bool? _hearted; bool? get hearted => _$this._hearted; set hearted(bool? hearted) => _$this._hearted = hearted; @@ -176,6 +187,7 @@ class CommentBuilder implements Builder { _commentorUrl = $v.commentorUrl; _repliesPage = $v.repliesPage; _likeCount = $v.likeCount; + _replyCount = $v.replyCount; _hearted = $v.hearted; _pinned = $v.pinned; _verified = $v.verified; @@ -209,6 +221,7 @@ class CommentBuilder implements Builder { commentorUrl: commentorUrl, repliesPage: repliesPage, likeCount: likeCount, + replyCount: replyCount, hearted: hearted, pinned: pinned, verified: verified); diff --git a/lib/src/serializers.dart b/lib/src/serializers.dart index f7b2e8b..2407cd5 100644 --- a/lib/src/serializers.dart +++ b/lib/src/serializers.dart @@ -50,6 +50,10 @@ part 'serializers.g.dart'; VideoInfo, ]) Serializers serializers = (_$serializers.toBuilder() + ..addBuilderFactory( + const FullType(BuiltList, [FullType(String)]), + () => ListBuilder(), + ) ..addBuilderFactory( const FullType(BuiltList, [FullType(StreamItem)]), () => ListBuilder(), diff --git a/test/channel_api_test.dart b/test/channel_api_test.dart new file mode 100644 index 0000000..df34d06 --- /dev/null +++ b/test/channel_api_test.dart @@ -0,0 +1,47 @@ +import 'package:test/test.dart'; +import 'package:piped_api/piped_api.dart'; + + +/// tests for ChannelApi +void main() { + final instance = PipedApi().getChannelApi(); + + group(ChannelApi, () { + // Gets Channel Information from ID. + // + // Gets all available Channel information about a channel. + // + //Future channelInfoId(String channelId) async + test('test channelInfoId', () async { + // TODO + }); + + // Gets Channel Information from name. + // + // Gets all available Channel information about a channel. + // + //Future channelInfoName(String name) async + test('test channelInfoName', () async { + // TODO + }); + + // Gets Channel Information from username. + // + // Gets all available Channel information about a channel. + // + //Future channelInfoUsername(String username) async + test('test channelInfoUsername', () async { + // TODO + }); + + // Gets more channel videos + // + // Gets more channel videos. + // + //Future channelNextPage(String channelId, String nextpage) async + test('test channelNextPage', () async { + // TODO + }); + + }); +} diff --git a/test/feed_api_test.dart b/test/feed_api_test.dart new file mode 100644 index 0000000..c3add50 --- /dev/null +++ b/test/feed_api_test.dart @@ -0,0 +1,20 @@ +import 'package:test/test.dart'; +import 'package:piped_api/piped_api.dart'; + + +/// tests for FeedApi +void main() { + final instance = PipedApi().getFeedApi(); + + group(FeedApi, () { + // Generate a feed while unauthenticated, from a list of channelIds. + // + // Generates a user feed while unauthenticated. + // + //Future> feedUnauthenticated(BuiltList channels) async + test('test feedUnauthenticated', () async { + // TODO + }); + + }); +} diff --git a/test/search_api_test.dart b/test/search_api_test.dart new file mode 100644 index 0000000..d63e04e --- /dev/null +++ b/test/search_api_test.dart @@ -0,0 +1,29 @@ +import 'package:test/test.dart'; +import 'package:piped_api/piped_api.dart'; + + +/// tests for SearchApi +void main() { + final instance = PipedApi().getSearchApi(); + + group(SearchApi, () { + // Searches for videos, channels, and playlists. + // + // Searches for videos, channels, and playlists. + // + //Future search(String q, SearchFilter filter) async + test('test search', () async { + // TODO + }); + + // Gets more search results + // + // Gets more search results. + // + //Future searchNextPage(String nextpage, String q, SearchFilter filter) async + test('test searchNextPage', () async { + // TODO + }); + + }); +} diff --git a/test/video_api_test.dart b/test/video_api_test.dart new file mode 100644 index 0000000..53ed512 --- /dev/null +++ b/test/video_api_test.dart @@ -0,0 +1,38 @@ +import 'package:test/test.dart'; +import 'package:piped_api/piped_api.dart'; + + +/// tests for VideoApi +void main() { + final instance = PipedApi().getVideoApi(); + + group(VideoApi, () { + // Gets Comments + // + // Gets the comments for a video. + // + //Future comments(String videoId) async + test('test comments', () async { + // TODO + }); + + // Gets more comments + // + // Gets more comments. + // + //Future commentsNextPage(String videoId, String nextpage) async + test('test commentsNextPage', () async { + // TODO + }); + + // Gets Video Information + // + // Gets all available Stream information about a video. + // + //Future streamInfo(String videoId) async + test('test streamInfo', () async { + // TODO + }); + + }); +}