"""
Main Zencoder module
"""

class Zencoder(object):
    base_url = 'https://app.zencoder.com/api'
    def __init__(self, api_key):
        """ Initialize Zencoder """
        self.api_key = api_key


@@ -21,16 +21,68 @@
 dule%0A%22%22%22
+%0Aimport os%0A%0Aclass ZencoderError(Exception):%0A    pass
 %0A%0Aclass 
@@ -145,16 +145,17 @@
 om/api'%0A
+%0A
     def 
@@ -176,16 +176,21 @@
  api_key
+=None
 ):%0A     
@@ -232,28 +232,243 @@
     
-self.api_key = api_key
+if not api_key:%0A            try:%0A                self.api_key = os.environ%5B'ZENCODER_API_KEY'%5D%0A            except KeyError:%0A                raise ZencoderError('ZENCODER_API_KEY not set')%0A        else:%0A            self.api_key = api_key%0A
 %0A%0A

set the api_key correctly will fall back on grabbing the ZENCODER_API_KEY env var