-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
82 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const Fetch = require('./fetcher'); | ||
|
||
module.exports = { | ||
variables: function(user, type) { | ||
if (type === 'ANIME' || type === 'MANGA') { | ||
if (typeof user === 'string') { return [{ name: user, type: type }, `query ($name: String, $type: MediaType) { MediaListCollection(userName: $name, type: $type) { `]; } | ||
else if (typeof user === 'number') { return [{ id: user, type: type }, `query ($id: Int, $type: MediaType) { MediaListCollection(userId: $id,, type: $type) { `]; } | ||
} | ||
}, | ||
anime: function(user) { | ||
if (!user) { throw new Error("AniList username or id is missing!"); } | ||
var start = this.variables(user, 'ANIME'); | ||
var query = start[1] + `lists { name isCustomList isSplitCompletedList status entries { media { | ||
id idMal title { romaji english native userPreferred } | ||
type episodes description format status startDate { year month day } endDate { year month day } | ||
season duration countryOfOrigin isLicensed source hashtag trailer { id site } | ||
updatedAt coverImage { large medium } bannerImage genres synonyms averageScore meanScore | ||
popularity trending tags { name isMediaSpoiler } relations { edges { id } } characters { edges { id } } | ||
staff { edges { id } } studios { edges { id } } isFavourite isAdult nextAiringEpisode { id } airingSchedule { edges { id } } | ||
trends { edges { node { averageScore popularity inProgress episode } } } externalLinks { url } | ||
streamingEpisodes { title thumbnail url site } rankings { id } mediaListEntry { id } | ||
reviews { edges { node { id summary } } } siteUrl autoCreateForumThread modNotes } } } } }`; | ||
return Fetch.send(query, start[0]); | ||
}, | ||
manga: function(user) { | ||
if (!user) { throw new Error("AniList username or id is missing!"); } | ||
var start = this.variables(user, 'MANGA'); | ||
var query = start[1] + `lists { name isCustomList isSplitCompletedList status entries { media { | ||
id idMal title { romaji english native userPreferred } | ||
type description format status startDate { year month day } endDate { year month day } volumes countryOfOrigin isLicensed updatedAt | ||
coverImage { large medium } bannerImage genres synonyms averageScore meanScore siteUrl autoCreateForumThread modNotes | ||
popularity trending tags { name isMediaSpoiler } relations { edges { id } } characters { edges { id } } staff { edges { id } } | ||
isFavourite isAdult trends { edges { node { averageScore popularity inProgress episode } } } | ||
externalLinks { url } rankings { id } mediaListEntry { id } reviews { edges { node { id } } } } } } } }`; | ||
return Fetch.send(query, start[0]); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const anilist = require('../index'); | ||
const AniList = new anilist(); | ||
|
||
AniList.lists.anime('salixor') | ||
.then(data => { console.log(data.filter(l => l.status === 'CURRENT')); }); | ||
AniList.lists.manga('salixor') | ||
.then(data => { console.log(data.filter(l => l.status === 'CURRENT')); }); |