2022-02-03 17:23:29 +01:00
|
|
|
package anilist
|
|
|
|
|
2022-02-06 10:39:04 +01:00
|
|
|
import "context"
|
|
|
|
|
2022-02-24 21:15:14 +01:00
|
|
|
func (api *Api) GetMedia(ctx context.Context, vars MediaQuery, onError func(error)) *Cursor[Media] {
|
2022-02-03 17:23:29 +01:00
|
|
|
resp := responseObj[*page[Media]]{}
|
2022-02-06 10:39:04 +01:00
|
|
|
return requestPaged(api, ctx, getMediaQuery, vars.toMap(), &resp, onError)
|
2022-02-03 17:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
getMediaQuery = `query (
|
|
|
|
$id: Int,
|
|
|
|
$startDate: FuzzyDateInt,
|
|
|
|
$endDate: FuzzyDateInt,
|
|
|
|
$season: MediaSeason,
|
|
|
|
$seasonYear: Int,
|
|
|
|
$type: MediaType,
|
|
|
|
$format: MediaFormat,
|
|
|
|
$status: MediaStatus,
|
|
|
|
$episodes: Int,
|
|
|
|
$duration: Int,
|
|
|
|
$chapters: Int,
|
|
|
|
$volumes: Int,
|
|
|
|
$isAdult: Boolean,
|
|
|
|
$genre: String,
|
|
|
|
$tag: String,
|
|
|
|
$source: MediaSource,
|
|
|
|
$search: String,
|
|
|
|
$id_in: [Int],
|
|
|
|
$id_not_in: [Int],
|
|
|
|
$startDate_greater: FuzzyDateInt,
|
|
|
|
$startDate_lesser: FuzzyDateInt,
|
|
|
|
$endDate_greater: FuzzyDateInt,
|
|
|
|
$endDate_lesser: FuzzyDateInt,
|
|
|
|
$format_in: [MediaFormat],
|
|
|
|
$format_not_in: [MediaFormat],
|
|
|
|
$status_in: [MediaStatus],
|
|
|
|
$status_not_in: [MediaStatus],
|
|
|
|
$episodes_greater: Int,
|
|
|
|
$episodes_lesser: Int,
|
|
|
|
$duration_greater: Int,
|
|
|
|
$duration_lesser: Int,
|
|
|
|
$volumes_greater: Int,
|
|
|
|
$volumes_lesser: Int,
|
|
|
|
$genre_in: [String],
|
|
|
|
$genre_not_in: [String],
|
|
|
|
$tag_in: [String],
|
|
|
|
$tag_not_in: [String],
|
|
|
|
$source_in: [MediaSource],
|
|
|
|
$sort:[MediaSort],
|
|
|
|
$page: Int
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
Page (page: $page) {
|
|
|
|
pageInfo ` + subSelectionPageInfo + `
|
|
|
|
media (
|
|
|
|
id: $id,
|
|
|
|
startDate: $startDate,
|
|
|
|
endDate: $endDate,
|
|
|
|
season: $season,
|
|
|
|
seasonYear: $seasonYear,
|
|
|
|
type: $type,
|
|
|
|
format: $format,
|
|
|
|
status: $status,
|
|
|
|
episodes: $episodes,
|
|
|
|
duration: $duration,
|
|
|
|
chapters: $chapters,
|
|
|
|
volumes: $volumes,
|
|
|
|
isAdult: $isAdult,
|
|
|
|
genre: $genre,
|
|
|
|
tag: $tag,
|
|
|
|
source: $source,
|
|
|
|
search: $search,
|
|
|
|
id_in: $id_in,
|
|
|
|
id_not_in: $id_not_in,
|
|
|
|
startDate_greater: $startDate_greater,
|
|
|
|
startDate_lesser: $startDate_lesser,
|
|
|
|
endDate_greater: $endDate_greater,
|
|
|
|
endDate_lesser: $endDate_lesser,
|
|
|
|
format_in: $format_in,
|
|
|
|
format_not_in: $format_not_in,
|
|
|
|
status_in: $status_in,
|
|
|
|
status_not_in: $status_not_in,
|
|
|
|
episodes_greater: $episodes_greater,
|
|
|
|
episodes_lesser: $episodes_lesser,
|
|
|
|
duration_greater: $duration_greater,
|
|
|
|
duration_lesser: $duration_lesser,
|
|
|
|
volumes_greater: $volumes_greater,
|
|
|
|
volumes_lesser: $volumes_lesser,
|
|
|
|
genre_in: $genre_in,
|
|
|
|
genre_not_in: $genre_not_in,
|
|
|
|
tag_in: $tag_in,
|
|
|
|
tag_not_in: $tag_not_in,
|
|
|
|
source_in: $source_in,
|
|
|
|
sort: $sort
|
|
|
|
) ` + subSelectionMedia + `
|
|
|
|
}
|
|
|
|
}`
|
|
|
|
)
|