Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Added anilist.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakiut committed May 18, 2017
1 parent ef10538 commit 3ad3ec3
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions libraries/anilist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# -*- coding: utf-8 -*-

import requests
from random import shuffle
import time
from decimal import *
import sys
import datetime

from libraries.perms import *
from libraries.library import *

from urllib import request
import linecache
import ast

#####################################################################################################################################################

def auth(params):
q = requests.post('https://anilist.co/api/auth/access_token', params=params)
auth = q.json()
token = auth['access_token']

return token

#####################################################################################################################################################

def getAnimeInfo(anime, token):
anime = str(anime)
q = requests.get('https://anilist.co/api/anime/search/{0}'.format(anime), params={'access_token':token})
data = q.json()
data = filter(lambda x: x.get("title_english") == anime, data)
data = list(data)
data = data[0]

return data

#####################################################################################################################################################

def getAnimeGenres(data):
List = data['genres']
genres = ""

for genre in List:
genres += genre + ", "

genres = genres.rstrip(', ')

return genres

#####################################################################################################################################################

def formatAnimeDescription(data):
desc = data['description']
desc = desc.replace("<br>", "")
return desc

#####################################################################################################################################################

def formatAnimeDate(data):

Message = ""
date = data['start_date']

date = str(date)
split1 = date.split("T")
date = split1[0]
split2 = date.split("-")
date = "{0}/{1}/{2}".format(split2[2], split2[1], split2[0])

Message += "Started : " + date
date = data['end_date']

if date == None :
return Message
else:
date = str(date)
split1 = date.split("T")
date = split1[0]
split2 = date.split("-")
date = "{0}/{1}/{2}".format(split2[2], split2[1], split2[0])

Message += " | Finished : " + date

return Message

#####################################################################################################################################################

def getMangaInfo(manga, token):
manga = str(manga)
q = requests.get('https://anilist.co/api/manga/search/{0}'.format(manga), params={'access_token':token})
data = q.json()
data = filter(lambda x: x.get('type') == 'Manga', data)
data = list(data)
data = data[0]

return data

#####################################################################################################################################################

0 comments on commit 3ad3ec3

Please sign in to comment.