Remove sqlite3 build dep.
[gmpc.git] / src / Tools / gmpc-metadata-prefetcher.vala
blob6d884acb146e136babc3bbbda25355bda5be4b19
2 /* Gnome Music Player Client (GMPC)
3 * Copyright (C) 2004-2012 Qball Cow <qball@gmpclient.org>
4 * Project homepage: http://gmpclient.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 2 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 along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 using Config;
21 using Gtk;
22 using Gmpc;
24 private const bool use_transition_mpf = Gmpc.use_transition;
26 public class Gmpc.Tools.MetadataPrefetcher : Gmpc.Plugin.Base
28 private const int[] version = {0,0,2};
30 public override unowned int[] get_version()
32 return this.version;
35 public override unowned string get_name()
37 return "Metadata pre-fetcher";
40 construct
42 /* Mark the plugin as an internal dummy */
43 this.plugin_type = 8+4;
44 /* Attach status changed signal */
45 gmpcconn.status_changed.connect(status_changed);
49 private void status_changed(Connection conn, MPD.Server server, MPD.Status.Changed what)
51 if(!this.get_enabled()) return;
52 if((what&MPD.Status.Changed.NEXTSONG) == MPD.Status.Changed.NEXTSONG)
54 int next_song_id = server.player_get_next_song_id();
55 if(next_song_id > 0)
57 MPD.Song? song = server.playlist_get_song(next_song_id);
58 if(song != null)
60 Gmpc.MetaData.Item met = null;
61 Gmpc.MetaData.Result md_result;
63 GLib.log("MetadataPrefetcher", GLib.LogLevelFlags.LEVEL_DEBUG, "Pre-fetching %s", song.file);
64 /* Query artist */
65 md_result = Gmpc.MetaData.get_path(song, Gmpc.MetaData.Type.ARTIST_ART, out met);
66 /* Query album art */
67 md_result = Gmpc.MetaData.get_path(song, Gmpc.MetaData.Type.ALBUM_ART, out met);