# Path: trackma/tracker/tracker.py
# class TrackerBase(object):
#     def __init__(self, messenger, tracker_list, config, watch_dirs, redirections=None):
#     def set_message_handler(self, message_handler):
#     def disable(self):
#     def update_list(self, tracker_list):
#     def connect_signal(self, signal, callback):
#     def observe(self, config, watch_dirs):
#     def get_status(self):
#     def _emit_signal(self, signal, *args):
#     def _update_show(self, state, show_tuple):
#                 def action(): return self._emit_signal('update', show, episode)
#                 def action(): return self._emit_signal('unrecognised', show, episode)
#     def _ignore_current(self):
#     def _update_state(self, state):
#     def pause_timer(self):
#     def resume_timer(self):
#     def update_show_if_needed(self, state, show_tuple):
#     def _get_playing_show(self, filename):


import ntpath
import time
import urllib.parse
import urllib.request
import xml.dom.minidom as xdmd
import trackma.utils as utils
from trackma.tracker import tracker
                self.msg.warn(
                    self.name, "Claimed Plex Media Server, login in the settings and restart trackma.")
            elif self.status_log[-1] == NOT_RUNNING and self.status_log[-2] == NOT_RUNNING:
                self.msg.warn(self.name, "Plex Media Server is not running.")

            del self.status_log[0]

            # Wait for the interval before running check again
            time.sleep(config['tracker_interval'])

    def _get_plex_token(self):
        username = self.config['plex_user']
        password = self.config['plex_passwd']
        uuid = self.config['plex_uuid']

        if not (username and password):
            return ''

        body = bytes('user[login]=%s&user[password]=%s' %
                     (username, password), "utf-8")
        headers = {'X-Plex-Client-Identifier': uuid,
                   'X-Plex-Product': "Trackma",
                   'X-Plex-Version': utils.VERSION}

        req = urllib.request.Request(
            'https://plex.tv/users/sign_in.xml', body, headers=headers)
        response = urllib.request.urlopen(req)
        data = response.read().decode("utf-8")

        tdoc = xdmd.parseString(data)

# Path: trackma/tracker/tracker.py
# class TrackerBase(object):
#     def __init__(self, messenger, tracker_list, config, watch_dirs, redirections=None):
#     def set_message_handler(self, message_handler):
#     def disable(self):
#     def update_list(self, tracker_list):
#     def connect_signal(self, signal, callback):
#     def observe(self, config, watch_dirs):
#     def get_status(self):
#     def _emit_signal(self, signal, *args):
#     def _update_show(self, state, show_tuple):
#                 def action(): return self._emit_signal('update', show, episode)
#                 def action(): return self._emit_signal('unrecognised', show, episode)
#     def _ignore_current(self):
#     def _update_state(self, state):
#     def pause_timer(self):
#     def resume_timer(self):
#     def update_show_if_needed(self, state, show_tuple):
#     def _get_playing_show(self, filename):


# Path: trackma/tracker/plex.py
import ntpath
import time
import urllib.parse
import urllib.request
import xml.dom.minidom as xdmd
import trackma.utils as utils
from trackma.tracker import tracker

                self.msg.warn(
                    self.name, "Claimed Plex Media Server, login in the settings and restart trackma.")
            elif self.status_log[-1] == NOT_RUNNING and self.status_log[-2] == NOT_RUNNING:
                self.msg.warn(self.name, "Plex Media Server is not running.")

            del self.status_log[0]

            # Wait for the interval before running check again
            time.sleep(config['tracker_interval'])

    def _get_plex_token(self):
        username = self.config['plex_user']
        password = self.config['plex_passwd']
        uuid = self.config['plex_uuid']

        if not (username and password):
            return ''

        body = bytes('user[login]=%s&user[password]=%s' %
                     (username, password), "utf-8")
        headers = {'X-Plex-Client-Identifier': uuid,
                   'X-Plex-Product': "Trackma",
                   'X-Plex-Version': utils.VERSION}

        req = urllib.request.Request(
            'https://plex.tv/users/sign_in.xml', body, headers=headers)
        response = urllib.request.urlopen(req)
        data = response.read().decode("utf-8")

        tdoc = xdmd.parseString(data)

        token = tdoc.getElementsByTagName("user")[0].getAttribute("authToken")