Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Update readme docs with usage #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 6, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update README to reflect node library
  • Loading branch information
Alex Schworer committed Jun 6, 2013
commit b9245417c60d3f5e4271b0919741e0ad66369cca
200 changes: 73 additions & 127 deletions 200 README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,35 @@
# Zencoder
[![Build Status](https://travis-ci.org/zencoder/zencoder-py.png?branch=master)](https://travis-ci.org/zencoder/zencoder-py)

A Python module for the [Zencoder](http://zencoder.com) API.

## Installation
Install from PyPI using `easy_install` or `pip`.

pip install zencoder

## Dependencies
`zencoder-py` depends on [requests](http://python-requests.org), and uses the `json` or `simplejson` module.
Zencoder
----

## Usage
[![Build Status](https://travis-ci.org/zencoder/zencoder-py.png?branch=master)](https://travis-ci.org/zencoder/zencoder-py)

from zencoder import Zencoder
zen = Zencoder('abc123') # enter your api key
A Python module for interacting with the [Zencoder](http://zencoder.com) API.

# creates an encoding job with the defaults
job = zen.job.create('http://input-file/movie.avi')
print job.code
print job.body
print job.body['id']
### Getting Started

# get the transcode progress of the first output
progress = zen.output.progress(job.body['outputs'][0]['id'])
print progress.body
Install from PyPI

$ pip install zencoder

# configure your outputs with dictionaries
iphone = {
'label': 'iPhone',
'url': 's3://output-bucket/output-file-1.mp4',
'width': 480,
'height': 320
}
web = {
'label': 'web',
'url': 's3://output-bucket/output-file.vp8',
'video_codec':, 'vp8'
}
# the outputs kwarg requires an iterable
outputs = (iphone, web)
another_job = zen.job.create(input_url, outputs=outputs)
Import zencoder

**Note:** If you set the `ZENCODER_API_KEY` environment variable to your api key, you don't have to provide it when initializing Zencoder.
```python
from zencoder import Zencoder
```

## Specifying the API Version
Set the version of the Zencoder API you want to use as the `api_version` keyword to the `Zencoder` object (defaults to `v2`):
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'.

```python
# set to version 1: https://app.zencoder.com/api/v1/
zen = Zencoder(api_version='v1')
# If you want to specify an API key when creating a client
client = Zencoder('API_KEY')

# set to the edge version: https://app.zencoder.com/api/
zen = Zencoder(api_version='edge')
```
# If you have the environment variable set
client = Zencoder()

## Jobs
## [Jobs](https://app.zencoder.com/docs/api/jobs)

There's more you can do on jobs than anything else in the API. The following methods are available: `list`, `create`, `details`, `progress`, `resubmit`, `cancel`, `delete`.

### create
Create a [new job](https://app.zencoder.com/docs/api/jobs/create).

```python
zen.job.create('s3://bucket/key.mp4')
Expand All @@ -77,7 +46,7 @@ response.code # 201
response.body['id'] # 12345
```

### list
[List jobs](https://app.zencoder.com/docs/api/jobs/list).

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`.

Expand All @@ -86,31 +55,31 @@ zen.job.list(per_page=10)
zen.job.list(per_page=10, page=2)
```

### details
Get [details](https://app.zencoder.com/docs/api/jobs/show) about a job.

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

```python
zen.job.details(1)
```

### progress
Get [progress](https://app.zencoder.com/docs/api/jobs/progress) on a job.

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

```python
zen.job.progress(1)
```

### resubmit
[Resubmit](https://app.zencoder.com/docs/api/jobs/resubmit) a job

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

```python
zen.job.resubmit(1)
```

### cancel
[Cancel](https://app.zencoder.com/docs/api/jobs/cancel) a job

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

Expand All @@ -126,97 +95,60 @@ The number passed to `delete` is the ID of a Zencoder job.
zen.job.delete(1)
```

## Inputs
## [Inputs](https://app.zencoder.com/docs/api/inputs)

### details
Get [details](https://app.zencoder.com/docs/api/inputs/show) about an input.

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

```python
zen.input.details(1)
```

### progress
Get [progress](https://app.zencoder.com/docs/api/inputs/progress) for an input.

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

```python
zen.input.progress(1)
```

## Outputs
## [Outputs](https://app.zencoder.com/docs/api/outputs)

### details
Get [details](https://app.zencoder.com/docs/api/outputs/show) about an output.

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

```python
zen.output.details(1)
```

### progress
Get [progress](https://app.zencoder.com/docs/api/outputs/progress) for an output.

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

```python
zen.output.progress(1)
```

## Accounts
## [Reports](https://app.zencoder.com/docs/api/reports)

### create
Reports are great for getting usage data for your account. All default to 30 days from yesterday with no [grouping](https://app.zencoder.com/docs/api/encoding/job/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.

No API Key is required.

```python
zen.account.create('foo@example.com', tos=1)
zen.account.create('foo@example.com', tos=1,
options={'password': 'abcd1234',
'affiliate_code': 'foo'})
```

### details

```python
zen.account.details()
```

### integration

This will put your account into integration mode (site-wide).

```python
zen.account.integration()
```

### live

This will put your account into live mode (site-wide).

```python
zen.account.live()
```

## Reports

### minutes

This will list the minutes used for your account within a certain, configurable range.
Get [all usage](https://app.zencoder.com/docs/api/reports/all) (Live + VOD).

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

### vod

This will list the VOD minutes used for your account.
Get [VOD usage](https://app.zencoder.com/docs/api/reports/vod).

```python
import datetime
Expand All @@ -229,9 +161,7 @@ zen.report.vod(start_date=datetime.date(2011, 10, 30),
grouping="foo")
```

### live

This will list the Live transcoding minutes used for your account.
Get [Live usage](https://app.zencoder.com/docs/api/reports/live).

```python
import datetime
Expand All @@ -244,27 +174,43 @@ zen.report.live(start_date=datetime.date(2011, 10, 30),
grouping="foo")
```

### all
## [Accounts](https://app.zencoder.com/docs/api/accounts)

This will list all of the transcoding minutes used for your account.
Create a [new account](https://app.zencoder.com/docs/api/accounts/create). 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.

```python
import datetime
zen.report.all()
zen.report.all(grouping="foo")
zen.report.all(start_date=datetime.date(2011, 10, 30),
end_date=datetime.date(2011, 11, 24))
zen.report.all(start_date=datetime.date(2011, 10, 30),
end_date=datetime.date(2011, 11, 24),
grouping="foo")
zen.account.create('foo@example.com', tos=1)
zen.account.create('foo@example.com', tos=1,
options={'password': 'abcd1234',
'affiliate_code': 'foo'})
```

Get [details](https://app.zencoder.com/docs/api/accounts/show) about the current account.

```python
zen.account.details()
```

## Documentation
Docs are in progress, and hosted at Read the Docs: http://zencoder.rtfd.org
Turn [integration mode](https://app.zencoder.com/docs/api/accounts/integration) on (all jobs are test jobs).

```python
zen.account.integration()
```

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

```python
zen.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

## Contributors
* [Senko Rasic](http://github.com/senko)
* [Josh Kennedy](http://github.com/kennedyj)
* [Issac Kelly](http://github.com/issackelly)
Or use `nose`:

$ nosetests

Morty Proxy This is a proxified and sanitized view of the page, visit original site.