Ticket #5401: 0001-Check-all-tags-for-existence-before-using-them.patch

File 0001-Check-all-tags-for-existence-before-using-them.patch, 2.3 KB (added by Boris Bobrov, 9 years ago)
  • mediagoblin/media_types/video/util.py

    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):  
    3535
    3636    _log.debug('skip_transcode config: {0}'.format(config))
    3737
    38     tags = metadata.get_tags()
    39     if not tags:
     38    metadata_tags = metadata.get_tags()
     39    if not metadata_tags:
    4040        return False
    4141
    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']:
    4444            return False
    4545
    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
    4849                config['container_formats']):
    4950            return False
    5051
    5152    if config['video_codecs']:
    5253        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
    5458                    config['video_codecs']):
    5559                return False
    5660
    5761    if config['audio_codecs']:
    5862        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
    6067                    config['audio_codecs']):
    6168                return False
    6269