]> kaliko git repositories - mpd-sima.git/blob - sima/lib/player.py
Add copyright headers & clean-up
[mpd-sima.git] / sima / lib / player.py
1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2009-2014 Jack Kaliko <jack@azylum.org>
3 #
4 #  This file is part of sima
5 #
6 #  sima is free software: you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation, either version 3 of the License, or
9 #  (at your option) any later version.
10 #
11 #  sima is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with sima.  If not, see <http://www.gnu.org/licenses/>.
18 #
19 #
20
21 # TODO:
22 # Add decorator to filter through history?
23
24 # standard library import
25 import logging
26
27 # local import
28 #from sima.lib.track import Track
29
30
31 class Player(object):
32
33     """Player interface to inherit from.
34
35     When querying player music library for tracks, Player instance *must* return
36     Track objects (usually a list of them)
37
38     Player instance should expose the following immutable attributes:
39         * artists
40         * state
41         * current
42         * queue
43         * playlist
44         *
45     """
46
47     def __init__(self):
48         super().__init__()
49         self.log = logging.getLogger('sima')
50
51     def monitor(self):
52         """Monitor player for change
53         Returns :
54             * database  player media library has changed
55             * playlist  playlist modified
56             * options   player options changed: repeat mode, etc…
57             * player    player state changed: paused, stopped, skip track…
58         """
59         raise NotImplementedError
60
61     def remove(self, position=0):
62         """Removes the oldest element of the playlist (index 0)
63         """
64         raise NotImplementedError
65
66     def find_track(self, artist, title=None):
67         """
68         Find tracks for a specific artist or filtering with a track title
69             >>> player.find_track('The Beatles')
70             >>> player.find_track('Nirvana', title='Smells Like Teen Spirit')
71
72         Returns a list of Track objects
73         """
74         raise NotImplementedError
75
76     def find_album(self, artist, album):
77         """
78         Find tracks by track's album name
79             >>> player.find_album('Nirvana', 'Nevermind')
80
81         Returns a list of Track objects
82         """
83         raise NotImplementedError
84
85     def find_albums(self, artist):
86         """
87         Find albums by artist's name
88             >>> player.find_alums('Nirvana')
89
90         Returns a list of string objects
91         """
92         raise NotImplementedError
93
94     def fuzzy_find_artist(self, artist):
95         """
96         Find artists based on a fuzzy search in the media library
97             >>> bea = player.fuzzy_find_artist('beatles')
98             >>> print(bea)
99             >>> ['The Beatles']
100
101         Returns a list of strings (artist names)
102         """
103         raise NotImplementedError
104
105     def disconnect(self):
106         """Closing client connection with the Player
107         """
108         raise NotImplementedError
109
110     def connect(self):
111         """Connect client to the Player
112         """
113         raise NotImplementedError
114
115 # VIM MODLINE
116 # vim: ai ts=4 sw=4 sts=4 expandtab