2 # -*- coding: utf-8 -*-
4 # Copyright (c) 2009, 2010, 2012 Kaliko Jack <kaliko.jack@azylum.org>
6 # This program 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.
11 # This program 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.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 from time import sleep
25 from lib.goodies import Goodie
33 'sw': ['-c', '--crossfade'],
37 'help': 'fade out/fade in over t seconds.'},
47 'description': 'Jump to next album in playlist.',
52 Goodie.__init__(self, self.__class__.script_info,
53 extra_options=NALBUM_OPTS)
56 def _fade(self, io='out'):
58 end_volum => End volume value
59 mpd_vol => Start volume value
61 mpd_vol = int(self.init_vol)
63 end_volum = mpd_vol / 10
64 mpd_vol = self.init_vol
66 end_volum = int(self.init_vol)
67 mpd_vol = int(self.init_vol) / 10
68 span = float(end_volum - mpd_vol)
69 step = span / float(10*self.cli_options.time)
72 self.client.setvol(int(mpd_vol))
73 if abs(mpd_vol - end_volum) < 1:
74 self.client.setvol(end_volum)
79 """Retrieve playlist from current song to the end."""
80 if 'song' not in self.client.status():
81 print "No current song set in MPD!"
82 self.client.disconnect()
84 current_album = str(self.client.currentsong().get('album', 'TAG MISSING'))
85 current_song_pos = int(self.client.currentsong().get('pos'))
86 print 'Current album: "%s"' % current_album
87 next_album_pos = current_song_pos
89 while album == current_album:
91 pl_length = int(self.client.status().get('playlistlength')) - 1
92 if pl_length < next_album_pos:
93 print 'Next album not found in the playlitst!'
94 self.client.disconnect()
96 album = self.client.playlistinfo(next_album_pos)[0].get('album', 'TAG MISSING')
97 print 'Next album appears to be: "%s"' % album
102 print 'Connecting %s:%i' % (self.cli_options.host, self.cli_options.port)
104 self.init_vol = int(self.client.status().get('volume'))
105 if self.cli_options.time:
106 print 'Cross fading next album'
108 self.client.play(self._get_next())
109 if self.cli_options.time:
111 self.client.disconnect()
116 if __name__ == '__main__':
119 except KeyboardInterrupt:
120 sys.stdout.write('exit')
123 # vim: ai ts=4 sw=4 sts=4 expandtab