diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index 22f3df7..545f07d 100644 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -38,17 +38,18 @@ def encode(filename, prefix, profile, info=None, extract_frames=True): oshash = info['oshash'] frames = [] cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash))) - if info.get('video'): - if extract_frames: - for pos in utils.video_frame_positions(info['duration']): - frame_name = '%s.png' % pos - frame_f = os.path.join(cache, frame_name) - if not os.path.exists(frame_f): - print frame_f - extract.frame(filename, frame_f, pos) - frames.append(frame_f) + if info.get('video') and extract_frames: + for pos in utils.video_frame_positions(info['duration']): + frame_name = '%s.png' % pos + frame_f = os.path.join(cache, frame_name) + if not os.path.exists(frame_f): + print frame_f + extract.frame(filename, frame_f, pos) + frames.append(frame_f) + if info.get('video') or info.get('audio'): media_f = os.path.join(cache, profile) - if not os.path.exists(media_f): + if not os.path.exists(media_f) \ + or os.stat(media_f).st_size == 0: extract.video(filename, media_f, profile, info) else: print info