# 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/utils.py
# VERSION = '0.8.4'
# DATADIR = os.path.dirname(__file__) + '/data'
#     PASSWD = auto()
#     OAUTH = auto()
#     OAUTH_PKCE = auto()
#     UNKNOWN = 'Unknown'
#     ONGOING = 'Ongoing'
#     FINISHED = 'Finished'
#     NOTYET = 'Not yet started'
#     CANCELLED = 'Cancelled'
#     OTHER = 'Other'
#     AIRING = ONGOING
#     RELEASING = ONGOING
#     PUBLISHING = ONGOING
#     CURRENTLY_AIRING = ONGOING
#     FINISHED_AIRING = FINISHED
#     NOT_YET_AIRED = NOTYET
#     NOT_YET_RELEASED = NOTYET
#     NOT_YET_PUBLISHED = NOTYET
#     UNKNOWN = "Unknown"
#     OTHER = "Other"
#     TV = "TV"
#     MOVIE = "Movie"
#     OVA = "OVA"
#     SPECIAL = "Special"
#     MANGA = "Manga"
#     NOVEL = "Novel"
#     ONE_SHOT = "One Shot"
#     SP = SPECIAL
#     MUSIC = OTHER
#     ONA = OVA
#     NOVIDEO = auto()
#     PLAYING = auto()
#     UNRECOGNIZED = auto()
#     NOT_FOUND = auto()
#     IGNORED = auto()
#     WINTER = 'Winter'
#     SPRING = 'Spring'
#     SUMMER = 'Summer'
#     FALL = 'Fall'
#     KEYWORD = auto()
#     SEASON = auto()
#     KW = KEYWORD
# HOME = os.path.expanduser("~")
# EXTENSIONS = ('.mkv', '.mp4', '.avi', '.ts')
# class Login(Enum):
# class BaseEnum(Enum):
# class Status(BaseEnum):
# class Type(BaseEnum):
# class Tracker(Enum):
# class Season(Enum):
# class SearchMethod(Enum):
# class TrackmaError(Exception):
# class EngineError(TrackmaError):
# class DataError(TrackmaError):
# class APIError(TrackmaError):
# class AccountError(TrackmaError):
# class TrackmaFatal(Exception):
# class EngineFatal(TrackmaFatal):
# class DataFatal(TrackmaFatal):
# class APIFatal(TrackmaFatal):
#     def find(cls, name):
#     def from_int(cls, index):
#     def __int__(self):
#     def __lt__(self, other):
#     def __le__(self, other):
#     def __gt__(self, other):
#     def __ge__(self, other):
#     def __add__(self, other):
#     def __str__(self):
# def oauth_generate_pkce() -> str:
# def parse_config(filename, default):
# def save_config(config_dict, filename):
# def load_data(filename):
# def save_data(data, filename):
# def log_error(msg):
# def expand_path(path):
# def expand_paths(paths):
# def is_media(filename):
# def regex_find_videos(subdirectory=''):
# def regex_rename_files(pattern, source_dir, dest_dir):
# def list_library(path):
# def make_dir(path):
# def dir_exists(dirname):
# def file_exists(filename):
# def file_older_than(filename, mtime):
# def try_files(filenames):
# def sync_file(fname, sync_url):
# def copy_file(src, dest):
# def to_config_path(*paths):
# def to_data_path(*paths):
# def to_cache_path(*paths):
# def change_permissions(filename, mode):
# def estimate_aired_episodes(show):
# def guess_show(show_title, tracker_list):
# def redirect_show(show_tuple, redirections, tracker_list):
# def spawn_process(arg_list):
# def get_terminal_size(fd=1):
# def show():


import os
import re
import urllib.parse
from pydbus import SessionBus
from gi.repository import GLib
from trackma.tracker import tracker
from trackma import utils
            # TODO : Support for full path
            return os.path.basename(urllib.parse.unquote_plus(metadata['xesam:url']))
        else:
            return None

    def _handle_status(self, status, sender):
        self.msg.debug(self.name, "New playback status: {}".format(status))

        if status == "Playing":
            self._playing(self.filenames[sender], sender)
            self.resume_timer()
        elif status == "Paused":
            self._playing(self.filenames[sender], sender)
            self.pause_timer()
        elif status == "Stopped":
            self._stopped(sender)

        self.statuses[sender] = status

    def _playing(self, filename, sender):
        if filename != self.last_filename:
            self.msg.debug(self.name, "New video: {}".format(filename))

            (state, show_tuple) = self._get_playing_show(filename)
            self.update_show_if_needed(state, show_tuple)

            self.msg.debug(self.name, "New tracker status: {} ({})".format(
                state, self.last_state))

            # We can override the active player if this player is playing a valid show.

