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:
69  ~Location();
70  Location(const Location& cl);
71  Location& operator=(const Location& cl);
72 
78  bool isValid() const;
79 
85  QString hashPath() 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 
137 
146  void enableFreetextSearch(bool b);
147 
152  QString toString() const;
153 
160  QString hash() const;
161 
168  bool hasAudioFileSource() const;
169 
176  QString audioFileSource() const;
177 
184  QString audioFileTarget() const;
185 
186 
187 
192  QString localPathDir() const;
193 
199  QStringList localPathHints() const;
200 
207  QString localPath() const;
208 
209 
215  QString preferredPath() const;
216 
217 
218  QString alternativePath() const;
219 
220 
227  static Location coverLocation(const QString& albumName, const QString& artistName);
228 
236  static Location coverLocation(const QString& albumName, const QStringList& artists);
237 
238 
245  static Location xcoverLocation(const Album& album);
246 
247 
253  static Location coverLocation(const QString& artist);
254  static Location coverLocationRadio(const QString& radioStation);
255 
256 
263  static Location coverLocation(const Artist& artist);
264 
265 
275  static Location coverLocation(const MetaData& md);
276  static Location coverLocation(const MetaData& md, bool checkForCoverart);
277 
278 
285  static Location coverLocation(const QList<QUrl>& urls, const QString& token);
286 
287 
288  static QString invalidPath();
289 
295  };
296 }
297 
298 Q_DECLARE_METATYPE(Cover::Location)
299 
300 #endif // COVERLOCATION_H
Cover::Location::toString
QString toString() const
to_string
Cover::Location::coverLocation
static Location coverLocation(const Artist &artist)
overloaded. extracts artist name and calls coverLocation(const QString& artist)
Cover::Location::searchTerm
QString searchTerm() const
Search term for a free search. As a human you would type that search term into your browser.
Cover::Location::hashPath
QString hashPath() const
Returns the standard cover path in the .Sayonara directory.
Cover::Location::setSearchUrls
void setSearchUrls(const QList< Fetcher::Url > &urls)
Set urls where to look for Covers in the internet.
Cover::Location::searchUrls
QList< Fetcher::Url > searchUrls() const
Retrieve the urls where a new cover can be searched.
Cover::Location::xcoverLocation
static Location xcoverLocation(const Album &album)
overloaded. Calls coverLocation(const QString& albumName, const QStringList& artists)
Cover::Location::enableFreetextSearch
void enableFreetextSearch(bool b)
When enabling freetext search you specify the search string yourself and it is not generated automati...
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::localPathHints
QStringList localPathHints() const
Get the paths audio file where a cover is stored in the same directory.
Album
The Album class.
Definition: Album.h:41
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
QMap
Definition: org_mpris_media_player2_adaptor.h:21
Cover::Location::coverLocation
static Location coverLocation(const QString &albumName, const QStringList &artists)
overloaded. Picks major artist out of artists and calls coverLocation(const QString& albumName,...
Cover::Location::invalidLocation
static Location invalidLocation()
returns an invalid location
Cover::Location::hasSearchUrls
bool hasSearchUrls() const
Check for existing search urls.
Cover::Location::Location
Location()
Default constructor. Creates an invalid Location with the Sayonara logo as cover.
Cover::Location::setSearchTerm
void setSearchTerm(const QString &searchTerm)
Set a new search term.
Cover::Location::localPathDir
QString localPathDir() const
Calculates the directory where the cover is located.
Artist
The Artist class.
Definition: Artist.h:38
Cover::Location::coverLocation
static Location coverLocation(const QList< QUrl > &urls, const QString &token)
fetch a cover from a specific url
Cover::Location
The CoverLocation class.
Definition: CoverLocation.h:39
Cover::Location::audioFileSource
QString audioFileSource() const
Returns the path to the music file where a cover is stored. You can extract the cover by using Taggin...
Cover::Location::coverLocation
static Location coverLocation(const QString &albumName, const QString &artistName)
creates CoverLocation by taking the md5 sum between albumName and artistName
Cover::Location::isValid
bool isValid() const
returns if the current location is a valid or a standard constructed location
MetaData
The MetaData class.
Definition: MetaData.h:47
Cover::Location::hasAudioFileSource
bool hasAudioFileSource() const
Indicates if it is possible to fetch the cover directly from the audio file. If you call this method ...
Cover::Location::setSearchTerm
void setSearchTerm(const QString &searchTerm, const QString &coverFetcherIdentifier)
Set a new search term for a specific cover fetcher Cover fetcher strings can be found in the Cover::F...
Cover::Location::audioFileTarget
QString audioFileTarget() const
When retrieving the audio_file_source, and you want to save it afterwards, store it at the place retu...
Cover::Location::localPath
QString localPath() const
Get the path which is nearest to the audio files. Repair/Create a link in the Sayonara cover director...
Cover::Location::preferredPath
QString preferredPath() const
Use this to retrieve a filepath where a copy of the cover is stored.
Cover::Location::coverLocation
static Location coverLocation(const QString &artist)
Creates cover token of the form artist_<md5sum of artist>
Cover::Location::coverLocation
static Location coverLocation(const MetaData &md)
overloaded. if MetaData::albumId < 0 calls coverLocation(const QString& albumName,...