Git Product home page Git Product logo

zencoder-py's Introduction

Zencoder

Build Status

A Python module for interacting with the Zencoder API.

Getting Started

Install from PyPI

$ pip install zencoder

Import zencoder

from zencoder import Zencoder

Create an instance of the Zencoder client. This will accept an API key and version. If not API key is set, it will look for a ZENCODER_API_KEY environment variable. API version defaults to 'v2'.

# If you want to specify an API key when creating a client
client = Zencoder('API_KEY')

# If you have the environment variable set
client = Zencoder()

Create a new job.

client.job.create('s3://bucket/key.mp4')
client.job.create('s3://bucket/key.mp4',
               outputs=[{'label': 'vp8 for the web',
                         'url': 's3://bucket/key_output.webm'}])

This returns a zencoder.Response object. The body includes a Job ID, and one or more Output IDs (one for every output file created).

response = client.job.create('s3://bucket/key.mp4')
response.code           # 201
response.body['id']     # 12345

List jobs.

By default the jobs listing is paginated with 50 jobs per page and sorted by ID in descending order. You can pass two parameters to control the paging: page and per_page.

client.job.list(per_page=10)
client.job.list(per_page=10, page=2)

Get details about a job.

The number passed to details is the ID of a Zencoder job.

client.job.details(1)

Get progress on a job.

The number passed to progress is the ID of a Zencoder job.

client.job.progress(1)

Resubmit a job

The number passed to resubmit is the ID of a Zencoder job.

client.job.resubmit(1)

Cancel a job

The number passed to cancel is the ID of a Zencoder job.

client.job.cancel(1)

Get details about an input.

The number passed to details is the ID of a Zencoder job.

client.input.details(1)

Get progress for an input.

The number passed to progress is the ID of a Zencoder job.

client.input.progress(1)

Get details about an output.

The number passed to details is the ID of a Zencoder job.

client.output.details(1)

Get progress for an output.

The number passed to progress is the ID of a Zencoder job.

client.output.progress(1)

Reports are great for getting usage data for your account. All default to 30 days from yesterday with no grouping, but this can be altered. These will return 422 Unprocessable Entity if the date format is incorrect or the range is greater than 2 months.

Get all usage (Live + VOD).

import datetime
client.report.all()
client.report.all(grouping="foo")
client.report.all(start_date=datetime.date(2011, 10, 30),
                end_date=datetime.date(2011, 11, 24))
client.report.all(start_date=datetime.date(2011, 10, 30),
                end_date=datetime.date(2011, 11, 24),
                grouping="foo")

Get VOD usage.

import datetime
client.report.vod()
client.report.vod(grouping="foo")
client.report.vod(start_date=datetime.date(2011, 10, 30),
               end_date=datetime.date(2011, 11, 24))
client.report.vod(start_date=datetime.date(2011, 10, 30),
               end_date=datetime.date(2011, 11, 24),
               grouping="foo")

Get Live usage.

import datetime
client.report.live()
client.report.live(grouping="foo")
client.report.live(start_date=datetime.date(2011, 10, 30),
                end_date=datetime.date(2011, 11, 24))
client.report.live(start_date=datetime.date(2011, 10, 30),
                end_date=datetime.date(2011, 11, 24),
                grouping="foo")

Create a new account. A unique email address and terms of service are required, but you can also specify a password (and confirmation) along with whether or not you want to subscribe to the Zencoder newsletter. New accounts will be created under the Test (Free) plan.

No API Key is required.

client.account.create('[email protected]', tos=1)
client.account.create('[email protected]', tos=1,
                   options={'password': 'abcd1234',
                            'affiliate_code': 'foo'})

Get details about the current account.

client.account.details()

Turn integration mode on (all jobs are test jobs).

client.account.integration()

Turn off integration mode, which means your account is live (and you'll be billed for jobs).

client.account.live()

Tests

The tests use the mock library to stub in response data from the API. Run tests individually:

$ python test/test_jobs.py

Or use nose:

$ nosetests

zencoder-py's People

Contributors

schworer avatar kennedyj avatar issackelly avatar senko avatar

Watchers

James Cloos 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.