Plex plugin to to play various online streams (mostly Latvian).

__init__.py 1.3KB

1234567891011121314151617181920212223242526272829303132
  1. ######################## BEGIN LICENSE BLOCK ########################
  2. # This library is free software; you can redistribute it and/or
  3. # modify it under the terms of the GNU Lesser General Public
  4. # License as published by the Free Software Foundation; either
  5. # version 2.1 of the License, or (at your option) any later version.
  6. #
  7. # This library is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. # Lesser General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU Lesser General Public
  13. # License along with this library; if not, write to the Free Software
  14. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  15. # 02110-1301 USA
  16. ######################### END LICENSE BLOCK #########################
  17. __version__ = "2.3.0"
  18. from sys import version_info
  19. def detect(aBuf):
  20. if ((version_info < (3, 0) and isinstance(aBuf, unicode)) or
  21. (version_info >= (3, 0) and not isinstance(aBuf, bytes))):
  22. raise ValueError('Expected a bytes object, not a unicode object')
  23. from . import universaldetector
  24. u = universaldetector.UniversalDetector()
  25. u.reset()
  26. u.feed(aBuf)
  27. u.close()
  28. return u.result