~ci-train-bot/mediascanner2/mediascanner2-ubuntu-zesty-2129

« back to all changes in this revision

Viewing changes to src/mediascanner/Album.cc

  • Committer: CI Train Bot
  • Author(s): James Henstridge
  • Date: 2015-11-24 08:56:45 UTC
  • mfrom: (314.1.11 folder-coverart)
  • Revision ID: ci-train-bot@canonical.com-20151124085645-9wyqr4az3s861qpn
If a folder contains an image file named {cover,album,albumart,.folder,folder}.{jpeg,jpg,png} use it as album art for songs in preference to online art if the songs do not have embedded art. Fixes: #1372000
Approved by: PS Jenkins bot, Michi Henning

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "Album.hh"
 
21
#include "internal/FolderArtCache.hh"
21
22
#include "internal/utils.hh"
22
23
 
23
24
using namespace std;
30
31
    string date;
31
32
    string genre;
32
33
    string filename;
 
34
    bool has_thumbnail;
33
35
 
34
36
    Private() {}
35
37
    Private(const string &title, const string &artist,
36
38
            const string &date, const string &genre,
37
 
            const string &filename)
 
39
            const string &filename, bool has_thumbnail)
38
40
        : title(title), artist(artist), date(date), genre(genre),
39
 
          filename(filename) {}
 
41
          filename(filename), has_thumbnail(has_thumbnail) {}
40
42
    Private(const Private &other) {
41
43
        *this = other;
42
44
    }
46
48
}
47
49
 
48
50
Album::Album(const std::string &title, const std::string &artist)
49
 
    : Album(title, artist, "", "", "") {
 
51
    : Album(title, artist, "", "", "", false) {
50
52
}
51
53
 
52
54
Album::Album(const std::string &title, const std::string &artist,
53
55
             const std::string &date, const std::string &genre,
54
56
             const std::string &filename)
55
 
    : p(new Private(title, artist, date, genre, filename)) {
 
57
    : Album(title, artist, date, genre, filename, !filename.empty()) {
 
58
}
 
59
 
 
60
Album::Album(const std::string &title, const std::string &artist,
 
61
             const std::string &date, const std::string &genre,
 
62
             const std::string &filename, bool has_thumbnail)
 
63
    : p(new Private(title, artist, date, genre, filename, has_thumbnail)) {
56
64
}
57
65
 
58
66
Album::Album(const Album &other) : p(new Private(*other.p)) {
100
108
    return p->filename;
101
109
}
102
110
 
 
111
bool Album::getHasThumbnail() const noexcept {
 
112
    return p->has_thumbnail;
 
113
}
 
114
 
103
115
std::string Album::getArtUri() const {
104
 
    if (p->filename.empty()) {
 
116
    if (p->has_thumbnail) {
 
117
        return make_thumbnail_uri(getUri(p->filename));
 
118
    } else {
 
119
        auto standalone = FolderArtCache::get().get_art_for_file(p->filename);
 
120
        if (!standalone.empty()) {
 
121
            return make_thumbnail_uri(getUri(standalone));
 
122
        }
105
123
        return make_album_art_uri(p->artist, p->title);
106
 
    } else {
107
 
        return make_thumbnail_uri(getUri(p->filename));
108
124
    }
109
125
}
110
126
 
113
129
        p->artist == other.p->artist &&
114
130
        p->date == other.p->date &&
115
131
        p->genre == other.p->genre &&
116
 
        p->filename == other.p->filename;
 
132
        p->filename == other.p->filename &&
 
133
        p->has_thumbnail == other.p->has_thumbnail;
117
134
}
118
135
 
119
136
bool Album::operator!=(const Album &other) const {