This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sakiut
committed
May 18, 2017
1 parent
ef10538
commit 3ad3ec3
Showing
1 changed file
with
99 additions
and
0 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
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 | ||
|
||
##################################################################################################################################################### |