Code Monkey home page Code Monkey logo

python-crunchyroll's Introduction

python-crunchyroll

Python interface to Crunchyroll's undocumented APIs and utilities for working with the returned data. Eventual plan is to create a better XMBC plugin.

Requirements

  • Python 2.6+
  • requests
  • PyCrypto
  • tlslite version 0.4.3 (pip install tlslite===0.4.3)

Usage

Pretty much anything of interest is available now, including the RTMPE stream data and decrypted and formatted subtitles.

Example usage:

>>> from crunchyroll.apis.meta import MetaApi
>>> api = MetaApi()
>>> pprint([s.name for s in api.list_anime_series(limit=5)])
[u'07 Ghost',
 u'11eyes',
 u'A Bridge to the Starry Skies - Hoshizora e Kakaru Hashi',
 u'A Dark Rabbit has Seven Lives',
 u'Abunai Sisters']
>>> space_brothers = api.search_anime_series('Space Brothers')[0]
>>> pprint(space_brothers.description)
u'To follow his brother Hibito to the moon, Mutta will attempt to become an
astronaut at the age of 32.  Unaware of his own talent, Mutta chases his
dreams to get back in front of his younger brother.'
>>> sb_episodes = api.list_media(space_brothers)
>>> len(sb_episodes)
49
>>> ep = [e for e in sb_episodes if e.episode_number == '40'][0]
>>> print ep.episode_number, ep.name, ep.free_available
40 Heaven and Hell True
>>> api.login(username=username, password=password)
True
>>> stream = api.get_media_stream(ep)
>>> subs = stream.default_subtitles.decrypt().get_ass_formatted()
>>> print '\n'.join(subs.split('\n')[:9])
[Script Info]
Title: English (US)
ScriptType: v4.00+
WrapStyle: 0
PlayRexX: 704
PlayResY: 400
Subtitle ID: XXXXX
Language: English (US)
Created: 28 days ago
>>> [s.language for s in stream.subtitle_stubs]
['English (US)', u'Espa\xf1ol', u'Fran\xe7ais (France)', u'Portugu\xeas (Brasil)']
>>> fr_subs = api.unfold_subtitle_stub(stream.subtitle_stubs[2]).decrypt().get_srt_formatted()
>>> print '\n'.join(fr_subs.split('\n')[:11])
1
00:00:00,760 --> 00:00:02,940
Tiens ? Ça ne s'ouvre pas.

2
00:00:04,500 --> 00:00:06,770
Tourne le levier vers la gauche.

3
00:00:07,360 --> 00:00:10,150
Lequel ?

TODO

  • Add a way to get the URL to the latest version of the player SWF
  • Add logging via logging module
  • Add unit tests

LICENSE

This project is licensed under GPLv2+, see LICENSE for more details.

python-crunchyroll's People

Contributors

aheadley avatar jsonn avatar

Watchers

Darius Kazemi avatar James Cloos avatar  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.