Play images and video from Synology PhotoStation server

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import
  3. import os
  4. from xml.dom.minidom import parse
  5. import kodiswift.mockxbmc.polib as polib
  6. def load_addon_strings(addon, filename):
  7. """This is not an official Kodi method, it is here to facilitate
  8. mocking up the other methods when running outside of Kodi."""
  9. def get_strings(fn):
  10. if os.path.exists(filename):
  11. po = polib.pofile(fn)
  12. return {entry.msgctxt[1:]: entry.msgid for entry in po}
  13. else:
  14. fn = os.path.splitext(fn)[0] + '.xml'
  15. xml = parse(fn)
  16. strings = {tag.getAttribute('id'): tag.firstChild.data
  17. for tag in xml.getElementsByTagName('string')}
  18. return strings
  19. addon._strings = get_strings(filename)
  20. def get_addon_id(addon_xml):
  21. """Parses an addon id from the given addon.xml filename."""
  22. xml = parse(addon_xml)
  23. addon_node = xml.getElementsByTagName('addon')[0]
  24. return addon_node.getAttribute('id')
  25. def get_addon_name(addon_xml):
  26. """Parses an addon name from the given addon.xml filename."""
  27. xml = parse(addon_xml)
  28. addon_node = xml.getElementsByTagName('addon')[0]
  29. return addon_node.getAttribute('name')