From 86dc32bc2030c7c7580190515e31838151c5ef80 Mon Sep 17 00:00:00 2001
From: Boris Bobrov <breton@cynicmansion.ru>
Date: Wed, 9 Mar 2016 12:28:14 +0300
Subject: [PATCH] Check all tags for existence before using them
Fix bug 5401
---
mediagoblin/media_types/video/util.py | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/mediagoblin/media_types/video/util.py b/mediagoblin/media_types/video/util.py
index 10705ea..8b65d83 100644
a
|
b
|
def skip_transcode(metadata, size):
|
35 | 35 | |
36 | 36 | _log.debug('skip_transcode config: {0}'.format(config)) |
37 | 37 | |
38 | | tags = metadata.get_tags() |
39 | | if not tags: |
| 38 | metadata_tags = metadata.get_tags() |
| 39 | if not metadata_tags: |
40 | 40 | return False |
41 | 41 | |
42 | | if config['mime_types'] and tags.get_string('mimetype')[0]: |
43 | | if not tags.get_string('mimetype')[1] in config['mime_types']: |
| 42 | if config['mime_types'] and metadata_tags.get_string('mimetype')[0]: |
| 43 | if not metadata_tags.get_string('mimetype')[1] in config['mime_types']: |
44 | 44 | return False |
45 | 45 | |
46 | | if config['container_formats'] and tags.get_string('container-format')[0]: |
47 | | if not (tags.get_string('container-format')[1] in |
| 46 | if (config['container_formats'] and |
| 47 | metadata_tags.get_string('container-format')[0]): |
| 48 | if not (metadata_tags.get_string('container-format')[1] in |
48 | 49 | config['container_formats']): |
49 | 50 | return False |
50 | 51 | |
51 | 52 | if config['video_codecs']: |
52 | 53 | for video_info in metadata.get_video_streams(): |
53 | | if not (video_info.get_tags().get_string('video-codec')[1] in |
| 54 | video_tags = video_info.get_tags() |
| 55 | if not video_tags: |
| 56 | return False |
| 57 | if not (video_tags.get_string('video-codec')[1] in |
54 | 58 | config['video_codecs']): |
55 | 59 | return False |
56 | 60 | |
57 | 61 | if config['audio_codecs']: |
58 | 62 | for audio_info in metadata.get_audio_streams(): |
59 | | if not (audio_info.get_tags().get_string('audio-codec')[1] in |
| 63 | audio_tags = audio_info.get_tags() |
| 64 | if not audio_tags: |
| 65 | return False |
| 66 | if not (audio_tags.get_string('audio-codec')[1] in |
60 | 67 | config['audio_codecs']): |
61 | 68 | return False |
62 | 69 | |