~ricmm/+junk/unity-lens_music-sc

« back to all changes in this revision

Viewing changes to src/genre.vala

  • Committer: Ricardo Mendoza
  • Date: 2012-09-05 14:20:15 UTC
  • Revision ID: ricardo.mendoza@canonical.com-20120905142015-prem6hiyfshwgm8q
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by Alex Launi <alex.launi@canonical.com>
 
17
 *
 
18
 */
 
19
 
 
20
using Gee;
 
21
 
 
22
namespace Unity.MusicLens {
 
23
        
 
24
  public class Genre : GLib.Object
 
25
  {
 
26
    public static const string BLUES_ID = "blues";
 
27
    public static const string CLASSIC_ID = "classic";
 
28
    public static const string COUNTRY_ID = "country";
 
29
    public static const string DISCO_ID = "disco";
 
30
    public static const string FUNK_ID = "funk";
 
31
    public static const string ROCK_ID = "rock";
 
32
    public static const string METAL_ID = "metal";
 
33
    public static const string HIPHOP_ID = "hip-hop";
 
34
    public static const string HOUSE_ID = "house";
 
35
    public static const string NEWWAVE_ID = "new-wave";
 
36
    public static const string RANDB_ID = "r-and-b";
 
37
    public static const string PUNK_ID = "punk";
 
38
    public static const string JAZZ_ID = "jazz";
 
39
    public static const string POP_ID = "pop";
 
40
    public static const string REGGAE_ID = "reggae";
 
41
    public static const string SOUL_ID = "soul";
 
42
    public static const string TECHNO_ID = "techno";
 
43
    public static const string OTHER_ID = "other";
 
44
 
 
45
    private static TreeMultiMap<string, string> map;
 
46
    private static Map<string, string> inverted_map;
 
47
 
 
48
    static construct
 
49
    {
 
50
      map = new TreeMultiMap<string, string> ();
 
51
 
 
52
      /* blues */
 
53
      map.set (BLUES_ID, "blues");
 
54
 
 
55
      /* classic */
 
56
      map.set (CLASSIC_ID, "classic");
 
57
      map.set (CLASSIC_ID, "classical");
 
58
      map.set (CLASSIC_ID, "opera");
 
59
 
 
60
      /* country */
 
61
      map.set (COUNTRY_ID, "country");
 
62
 
 
63
      /* disco */
 
64
      map.set (DISCO_ID, "disco");
 
65
 
 
66
      /* funk */
 
67
      map.set (FUNK_ID, "funk");
 
68
 
 
69
      /* rock */
 
70
      map.set (ROCK_ID, "rock");
 
71
      map.set (ROCK_ID, "heavy");
 
72
      map.set (ROCK_ID, "hard");
 
73
      map.set (ROCK_ID, "rock and roll");
 
74
 
 
75
      /* metal */
 
76
      map.set (METAL_ID, "metal");
 
77
      map.set (METAL_ID, "heavy");
 
78
      map.set (METAL_ID, "heavy metal");
 
79
 
 
80
      /*hip hop */
 
81
      map.set (HIPHOP_ID, "hip-hop");
 
82
      map.set (HIPHOP_ID, "rap");
 
83
      map.set (HIPHOP_ID, "rap & hip hop");
 
84
 
 
85
      /*house*/
 
86
      map.set (HOUSE_ID, "house");
 
87
      map.set (HOUSE_ID, "chillout");
 
88
      map.set (HOUSE_ID, "minimal");
 
89
      map.set (HOUSE_ID, "hard");
 
90
      map.set (HOUSE_ID, "electronic");
 
91
      map.set (HOUSE_ID, "dance");
 
92
 
 
93
      /*new wave*/
 
94
      map.set (NEWWAVE_ID, "new-wave");
 
95
 
 
96
      /*r-and-b*/
 
97
      map.set (RANDB_ID, "r-and-b");
 
98
      map.set (RANDB_ID, "r&b");
 
99
 
 
100
      /*punk*/
 
101
      map.set (PUNK_ID, "punk");
 
102
      map.set (PUNK_ID, "punk rock");
 
103
      map.set (PUNK_ID, "hardcore");
 
104
      map.set (PUNK_ID, "heavy");
 
105
 
 
106
      /*jazz*/
 
107
      map.set (JAZZ_ID, "jazz");
 
108
 
 
109
      /*pop*/
 
110
      map.set (POP_ID, "pop");
 
111
      
 
112
      /*reggae*/
 
113
      map.set (REGGAE_ID, "reggae");
 
114
 
 
115
      /*soul*/
 
116
      map.set (SOUL_ID, "soul");
 
117
      map.set (SOUL_ID, "gospel");
 
118
 
 
119
      /*techno*/
 
120
      map.set (TECHNO_ID, "techno");
 
121
      map.set (TECHNO_ID, "minimal");
 
122
      map.set (TECHNO_ID, "trance");
 
123
      map.set (TECHNO_ID, "chillout");
 
124
      map.set (TECHNO_ID, "electronic");
 
125
      map.set (TECHNO_ID, "electronica");
 
126
      map.set (TECHNO_ID, "dance");
 
127
 
 
128
      /*other*/
 
129
      map.set (OTHER_ID, "other");
 
130
      map.set (OTHER_ID, "african");
 
131
      map.set (OTHER_ID, "alternative");
 
132
      map.set (OTHER_ID, "ambient");
 
133
      map.set (OTHER_ID, "asian");
 
134
      map.set (OTHER_ID, "brazilian");
 
135
      map.set (OTHER_ID, "celtic");
 
136
      map.set (OTHER_ID, "christmas");
 
137
      map.set (OTHER_ID, "folk");
 
138
      map.set (OTHER_ID, "latin");
 
139
      map.set (OTHER_ID, "oldies");
 
140
      map.set (OTHER_ID, "soundtrack");
 
141
      map.set (OTHER_ID, "traditional");
 
142
      map.set (OTHER_ID, "world");
 
143
 
 
144
      inverted_map = new HashMap<string, string> ();
 
145
      foreach (var key in map.get_keys ())
 
146
      {
 
147
        var values_collection = map[key];
 
148
        foreach (var val in values_collection)
 
149
        {
 
150
          inverted_map[val] = key;
 
151
        }
 
152
      }
 
153
    }
 
154
 
 
155
    public Collection<string> get_genre_synonyms (string genre_id)
 
156
    {
 
157
      if (map.contains (genre_id))
 
158
        return map.get (genre_id);
 
159
      
 
160
      return new LinkedList<string> ();
 
161
    }
 
162
 
 
163
    public string get_id_for_genre (string genre)
 
164
    {
 
165
      return inverted_map[genre] ?? OTHER_ID;
 
166
    }
 
167
  }
 
168
}
 
169