Sayonara Player
CoverLocation.h
1 /* CoverLocation.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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 #include "Components/Covers/Fetcher/CoverFetcherUrl.h"
27 
28 class QUrl;
29 
30 namespace Cover
31 {
32  using StringMap=QMap<QString, QString>;
33 
38  class Location
39  {
40  PIMPL(Location)
41 
42  private:
43  void setValid(bool b);
44  void setIdentifier(const QString& identifier);
45  void setLocalPathHints(const QStringList& localPaths);
46 
51  void setHash(const QString& str);
52 
60  bool setAudioFileSource(const QString& audio_filesource, const QString& symlinkPath);
61 
62 
63  public:
68  Location();
69  ~Location();
70  Location(const Location& cl);
71  Location& operator=(const Location& cl);
72 
78  bool isValid() const;
79 
85  QString symlinkPath() const;
86 
92  QString identifer() const;
93 
99 
100 
105  bool hasSearchUrls() const;
106 
107 
113  QString searchTerm() const;
114 
119  void setSearchTerm(const QString& searchTerm);
120 
129  void setSearchTerm(const QString& searchTerm,
130  const QString& coverFetcherIdentifier);
131 
136  void setSearchUrls(const QList<Fetcher::Url>& urls);
137 
146  void enableFreetextSearch(bool b);
147  bool isFreetextSearchEnabled() const;
148 
153  QString toString() const;
154 
161  QString hash() const;
162 
169  bool hasAudioFileSource() const;
170 
177  QString audioFileSource() const;
178 
185  QString audioFileTarget() const;
186 
187 
188 
193  QString localPathDir() const;
194 
200  QStringList localPathHints() const;
201 
208  QString localPath() const;
209 
210 
216  QString preferredPath() const;
217 
218 
219  QString alternativePath() const;
220 
221 
228  static Location coverLocation(const QString& albumName, const QString& artistName);
229 
237  static Location coverLocation(const QString& albumName, const QStringList& artists);
238 
239 
246  static Location xcoverLocation(const Album& album);
247 
248 
254  static Location coverLocation(const QString& artist);
255  static Location coverLocationRadio(const QString& radioStation);
256 
257 
264  static Location coverLocation(const Artist& artist);
265 
266 
276  static Location coverLocation(const MetaData& md);
277  static Location coverLocation(const MetaData& md, bool checkForCoverart);
278 
279 
286  static Location coverLocation(const QList<QUrl>& urls, const QString& token);
287 
288 
289  static QString invalidPath();
290 
295  static Location invalidLocation();
296 
297 
302  static QString getCoverDirectory(const QString& appendPath);
303  };
304 }
305 
306 Q_DECLARE_METATYPE(Cover::Location)
307 
308 #endif // COVERLOCATION_H
QString hash() const
Every combination of album and artist will result in a specific hash. You can find those hashes in th...
QString localPath() const
Get the path which is nearest to the audio files. Repair/Create a link in the Sayonara cover director...
The MetaData class.
Definition: MetaData.h:45
static Location invalidLocation()
returns an invalid location
Location()
Default constructor. Creates an invalid Location with the Sayonara logo as cover.
bool hasSearchUrls() const
Check for existing search urls.
void setSearchTerm(const QString &searchTerm)
Set a new search term.
QString localPathDir() const
Calculates the directory where the cover is located.
void setSearchUrls(const QList< Fetcher::Url > &urls)
Set urls where to look for Covers in the internet.
The CoverLocation class.
Definition: CoverLocation.h:38
QString symlinkPath() const
Returns the standard cover path in the .Sayonara directory.
QStringList localPathHints() const
Get the paths 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.
static Location coverLocation(const QString &albumName, const QString &artistName)
creates CoverLocation by taking the md5 sum between albumName and artistName
bool isValid() const
returns if the current location is a valid or a standard constructed location
bool hasAudioFileSource() const
Indicates if it is possible to fetch the cover directly from the audio file. If you call this method ...
QString audioFileTarget() const
When retrieving the audio_file_source, and you want to save it afterwards, store it at the place retu...
QString preferredPath() const
Use this to retrieve a filepath where a copy of the cover is stored.
The Album class.
Definition: Album.h:39
QString audioFileSource() const
Returns the path to the music file where a cover is stored. You can extract the cover by using Taggin...
The Artist class.
Definition: Artist.h:36
QList< Fetcher::Url > searchUrls() const
Retrieve the urls where a new cover can be searched.
QString searchTerm() const
Search term for a free search. As a human you would type that search term into your browser.
QString toString() const
to_string
static Location xcoverLocation(const Album &album)
overloaded. Calls coverLocation(const QString& albumName, const QStringList& artists)
void enableFreetextSearch(bool b)
When enabling freetext search you specify the search string yourself and it is not generated automati...
static QString getCoverDirectory(const QString &appendPath)
returns the standard cover directory
Definition: org_mpris_media_player2_adaptor.h:21
Definition: EngineUtils.h:33