mirror of
https://github.com/zoriya/guessit.git
synced 2026-06-06 20:03:14 +00:00
Add mimetype property
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
Reference in New Issue
Block a user