Вот такой вот класс:
import ctypes
class CMagic:
   __mgc = None
   __cookie = None
   def __init__(self):
     #Загружаем libmagic.so
     self.__mgc = ctypes.cdll.LoadLibrary("libmagic.so")
     #Создаем новый cookie (требуется для
     #работы с magic-последовательностями)
     #0x10 | 0x400 = MAGIC_MIME (константа
     #декларируется в magic.h)
     self.__cookie = self.__mgc.magic_open(0x10 | 0x400)
     #Загружаем в __cookie
     #/etc/file/magic.mime (т.к. указано None)
     self.__mgc.magic_load(self.__cookie, None)
   def __del__(self):
     #Закрываем __cookie
     self.__mgc.magic_close(self.__cookie)
   def getMType(self,filename):
     #Получаем информацию о файле
     result = self.__mgc.magic_file(self.__cookie,filename)
     #magic_file возвращает const char*,
     #mimetype.value - это строка по указателю
     mimetype = ctypes.c_char_p(result)
     rez = mimetype.value
     return rez
   def is_video(self,filename):
     #Проверяем, является ли файл
     #- видео файлом
     mime = self.getMType(filename)
     if mime.count("video"):
       return 1
     return 0
