3 # This file is part of Jamaendo.
4 # Copyright (c) 2010 Kristoffer Gronlund
6 # Jamaendo 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 # Jamaendo 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 Jamaendo. If not, see <http://www.gnu.org/licenses/>.
19 # Player code heavily based on http://thpinfo.com/2008/panucci/:
20 # A resuming media player for Podcasts and Audiobooks
21 # Copyright (c) 2008-05-26 Thomas Perl <thpinfo.com>
22 # (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
24 # console interface to jamaui/jamaendo
26 # debugging hack - add . to path
28 local_module_dir = os.path.join(os.path.dirname(sys.argv[0]), '..')
29 if os.path.isdir(local_module_dir):
30 sys.path.append(local_module_dir)
33 from jamaui.player import Player, Playlist, the_player
37 gobject.threads_init()
41 pp = pprint.PrettyPrinter(indent=4)
45 class Console(object):
49 queries = ['albums_of_the_week', 'artists', 'albums']
51 getattr(self, "query_"+query)()
53 print "Valid queries: " + ", ".join(queries)
55 def query_albums_of_the_week(self):
56 result = jamaendo.albums_of_the_week()
57 pp.pprint([(a.ID, a.name) for a in result])
61 def query_artists(self):
62 result = jamaendo.search_artists(sys.argv[2])
63 pp.pprint([(a.ID, a.name) for a in result])
65 albums = jamaendo.get_albums(a.ID)
67 print "Playing album: %s - %s" % (a.name, album.name)
68 self.play_album(album)
70 def query_albums(self):
71 result = jamaendo.search_albums(sys.argv[2])
72 pp.pprint([(a.ID, a.name) for a in result])
76 def play_tracks(self, tracks):
77 playlist = Playlist(tracks)
81 while player.playing():
84 except KeyboardInterrupt:
87 def play_album(self, album):
90 print "%s - %s" % (album.artist_name, album.name)
92 self.play_tracks(album.tracks)
94 if __name__=="__main__":