# 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/utils.py
# VERSION = '0.8.4'
# DATADIR = os.path.dirname(__file__) + '/data'
#     PASSWD = auto()
#     OAUTH = auto()
#     OAUTH_PKCE = auto()
#     UNKNOWN = 'Unknown'
#     ONGOING = 'Ongoing'
#     FINISHED = 'Finished'
#     NOTYET = 'Not yet started'
#     CANCELLED = 'Cancelled'
#     OTHER = 'Other'
#     AIRING = ONGOING
#     RELEASING = ONGOING
#     PUBLISHING = ONGOING
#     CURRENTLY_AIRING = ONGOING
#     FINISHED_AIRING = FINISHED
#     NOT_YET_AIRED = NOTYET
#     NOT_YET_RELEASED = NOTYET
#     NOT_YET_PUBLISHED = NOTYET
#     UNKNOWN = "Unknown"
#     OTHER = "Other"
#     TV = "TV"
#     MOVIE = "Movie"
#     OVA = "OVA"
#     SPECIAL = "Special"
#     MANGA = "Manga"
#     NOVEL = "Novel"
#     ONE_SHOT = "One Shot"
#     SP = SPECIAL
#     MUSIC = OTHER
#     ONA = OVA
#     NOVIDEO = auto()
#     PLAYING = auto()
#     UNRECOGNIZED = auto()
#     NOT_FOUND = auto()
#     IGNORED = auto()
#     WINTER = 'Winter'
#     SPRING = 'Spring'
#     SUMMER = 'Summer'
#     FALL = 'Fall'
#     KEYWORD = auto()
#     SEASON = auto()
#     KW = KEYWORD
# HOME = os.path.expanduser("~")
# EXTENSIONS = ('.mkv', '.mp4', '.avi', '.ts')
# class Login(Enum):
# class BaseEnum(Enum):
# class Status(BaseEnum):
# class Type(BaseEnum):
# class Tracker(Enum):
# class Season(Enum):
# class SearchMethod(Enum):
# class TrackmaError(Exception):
# class EngineError(TrackmaError):
# class DataError(TrackmaError):
# class APIError(TrackmaError):
# class AccountError(TrackmaError):
# class TrackmaFatal(Exception):
# class EngineFatal(TrackmaFatal):
# class DataFatal(TrackmaFatal):
# class APIFatal(TrackmaFatal):
#     def find(cls, name):
#     def from_int(cls, index):
#     def __int__(self):
#     def __lt__(self, other):
#     def __le__(self, other):
#     def __gt__(self, other):
#     def __ge__(self, other):
#     def __add__(self, other):
#     def __str__(self):
# def oauth_generate_pkce() -> str:
# def parse_config(filename, default):
# def save_config(config_dict, filename):
# def load_data(filename):
# def save_data(data, filename):
# def log_error(msg):
# def expand_path(path):
# def expand_paths(paths):
# def is_media(filename):
# def regex_find_videos(subdirectory=''):
# def regex_rename_files(pattern, source_dir, dest_dir):
# def list_library(path):
# def make_dir(path):
# def dir_exists(dirname):
# def file_exists(filename):
# def file_older_than(filename, mtime):
# def try_files(filenames):
# def sync_file(fname, sync_url):
# def copy_file(src, dest):
# def to_config_path(*paths):
# def to_data_path(*paths):
# def to_cache_path(*paths):
# def change_permissions(filename, mode):
# def estimate_aired_episodes(show):
# def guess_show(show_title, tracker_list):
# def redirect_show(show_tuple, redirections, tracker_list):
# def spawn_process(arg_list):
# def get_terminal_size(fd=1):
# def show():


# Path: trackma/tracker/mpris.py
import os
import re
import urllib.parse
from pydbus import SessionBus
from gi.repository import GLib
from trackma.tracker import tracker
from trackma import utils

            # TODO : Support for full path
            return os.path.basename(urllib.parse.unquote_plus(metadata['xesam:url']))
        else:
            return None

    def _handle_status(self, status, sender):
        self.msg.debug(self.name, "New playback status: {}".format(status))

        if status == "Playing":
            self._playing(self.filenames[sender], sender)
            self.resume_timer()
        elif status == "Paused":
            self._playing(self.filenames[sender], sender)
            self.pause_timer()
        elif status == "Stopped":
            self._stopped(sender)

        self.statuses[sender] = status

    def _playing(self, filename, sender):
        if filename != self.last_filename:
            self.msg.debug(self.name, "New video: {}".format(filename))

            (state, show_tuple) = self._get_playing_show(filename)
            self.update_show_if_needed(state, show_tuple)

            self.msg.debug(self.name, "New tracker status: {} ({})".format(
                state, self.last_state))

            # We can override the active player if this player is playing a valid show.

            if not self.active_player or self.last_state == utils.Tracker.PLAYING: