Add mimetype property

This commit is contained in:
Toilal
2015-11-05 21:46:41 +01:00
parent b5cf22f297
commit aba054a6ec
2 changed files with 24 additions and 1 deletions
+3 -1
View File
@@ -12,6 +12,7 @@ from .common.comparators import marker_sorted
from .common.date import valid_year
from .properties.type import type_processor
from .properties.mimetype import mimetype_processor
import six
@@ -163,4 +164,5 @@ def enlarge_group_matches(matches):
PROCESSORS = Rebulk().processor(enlarge_group_matches).post_processor(equivalent_holes, remove_ambiguous,
country_in_title, season_year, type_processor)
country_in_title, season_year, mimetype_processor,
type_processor)
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
mimetype property
"""
import mimetypes
from rebulk.match import Match
def mimetype_processor(matches):
"""
Mimetype post processor
:param matches:
:type matches:
:return:
:rtype:
"""
mime, _ = mimetypes.guess_type(matches.input_string, strict=False)
if mime is not None:
matches.append(Match(0, len(matches.input_string), name='mimetype', value=mime))