# Path: pyfeld/xmlHelper.py
# class XmlHelper:
#     @staticmethod
#     def xml_extract_dict(xml, extract_keys):
#         result_dict = {}
#         for k in extract_keys:
#             try:
#                 element = xml.getElementsByTagName(k)
#                 result_dict[k] = element[0].firstChild.nodeValue
#             except Exception as e:
#                 result_dict[k] = ""
#         return result_dict
# 
#     def xml_extract_dict_by_val(xml, extract_keys):
#         result_dict = {}
#         for k in extract_keys:
#             try:
#                 element = xml.getElementsByTagName(k)
#                 result_dict[k] = element[0].getAttribute("val")
#             except Exception as e:
#                 pass
#         return result_dict


import json
import requests
import sys
import cgi 
from time import time
from xml.dom import minidom
from pyfeld.xmlHelper import XmlHelper
from pyfeld.didlInfo import DidlInfo
    def stop(self):
        xml_root = self.host_send_transport("Stop",  '<InstanceID>0</InstanceID>')
        return xml_root.toprettyxml()

    def pause(self):
        xml_root = self.host_send_transport("Pause",  '<InstanceID>0</InstanceID>')
        return xml_root.toprettyxml()

    def seek(self, value):
        xml_root = self.host_send_transport("Seek",
                                           '<InstanceID>0</InstanceID><Unit>ABS_TIME</Unit>'
                                           '<Target>' + value + '</Target>')
        return xml_root.toprettyxml()

    def previous(self):
        xml_root = self.host_send_transport("Previous", '<InstanceID>0</InstanceID>')
        return xml_root.toprettyxml()

    def next(self):
        xml_root = self.host_send_transport("Next", '<InstanceID>0</InstanceID>')
        return xml_root.toprettyxml()

    def get_state_var(self):
        xml_root = self.host_send_rendering("GetStateVariables",
                                           '<InstanceID>0</InstanceID><'
                                           'StateVariableList>TransportStatus</StateVariableList>')
        return xml_root.toprettyxml()

    def get_position_info(self):
        xml_root = self.host_send_transport("GetPositionInfo",  '<InstanceID>0</InstanceID>')

# Path: pyfeld/xmlHelper.py
# class XmlHelper:
#     @staticmethod
#     def xml_extract_dict(xml, extract_keys):
#         result_dict = {}
#         for k in extract_keys:
#             try:
#                 element = xml.getElementsByTagName(k)
#                 result_dict[k] = element[0].firstChild.nodeValue
#             except Exception as e:
#                 result_dict[k] = ""
#         return result_dict
# 
#     def xml_extract_dict_by_val(xml, extract_keys):
#         result_dict = {}
#         for k in extract_keys:
#             try:
#                 element = xml.getElementsByTagName(k)
#                 result_dict[k] = element[0].getAttribute("val")
#             except Exception as e:
#                 pass
#         return result_dict


# Path: pyfeld/upnpCommand.py
import json
import requests
import sys
import cgi 
from time import time
from xml.dom import minidom
from pyfeld.xmlHelper import XmlHelper
from pyfeld.didlInfo import DidlInfo

    def stop(self):
        xml_root = self.host_send_transport("Stop",  '<InstanceID>0</InstanceID>')
        return xml_root.toprettyxml()

    def pause(self):
        xml_root = self.host_send_transport("Pause",  '<InstanceID>0</InstanceID>')
        return xml_root.toprettyxml()

    def seek(self, value):
        xml_root = self.host_send_transport("Seek",
                                           '<InstanceID>0</InstanceID><Unit>ABS_TIME</Unit>'
                                           '<Target>' + value + '</Target>')
        return xml_root.toprettyxml()

    def previous(self):
        xml_root = self.host_send_transport("Previous", '<InstanceID>0</InstanceID>')
        return xml_root.toprettyxml()

    def next(self):
        xml_root = self.host_send_transport("Next", '<InstanceID>0</InstanceID>')
        return xml_root.toprettyxml()

    def get_state_var(self):
        xml_root = self.host_send_rendering("GetStateVariables",
                                           '<InstanceID>0</InstanceID><'
                                           'StateVariableList>TransportStatus</StateVariableList>')
        return xml_root.toprettyxml()

    def get_position_info(self):
        xml_root = self.host_send_transport("GetPositionInfo",  '<InstanceID>0</InstanceID>')

        return XmlHelper.xml_extract_dict(xml_root, ['Track',