Kodi plugin to to play various online streams (mostly Latvian)

request.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # -*- coding: utf-8 -*-
  2. """
  3. kodiswift.request
  4. ------------------
  5. This module contains the Request class. This class represents an incoming
  6. request from Kodi.
  7. :copyright: (c) 2012 by Jonathan Beluch
  8. :license: GPLv3, see LICENSE for more details.
  9. """
  10. from __future__ import absolute_import
  11. import urlparse
  12. from kodiswift.common import unpickle_args
  13. __all__ = ['Request']
  14. class Request(object):
  15. def __init__(self, url, handle):
  16. """The request objects contains all the arguments passed to the plugin via
  17. the command line.
  18. Args:
  19. url (str): The complete plugin URL being requested. Since Kodi
  20. typically passes the URL query string in a separate argument
  21. from the base URL, they must be joined into a single string
  22. before being provided.
  23. handle (Union[int, str]): The handle associated with the current
  24. request.
  25. """
  26. self.url = url
  27. #: The current request's handle, an integer.
  28. self.handle = int(handle)
  29. # urlparse doesn't like the 'plugin' scheme, so pass a protocol
  30. # relative url, e.g. //plugin.video.helloxbmc/path
  31. self.scheme, remainder = url.split(':', 1)
  32. parts = urlparse.urlparse(remainder)
  33. self.netloc, self.path, self.query_string = (
  34. parts[1], parts[2], parts[4])
  35. self.args = unpickle_args(urlparse.parse_qs(self.query_string))