# 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 time
import json
import base64
import urllib.request
import trackma.utils as utils
from trackma.tracker import tracker
    def _timer_from_file(self):
        # returns 80% of video duration for the update timer,
        # roughly the time of the video minus the OP and ED
        if self._get_kodi_status() == IDLE:
            return None

        time = self._get_player_props("totaltime")
        seconds = (time['hours']*3600)+(time['minutes']*60)+(time['seconds'])

        return round(seconds*0.80)

    def _get_rpc_info(self, method, params={}):
        url = "http://{}/jsonrpc".format(self.host_port)

        body = {
            "method": method,
            "params": params,
            "jsonrpc": "2.0",
            "id": 0
        }

        if not self.config['kodi_user'] == '':
            req = urllib.request.Request(url, json.dumps(
                body).encode(), headers=self.headers)
            b64 = base64.b64encode(bytes("{}:{}".format(
                self.config['kodi_user'], self.config['kodi_passwd']), 'ascii'))
            req.add_header("Authorization",
                           "Basic {}".format(b64.decode('utf-8')))
        else:
            req = urllib.request.Request(url, json.dumps(

# 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/kodi.py
import time
import json
import base64
import urllib.request
import trackma.utils as utils
from trackma.tracker import tracker

    def _timer_from_file(self):
        # returns 80% of video duration for the update timer,
        # roughly the time of the video minus the OP and ED
        if self._get_kodi_status() == IDLE:
            return None

        time = self._get_player_props("totaltime")
        seconds = (time['hours']*3600)+(time['minutes']*60)+(time['seconds'])

        return round(seconds*0.80)

    def _get_rpc_info(self, method, params={}):
        url = "http://{}/jsonrpc".format(self.host_port)

        body = {
            "method": method,
            "params": params,
            "jsonrpc": "2.0",
            "id": 0
        }

        if not self.config['kodi_user'] == '':
            req = urllib.request.Request(url, json.dumps(
                body).encode(), headers=self.headers)
            b64 = base64.b64encode(bytes("{}:{}".format(
                self.config['kodi_user'], self.config['kodi_passwd']), 'ascii'))
            req.add_header("Authorization",
                           "Basic {}".format(b64.decode('utf-8')))
        else:
            req = urllib.request.Request(url, json.dumps(

                body).encode(), headers=self.headers)