Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixing the grains and the callback

  • Loading branch information...
commit 11947b4476afe2037e33df8150aad189f11dd677 1 parent ce3d5c5
Douglas Camata authored November 05, 2012

Showing 1 changed file with 10 additions and 8 deletions. Show diff stats Hide diff stats

  1. 18  nsivideogranulate/tasks.py
18  nsivideogranulate/tasks.py
@@ -97,25 +97,25 @@ def _process_video(self):
97 97
                 grains_keys['videos'].append(video_key)
98 98
 
99 99
         if grains.has_key('audio') and grains['audio'] is not None:
100  
-            audio = grains['audio'].getContent().getvalue()
  100
+            audio = grains['audio']
101 101
             print 'Got the video audio.'
102  
-            row = {'file': b64encode(audio)}
  102
+            row = {'file': b64encode(audio.getContent().getvalue()), 'filename': audio.id}
103 103
             audio_key = self.sam.put(value=row).resource().key
104 104
             grains_keys['audio'] = audio_key
105 105
 
106 106
         if grains.has_key('thumbnails') and grains['thumbnails'] is not None:
107  
-            thumbnails = [thumbnail.getContent().getvalue() for thumbnail in grains['thumbnails']]
  107
+            thumbnails = [thumbnail for thumbnail in grains['thumbnails']]
108 108
             print 'Got the video thumbnails.'
109 109
             grains_keys['thumbnails'] = []
110 110
             for thumbnail in thumbnails:
111  
-                row = {'file': b64encode(thumbnail)}
  111
+                row = {'file': b64encode(thumbnail.getContent().getvalue()), 'filename': thumbnail.id}
112 112
                 thumbnail_key = self.sam.put(value=row).resource().key
113 113
                 grains_keys['thumbnails'].append(thumbnail_key)
114 114
 
115 115
         if grains.has_key('converted_video') and grains['converted_video'] is not None:
116  
-            converted_video = grains['converted_video'].getContent().getvalue()
  116
+            converted_video = grains['converted_video']
117 117
             print 'Got the converted video.'
118  
-            row = {'file': b64encode(converted_video)}
  118
+            row = {'file': b64encode(converted_video.getContent().getvalue()), 'filename': converted_video.id}
119 119
             converted_video_key = self.sam.put(value=row).resource().key
120 120
             grains_keys['converted_video'] = converted_video_key
121 121
 
@@ -141,8 +141,10 @@ def run(self, url, verb, video_uid, grains_keys):
141 141
         try:
142 142
             print "Sending callback to %s" % url
143 143
             restfulie = Restfulie.at(url).as_('application/json')
144  
-            thumbnails = grains_keys['thumbnails']
145  
-            del grains_keys['thumbnails']
  144
+            thumbnails = []
  145
+            if grains_keys.get('thumbnails'):
  146
+                thumbnails = grains_keys['thumbnails']
  147
+                del grains_keys['thumbnails']
146 148
             response = getattr(restfulie, verb)(video_key=video_uid, grains_keys=grains_keys, thumbnails_keys=thumbnails, done=True)
147 149
         except Exception, e:
148 150
             print "Erro no callback."

0 notes on commit 11947b4

Please sign in to comment.
Something went wrong with that request. Please try again.