diff --git a/build/windows/Facepager.spec b/build/windows/Facepager.spec index fd0da2d4..da109ace 100644 --- a/build/windows/Facepager.spec +++ b/build/windows/Facepager.spec @@ -5,7 +5,7 @@ block_cipher = None a = Analysis(['Facepager.py'], pathex=['.'], - binaries=[('../build/windows/PySide2', 'PySide2')], + binaries=[('../build/windows/PySide2', 'PySide2'),('../build/windows/cchardet', 'cchardet')], datas=[('ssl', 'ssl')], hiddenimports=[], hookspath=[], diff --git a/build/windows/cchardet/__init__.py b/build/windows/cchardet/__init__.py new file mode 100644 index 00000000..c6db442b --- /dev/null +++ b/build/windows/cchardet/__init__.py @@ -0,0 +1,50 @@ +from cchardet import _cchardet +from .version import __version__ + + +def detect(msg): + """ + Args: + msg: str + Returns: + { + "encoding": str, + "confidence": float + } + """ + encoding, confidence = _cchardet.detect_with_confidence(msg) + if isinstance(encoding, bytes): + encoding = encoding.decode() + return {"encoding": encoding, "confidence": confidence} + + +class UniversalDetector(object): + def __init__(self): + self._detector = _cchardet.UniversalDetector() + + def __enter__(self): + return self + + def __exit__(self, exception_type, exception_value, traceback): + self.close() + return False + + def reset(self): + self._detector.reset() + + def feed(self, data): + self._detector.feed(data) + + def close(self): + self._detector.close() + + @property + def done(self): + return self._detector.done + + @property + def result(self): + encoding, confidence = self._detector.result + if isinstance(encoding, bytes): + encoding = encoding.decode() + return {"encoding": encoding, "confidence": confidence} diff --git a/build/windows/cchardet/_cchardet.cp37-win_amd64.pyd b/build/windows/cchardet/_cchardet.cp37-win_amd64.pyd new file mode 100644 index 00000000..7803b060 Binary files /dev/null and b/build/windows/cchardet/_cchardet.cp37-win_amd64.pyd differ diff --git a/build/windows/cchardet/version.py b/build/windows/cchardet/version.py new file mode 100644 index 00000000..cfb007cb --- /dev/null +++ b/build/windows/cchardet/version.py @@ -0,0 +1 @@ +__version__ = '2.1.5' diff --git a/src/readme.md b/src/readme.md index b966d8f9..77ab0091 100644 --- a/src/readme.md +++ b/src/readme.md @@ -15,6 +15,7 @@ Facepager depends on the following packages: - numpy and pandas: pip install numpy pandas (licensed under BSD and 3-clause BSD license) - lxml: pip install lxml (BSD licence) - xmljson pip install xmljson (MIT licence) +- cchardet: pip install cchardet (GPL, LGPL, MPL 1.1) Facepager needs some secret keys to connect to Facebook, Twitter and YouTube. You can provide the credentials in the user interface or in an credential file. See credentials.py.readme for further details. @@ -35,7 +36,7 @@ Open the command line in a directory of your choice and execute the comments ind $ python -m venv pyenv $ pyenv\Scripts\activate.bat - $ pip install SQLAlchemy python-dateutil requests_oauthlib requests-toolbelt rauth lxml xmljson numpy pandas + $ pip install SQLAlchemy python-dateutil requests_oauthlib requests-toolbelt rauth lxml xmljson numpy pandas cchardet $ pip install PySide2==5.11.1 - Start Facepager @@ -54,7 +55,7 @@ Open terminal in a directory of your choice and execute the commands indicated b $ python3 -m venv pyenv $ source pyenv/bin/activate - $ pip install SQLAlchemy python-dateutil requests_oauthlib requests-toolbelt rauth lxml xmljson numpy pandas + $ pip install SQLAlchemy python-dateutil requests_oauthlib requests-toolbelt rauth lxml xmljson numpy pandas cchardet $ pip install PySide2==5.11.1 - Start Facepager @@ -77,7 +78,7 @@ Open terminal in a directory of your choice and execute the commands indicated b $ python3 -m venv pyenv $ source pyenv/bin/activate - $ pip3 install SQLAlchemy python-dateutil requests_oauthlib requests-toolbelt rauth lxml xmljson numpy pandas + $ pip3 install SQLAlchemy python-dateutil requests_oauthlib requests-toolbelt rauth lxml xmljson numpy pandas cchardet $ pip3 install PySide2==5.11.1 - Start Facepager