Add replyCount in comments and unauthenticated feed api.

This commit is contained in:
Kavin 2022-10-18 09:39:16 +01:00
parent 7407348212
commit fd20ae95b1
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
22 changed files with 1743 additions and 22 deletions

View File

@ -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

View File

@ -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

191
doc/ChannelApi.md Normal file
View File

@ -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)

View File

@ -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]

57
doc/FeedApi.md Normal file
View File

@ -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<StreamItem> 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<String> channels = ["UCs6KfncB4OV6Vug4o_bzijg","UClcE-kVhqyiHCcjYwcpfj9w"]; // BuiltList<String> | 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&lt;String&gt;**](String.md)| A list of channelIds to generate a feed from. |
### Return type
[**BuiltList&lt;StreamItem&gt;**](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)

107
doc/SearchApi.md Normal file
View File

@ -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)

View File

@ -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<StreamItem> 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<String> channels = ["UCs6KfncB4OV6Vug4o_bzijg","UClcE-kVhqyiHCcjYwcpfj9w"]; // BuiltList<String> | 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&lt;String&gt;**](String.md)| A list of channelIds to generate a feed from. |
### Return type
[**BuiltList&lt;StreamItem&gt;**](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)

147
doc/VideoApi.md Normal file
View File

@ -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)

View File

@ -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';

View File

@ -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);
}
}

View File

@ -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<Response<ChannelInfo>> channelInfoId({
required String channelId,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? 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: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_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<ChannelInfo>(
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<Response<ChannelInfo>> channelInfoName({
required String name,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? 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: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_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<ChannelInfo>(
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<Response<ChannelInfo>> channelInfoUsername({
required String username,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? 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: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_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<ChannelInfo>(
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<Response<StreamsPage>> channelNextPage({
required String channelId,
required String nextpage,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? 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: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
r'nextpage': encodeQueryParameter(_serializers, nextpage, const FullType(String)),
};
final _response = await _dio.request<Object>(
_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<StreamsPage>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
}

102
lib/src/api/feed_api.dart Normal file
View File

@ -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<StreamItem>] as data
/// Throws [DioError] if API call or serialization fails
Future<Response<BuiltList<StreamItem>>> feedUnauthenticated({
required BuiltList<String> channels,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/feed/unauthenticated';
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
r'channels': encodeCollectionQueryParameter<String>(_serializers, channels, const FullType(BuiltList, [FullType(String)]), format: ListFormat.csv,),
};
final _response = await _dio.request<Object>(
_path,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
BuiltList<StreamItem> _responseData;
try {
const _responseType = FullType(BuiltList, [FullType(StreamItem)]);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as BuiltList<StreamItem>;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<BuiltList<StreamItem>>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
}

190
lib/src/api/search_api.dart Normal file
View File

@ -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<Response<SearchPage>> search({
required String q,
required SearchFilter filter,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/search';
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
r'q': encodeQueryParameter(_serializers, q, const FullType(String)),
r'filter': encodeQueryParameter(_serializers, filter, const FullType(SearchFilter)),
};
final _response = await _dio.request<Object>(
_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<SearchPage>(
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<Response<SearchPage>> searchNextPage({
required String nextpage,
required String q,
required SearchFilter filter,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/nextpage/search';
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
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<Object>(
_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<SearchPage>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
}

View File

@ -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<StreamItem>] as data
/// Throws [DioError] if API call or serialization fails
Future<Response<BuiltList<StreamItem>>> feedUnauthenticated({
required BuiltList<String> channels,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/feed/unauthenticated';
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
r'channels': encodeCollectionQueryParameter<String>(_serializers, channels, const FullType(BuiltList, [FullType(String)]), format: ListFormat.csv,),
};
final _response = await _dio.request<Object>(
_path,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
BuiltList<StreamItem> _responseData;
try {
const _responseType = FullType(BuiltList, [FullType(StreamItem)]);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as BuiltList<StreamItem>;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<BuiltList<StreamItem>>(
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.
///

252
lib/src/api/video_api.dart Normal file
View File

@ -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<Response<CommentsPage>> comments({
required String videoId,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? 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: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_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<CommentsPage>(
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<Response<CommentsPage>> commentsNextPage({
required String videoId,
required String nextpage,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? 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: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
r'nextpage': encodeQueryParameter(_serializers, nextpage, const FullType(String)),
};
final _response = await _dio.request<Object>(
_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<CommentsPage>(
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<Response<VideoInfo>> streamInfo({
required String videoId,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? 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: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_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<VideoInfo>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
}

View File

@ -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<Comment, CommentBuilder> {
@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<Comment> {
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<Comment> {
) 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,

View File

@ -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<Comment, CommentBuilder> {
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<Comment, CommentBuilder> {
_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<Comment, CommentBuilder> {
commentorUrl: commentorUrl,
repliesPage: repliesPage,
likeCount: likeCount,
replyCount: replyCount,
hearted: hearted,
pinned: pinned,
verified: verified);

View File

@ -50,6 +50,10 @@ part 'serializers.g.dart';
VideoInfo,
])
Serializers serializers = (_$serializers.toBuilder()
..addBuilderFactory(
const FullType(BuiltList, [FullType(String)]),
() => ListBuilder<String>(),
)
..addBuilderFactory(
const FullType(BuiltList, [FullType(StreamItem)]),
() => ListBuilder<StreamItem>(),

View File

@ -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<ChannelInfo> channelInfoId(String channelId) async
test('test channelInfoId', () async {
// TODO
});
// Gets Channel Information from name.
//
// Gets all available Channel information about a channel.
//
//Future<ChannelInfo> channelInfoName(String name) async
test('test channelInfoName', () async {
// TODO
});
// Gets Channel Information from username.
//
// Gets all available Channel information about a channel.
//
//Future<ChannelInfo> channelInfoUsername(String username) async
test('test channelInfoUsername', () async {
// TODO
});
// Gets more channel videos
//
// Gets more channel videos.
//
//Future<StreamsPage> channelNextPage(String channelId, String nextpage) async
test('test channelNextPage', () async {
// TODO
});
});
}

20
test/feed_api_test.dart Normal file
View File

@ -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<BuiltList<StreamItem>> feedUnauthenticated(BuiltList<String> channels) async
test('test feedUnauthenticated', () async {
// TODO
});
});
}

29
test/search_api_test.dart Normal file
View File

@ -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<SearchPage> search(String q, SearchFilter filter) async
test('test search', () async {
// TODO
});
// Gets more search results
//
// Gets more search results.
//
//Future<SearchPage> searchNextPage(String nextpage, String q, SearchFilter filter) async
test('test searchNextPage', () async {
// TODO
});
});
}

38
test/video_api_test.dart Normal file
View File

@ -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<CommentsPage> comments(String videoId) async
test('test comments', () async {
// TODO
});
// Gets more comments
//
// Gets more comments.
//
//Future<CommentsPage> commentsNextPage(String videoId, String nextpage) async
test('test commentsNextPage', () async {
// TODO
});
// Gets Video Information
//
// Gets all available Stream information about a video.
//
//Future<VideoInfo> streamInfo(String videoId) async
test('test streamInfo', () async {
// TODO
});
});
}