# 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
# This file is part of Trackma.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#





class MPRISTracker(tracker.TrackerBase):
    name = 'Tracker (MPRIS)'
    mpris_base = 'org.mpris.MediaPlayer2'

    def is_active_player(self, sender):

# 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

# This file is part of Trackma.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#





class MPRISTracker(tracker.TrackerBase):
    name = 'Tracker (MPRIS)'
    mpris_base = 'org.mpris.MediaPlayer2'

    def is_active_player(self, sender):

        return not self.active_player or self.active_player == sender or self.last_state != utils.Tracker.PLAYING