@ -4,8 +4,12 @@ from modules.util import Failed
logger = util . logger
builders = [ " anilist_id " , " anilist_popular " , " anilist_trending " , " anilist_relations " , " anilist_studio " , " anilist_top_rated " , " anilist_search " ]
pretty_names = { " score " : " Average Score " , " popular " : " Popularity " , " trending " : " Trending " }
builders = [ " anilist_id " , " anilist_popular " , " anilist_trending " , " anilist_relations " , " anilist_studio " , " anilist_top_rated " , " anilist_search " , " anilist_userlist " ]
pretty_names = {
" score " : " Average Score " , " popular " : " Popularity " , " trending " : " Trending " , " CURRENT " : " Currently Watching " ,
" COMPLETED " : " Completed " , " PAUSED " : " Paused " , " DROPPED " : " Dropped " , " PLANNING " : " Planning " , " SCORE " : " Score " ,
" UPDATED_TIME " : " Updated Time " , " STARTED_ON " : " Start Date " , " MEDIA_TITLE_NATIVE " : " Title "
}
attr_translation = {
" year " : " seasonYear " , " adult " : " isAdult " , " start " : " startDate " , " end " : " endDate " , " tag_category " : " tagCategory " ,
" score " : " averageScore " , " min_tag_percent " : " minimumTagRank " , " country " : " countryOfOrigin " ,
@ -20,6 +24,17 @@ mod_searches = [
no_mod_searches = [ " search " , " season " , " year " , " adult " , " min_tag_percent " , " limit " , " sort_by " , " source " , " country " ]
searches = mod_searches + no_mod_searches
sort_options = { " score " : " SCORE_DESC " , " popular " : " POPULARITY_DESC " , " trending " : " TRENDING_DESC " }
userlist_sort_options = [ " score " , " last_updated " , " title " , " start_date " ]
userlist_sort_translation = {
" score " : " SCORE " , " last_updated " : " UPDATED_TIME " ,
" title " : " MEDIA_TITLE_NATIVE " , " start_date " : " STARTED_ON "
}
userlist_status = [ " watching " , " completed " , " paused " , " dropped " , " planning " ]
userlist_status_translation = {
" watching " : " CURRENT " , " completed " : " COMPLETED " ,
" paused " : " PAUSED " , " dropped " : " DROPPED " ,
" planning " : " PLANNING "
}
media_season = { " winter " : " WINTER " , " spring " : " SPRING " , " summer " : " SUMMER " , " fall " : " FALL " }
media_format = { " tv " : " TV " , " short " : " TV_SHORT " , " movie " : " MOVIE " , " special " : " SPECIAL " , " ova " : " OVA " , " ona " : " ONA " , " music " : " MUSIC " }
media_status = { " finished " : " FINISHED " , " airing " : " RELEASING " , " not_yet_aired " : " NOT_YET_RELEASED " , " cancelled " : " CANCELLED " , " hiatus " : " HIATUS " }
@ -210,6 +225,17 @@ class AniList:
return anilist_ids , ignore_ids , name
def _userlist ( self , username , status , sort_by ) :
query = " query ($userName: String, $status: MediaListStatus) { MediaListCollection (userName: $userName, status: $status, type: ANIME) { lists { status entries { media { id title { romaji english}}}}}} "
variables = { " userName " : username , " status " : status , " sort " : sort_by }
json_obj = self . _request ( query , variables )
lists = json_obj [ ' data ' ] [ ' MediaListCollection ' ] [ ' lists ' ]
anilist_ids = [ ]
for list in lists :
for media in list [ ' entries ' ] :
anilist_ids . append ( media [ ' media ' ] [ ' id ' ] )
return anilist_ids
def validate ( self , name , data ) :
valid = [ ]
for d in util . get_list ( data ) :
@ -243,6 +269,9 @@ class AniList:
elif method == " anilist_relations " :
anilist_ids , _ , name = self . _relations ( data )
logger . info ( f " Processing AniList Relations: ( { data } ) { name } ( { len ( anilist_ids ) } Anime) " )
elif method == " anilist_userlist " :
anilist_ids = self . _userlist ( data [ " username " ] , data [ " status " ] , data [ ' sort_by ' ] )
logger . info ( f " Processing AniList Userlist: Anime from { data [ ' username ' ] } ' s { pretty_names [ data [ ' status ' ] ] } list sorted by { pretty_names [ data [ ' sort_by ' ] ] } " )
else :
if method == " anilist_popular " :
data = { " limit " : data , " popularity.gt " : 3 , " sort_by " : " popular " }