Python module (submodule repositary), which provides content (video streams) from various online stream sources to corresponding Enigma2, Kodi, Plex plugins

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # Copyright (c) 2009 Raymond Hettinger
  2. #
  3. # Permission is hereby granted, free of charge, to any person
  4. # obtaining a copy of this software and associated documentation files
  5. # (the "Software"), to deal in the Software without restriction,
  6. # including without limitation the rights to use, copy, modify, merge,
  7. # publish, distribute, sublicense, and/or sell copies of the Software,
  8. # and to permit persons to whom the Software is furnished to do so,
  9. # subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be
  12. # included in all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  16. # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. # OTHER DEALINGS IN THE SOFTWARE.
  22. from UserDict import DictMixin
  23. class OrderedDict(dict, DictMixin):
  24. def __init__(self, *args, **kwds):
  25. if len(args) > 1:
  26. raise TypeError('expected at most 1 arguments, got %d' % len(args))
  27. try:
  28. self.__end
  29. except AttributeError:
  30. self.clear()
  31. self.update(*args, **kwds)
  32. def clear(self):
  33. self.__end = end = []
  34. end += [None, end, end] # sentinel node for doubly linked list
  35. self.__map = {} # key --> [key, prev, next]
  36. dict.clear(self)
  37. def __setitem__(self, key, value):
  38. if key not in self:
  39. end = self.__end
  40. curr = end[1]
  41. curr[2] = end[1] = self.__map[key] = [key, curr, end]
  42. dict.__setitem__(self, key, value)
  43. def __delitem__(self, key):
  44. dict.__delitem__(self, key)
  45. key, prev, next = self.__map.pop(key)
  46. prev[2] = next
  47. next[1] = prev
  48. def __iter__(self):
  49. end = self.__end
  50. curr = end[2]
  51. while curr is not end:
  52. yield curr[0]
  53. curr = curr[2]
  54. def __reversed__(self):
  55. end = self.__end
  56. curr = end[1]
  57. while curr is not end:
  58. yield curr[0]
  59. curr = curr[1]
  60. def popitem(self, last=True):
  61. if not self:
  62. raise KeyError('dictionary is empty')
  63. if last:
  64. key = reversed(self).next()
  65. else:
  66. key = iter(self).next()
  67. value = self.pop(key)
  68. return key, value
  69. def __reduce__(self):
  70. items = [[k, self[k]] for k in self]
  71. tmp = self.__map, self.__end
  72. del self.__map, self.__end
  73. inst_dict = vars(self).copy()
  74. self.__map, self.__end = tmp
  75. if inst_dict:
  76. return (self.__class__, (items,), inst_dict)
  77. return self.__class__, (items,)
  78. def keys(self):
  79. return list(self)
  80. setdefault = DictMixin.setdefault
  81. update = DictMixin.update
  82. pop = DictMixin.pop
  83. values = DictMixin.values
  84. items = DictMixin.items
  85. iterkeys = DictMixin.iterkeys
  86. itervalues = DictMixin.itervalues
  87. iteritems = DictMixin.iteritems
  88. def __repr__(self):
  89. if not self:
  90. return '%s()' % (self.__class__.__name__,)
  91. return '%s(%r)' % (self.__class__.__name__, self.items())
  92. def copy(self):
  93. return self.__class__(self)
  94. @classmethod
  95. def fromkeys(cls, iterable, value=None):
  96. d = cls()
  97. for key in iterable:
  98. d[key] = value
  99. return d
  100. def __eq__(self, other):
  101. if isinstance(other, OrderedDict):
  102. if len(self) != len(other):
  103. return False
  104. for p, q in zip(self.items(), other.items()):
  105. if p != q:
  106. return False
  107. return True
  108. return dict.__eq__(self, other)
  109. def __ne__(self, other):
  110. return not self == other