nzbToMedia/libs/guessit/jsonutils.py
Labrys of Knossos 2eb9d9dc7c Update guessit to 3.0.3
Also updates:
- babelfish-0.5.5
- python-dateutil-2.7.5
- rebulk-1.0.0
- six-1.12.0
2018-12-15 16:08:03 -05:00

22 lines
518 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
JSON Utils
"""
import json
from six import text_type
from rebulk.match import Match
class GuessitEncoder(json.JSONEncoder):
"""
JSON Encoder for guessit response
"""
def default(self, o): # pylint:disable=method-hidden
if isinstance(o, Match):
return o.advanced
if hasattr(o, 'name'): # Babelfish languages/countries long name
return text_type(o.name)
# pragma: no cover
return text_type(o)