Sayonara Player
CoverLocation.h
1 /* CoverLocation.h */
2 
3 /* Copyright (C) 2011-2019 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  namespace Fetcher
32  {
33  class Url;
34  }
35 
36  using StringMap=QMap<QString, QString>;
37 
42  class Location
43  {
44  PIMPL(Location)
45 
46  private:
47  void set_valid(bool b);
48  void set_identifier(const QString& identifier);
49  void set_cover_path(const QString& cover_path);
50  void set_local_path_hints(const QStringList& local_paths);
51 
56  void set_hash(const QString& str);
57 
65  bool set_audio_file_source(const QString& audio_filesource, const QString& cover_path);
66 
67 
68  public:
73  Location();
74  ~Location();
75  Location(const Location& cl);
76  Location& operator=(const Location& cl);
77 
83  bool is_valid() const;
84 
85 
91  QString cover_path() const;
92 
98  QString identifer() const;
99 
104  QList<Fetcher::Url> search_urls(bool also_inactive) const;
105 
114  Fetcher::Url search_url(int idx) const;
115 
116 
121  bool has_search_urls() const;
122 
123 
129  QString search_term() const;
130 
135  void set_search_term(const QString& search_term);
136 
145  void set_search_term(const QString& search_term,
146  const QString& cover_fetcher_identifier);
147 
152  void set_search_urls(const QList<Fetcher::Url>& urls);
153 
162  void enable_freetext_search(bool b);
163  bool is_freetext_search_enabled() const;
164 
169  QString to_string() const;
170 
177  QString hash() const;
178 
185  bool has_audio_file_source() const;
186 
193  QString audio_file_source() const;
194 
201  QString audio_file_target() const;
202 
203 
204 
209  QString local_path_dir() const;
210 
216  QStringList local_path_hints() const;
217 
224  QString local_path() const;
225 
226 
232  QString preferred_path() const;
233 
234 
235  QString alternative_path() const;
236 
237 
244  static Location cover_location(const QString& album_name, const QString& artist_name);
245 
253  static Location cover_location(const QString& album_name, const QStringList& artists);
254 
255 
262  static Location xcover_location(const Album& album);
263 
264 
270  static Location cover_location(const QString& artist);
271 
272 
279  static Location cover_location(const Artist& artist);
280 
281 
291  static Location cover_location(const MetaData& md);
292  static Location cover_location(const MetaData& md, bool check_for_coverart);
293 
294 
301  static Location cover_location(const QUrl& url, const QString& target_path);
302  static Location cover_location(const QList<QUrl>& urls, const QString& target_path);
303 
304 
305  static QString invalid_path();
306 
311  static Location invalid_location();
312 
313 
318  static QString get_cover_directory(const QString& append_path);
319  };
320 }
321 
322 Q_DECLARE_METATYPE(Cover::Location)
323 
324 #endif // COVERLOCATION_H
Cover::Location::has_search_urls
bool has_search_urls() const
Check for existing search urls.
Cover::Location::invalid_location
static Location invalid_location()
returns an invalid location
Cover::Location::has_audio_file_source
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 ...
Cover::Location::search_term
QString search_term() const
Search term for a free search. As a human you would type that search term into your browser.
Cover::Location::set_search_term
void set_search_term(const QString &search_term)
Set a new search term.
Cover::Location::get_cover_directory
static QString get_cover_directory(const QString &append_path)
returns the standard cover directory
Cover::Location::hash
QString hash() const
Every combination of album and artist will result in a specific hash. You can find those hashes in th...
Cover::Location::local_path_dir
QString local_path_dir() const
Calculates the directory where the cover is located.
Cover::Location::audio_file_source
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...
Album
The Album class.
Definition: Album.h:39
Cover::Location::identifer
QString identifer() const
This identifier may be used in order to check how the cover algorithm determined the locations.
QList
Definition: EngineUtils.h:33
Cover::Location::cover_location
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
QMap
Definition: org_mpris_media_player2_adaptor.h:21
Cover::Location::xcover_location
static Location xcover_location(const Album &album)
overloaded. Calls cover_location(const QString& album_name, const QStringList& artists)
Cover::Location::cover_path
QString cover_path() const
Returns the standard cover path in the .Sayonara directory.
Cover::Location::local_path
QString local_path() const
Get the path which is nearest to the audio files. Repair/Create a link in the Sayonara cover director...
Cover::Location::audio_file_target
QString audio_file_target() const
When retrieving the audio_file_source, and you want to save it afterwards, store it at the place retu...
Cover::Location::to_string
QString to_string() const
to_string
Cover::Location::is_valid
bool is_valid() const
returns if the current location is a valid or a standard constructed location
Cover::Location::local_path_hints
QStringList local_path_hints() const
Get the paths audio file where a cover is stored in the same directory.
Cover::Location::Location
Location()
Default constructor. Creates an invalid Location with the Sayonara logo as cover.
Cover::Location::search_urls
QList< Fetcher::Url > search_urls(bool also_inactive) const
Retrieve the urls where a new cover can be searched.
Cover::Location::search_url
Fetcher::Url search_url(int idx) const
Search urls contains urls from Google, Discogs or Audioscrobbler. They are ordered as configured in t...
Cover::Fetcher::Url
Definition: CoverFetcherUrl.h:8
Artist
The Artist class.
Definition: Artist.h:36
Cover::Location::enable_freetext_search
void enable_freetext_search(bool b)
When enabling freetext search you specify the search string yourself and it is not generated automati...
Cover::Location
The CoverLocation class.
Definition: CoverLocation.h:42
MetaData
The MetaData class.
Definition: MetaData.h:44
Cover::Location::preferred_path
QString preferred_path() const
Use this to retrieve a filepath where a copy of the cover is stored.
Cover::Location::set_search_urls
void set_search_urls(const QList< Fetcher::Url > &urls)
Set urls where to look for Covers in the internet.