Sayonara Player
CoverLocation.h
1 /* CoverLocation.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef COVERLOCATION_H
22 #define COVERLOCATION_H
23 
24 #include <QMetaType>
25 #include "Utils/Pimpl.h"
26 
27 class QUrl;
28 
29 namespace Cover
30 {
31  using StringMap=QMap<QString, QString>;
32 
37  class Location
38  {
39  PIMPL(Location)
40 
41 
42  private:
43  void set_valid(bool b);
44  void set_identifier(const QString& identifier);
45  void set_cover_path(const QString& cover_path);
46  void set_local_path_hint(const QString& base_path);
47 
52  void set_hash(const QString& str);
53 
61  bool set_audio_file_source(const QString& audio_filesource, const QString& cover_path);
62 
63 
64  public:
69  Location();
70  ~Location();
71  Location(const Location& cl);
72  Location& operator=(const Location& cl);
73 
79  bool valid() const;
80 
86  static bool is_invalid(const QString& cover_path);
87 
88 
94  QString cover_path() const;
95 
101  QString identifer() const;
102 
107  const QStringList& search_urls() const;
108 
117  QString search_url(int idx) const;
118 
123  bool has_search_urls() const;
124 
125 
131  QString search_term() const;
132 
137  void set_search_term(const QString& search_term);
138 
147  void set_search_term(const QString& search_term,
148  const QString& cover_fetcher_identifier);
149 
154  void set_search_urls(const QStringList& urls);
155 
164  void enable_freetext_search(bool b);
165  bool is_freetext_search_enabled() const;
166 
171  QString to_string() const;
172 
179  QString hash() const;
180 
187  bool has_audio_file_source() const;
188 
195  QString audio_file_source() const;
196 
203  QString audio_file_target() const;
204 
205 
211  QString local_path_hint() const;
212 
213 
219  QString preferred_path() const;
220 
221 
228  static Location cover_location(const QString& album_name, const QString& artist_name);
229 
237  static Location cover_location(const QString& album_name, const QStringList& artists);
238 
239 
246  static Location xcover_location(const Album& album);
247 
248 
254  static Location cover_location(const QString& artist);
255 
256 
263  static Location cover_location(const Artist& artist);
264 
265 
275  static Location cover_location(const MetaData& md);
276 
277 
284  static Location cover_location(const QUrl& url, const QString& target_path);
285 
286 
291  static Location invalid_location();
292 
293 
298  static QString get_cover_directory(const QString& append_path);
299  };
300 }
301 
302 Q_DECLARE_METATYPE(Cover::Location)
303 
304 #endif // COVERLOCATION_H
QString preferred_path() const
Use this to retrieve a filepath where a copy of the cover is stored.
QString hash() const
Every combination of album and artist will result in a specific hash. You can find those hashes in th...
bool valid() const
returns if the current location is a valid or a standard constructed location
QString search_url(int idx) const
Search urls contains urls from Google, Discogs or Audioscrobbler. They are ordered as configured in t...
static Location xcover_location(const Album &album)
overloaded. Calls cover_location(const QString& album_name, const QStringList& artists) ...
The MetaData class.
Definition: MetaData.h:44
bool has_audio_file_source() const
Indicates if it is possible to fetch the cover directly from the audio file. If you call this method ...
bool has_search_urls() const
Check for existing search urls.
static Location invalid_location()
returns an invalid location
void set_search_term(const QString &search_term)
Set a new search term.
Location()
Default constructor. Creates an invalid Location with the Sayonara logo as cover. ...
static bool is_invalid(const QString &cover_path)
returns if path is the same as the invalid location path
The CoverLocation class.
Definition: CoverLocation.h:37
static QString get_cover_directory(const QString &append_path)
returns the standard cover directory
QString audio_file_source() const
Returns the path to the music file where a cover is stored. You can extract the cover by using Taggin...
void enable_freetext_search(bool b)
When enabling freetext search you specify the search string yourself and it is not generated automati...
QString local_path_hint() const
Get the path of an audio file where a cover is stored in the same directory.
QString identifer() const
This identifier may be used in order to check how the cover algorithm determined the locations...
void set_search_urls(const QStringList &urls)
Set urls where to look for Covers in the internet.
static Location cover_location(const QString &album_name, const QString &artist_name)
creates CoverLocation by taking the md5 sum between album_name and artist_name
QString cover_path() const
Returns the standard cover path in the .Sayonara directory.
QString to_string() const
to_string
const QStringList & search_urls() const
Retrieve the urls where a new cover can be searched.
QString audio_file_target() const
When retrieving the audio_file_source, and you want to save it afterwards, store it at the place retu...
The Album class.
Definition: Album.h:39
Definition: SomaFMStation.h:33
The Artist class.
Definition: Artist.h:36
QString search_term() const
Search term for a free search. As a human you would type that search term into your browser...