GithubHelp home page GithubHelp logo

gitenxx / spice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from utagai/spice

1.0 2.0 0.0 1.26 MB

spice is a pure Python API that wraps around MAL's Official API and makes it much, much better.

License: MIT License

Python 100.00%

spice's Introduction

An Introduction

The Official MyAnimeList API needs lots of work and is pretty annoying to use. Here are some of the many issues:

  • Some of the documentation is just straight up incorrect (perhaps it was correct sometime ago).
  • There are MySQL bugs on MAL's end that must be circumvented.
  • There are severe limitations in what the API allows you to do, forcing the programmer's hand to write ugly scraping code.
  • Some of the ways to do simple things like updating an anime on a user's list requires an esoteric knowledge of MAL URLs/queries that are no where on the documentation.
  • The Official MAL API fails to provide consistent behavior.
    • e.g. When sending too many requests, the Official MAL API has unpredictable behavior.

Work and/or further development on it seems like a lost cause, since the developer(s) have far more pressing concerns with the site.

This API aims to provide an easy to use Python API that wraps around MAL's REST-API so that you don't have to experience any headaches.

Name inspired by Horo/Holo from Spice and Wolf.

API inspired by other attempts (which made their own REST API wrapper, while this one uses a pure Python implementation), such as crobert22's Railgun and chuyeow's myanimelist-api.

Install

$ pip install spice_api

Here's How to Use It

import spice_api as spice

def main():
	creds = spice.load_auth_from_file('auth') #or spice.init_auth(username, pw)
	search_results = spice.search('Spice and Wolf', spice.get_medium('anime'), creds)
	print(results[0].title) # > Ookami to Koushinryou
	saw_id = results[0].id # > 2966
	
	#mal sees everything as anime or manga, so novels are considered manga.
	saw_novel = spice.search_id(saw_id, spice.get_medium('manga'), creds)
	print(saw_novel.title) # > Ookami to Koushinryou
	print(saw_novel.chapters) # > 0
	print(saw_novel.volumes) # > 18
	
	#get a fresh anime data object to fill in, and then push to your list
	saw_data = spice.get_blank(spice.get_medium('anime'))
	saw_data.episodes = 10 #you've watched 10 eps
	saw_data.status = spice.get_status('watching') #you're still watching
	saw_data.score = 9 #your rating
	saw_data.tags = ['Holo is the best.'] #tags
	#there are many other fields you can fill in, but this is enough.
	spice.update(saw_data, saw_id, spice.get_medium('anime'), creds) #update your list.

	your_list = spice.get_list(spice.get_medium('anime'), creds) #get your list (no args)
	other_anime_list = spice.get_list(spice.get_medium('anime'), 'Pickleplatter', creds) #someone else's list
	
	print(your_list.avg_score()) # > mean 
	print(your_list.p_var()) # > variance
	# there are A LOT more methods for analyzing lists. Check them out in the source code in objects.py!
	print(your_list.get_num_status(spice.get_status_num('watching'))) #number of shows you're watching
	print(your_list.compatibility(other_anime_list)) # > you and your friend's compatibility score

What's Left

  • Add more information to Anime() and Manga() objects through webscraping.
  • Add more list comparison methods.
  • Make some documentation for christ's sake.
  • Make README even more pretty.

spice's People

Contributors

utagai avatar getrektbyme avatar

Stargazers

Albegov Mihail avatar

Watchers

James Cloos avatar negative_agetator avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.