Added podcast support, only from subsonic API for now, ref #726

This commit is contained in:
emeric
2025-09-13 15:04:13 +02:00
parent 1d584ebcc6
commit 932e7715f5
111 changed files with 4717 additions and 188 deletions
+23
View File
@@ -84,4 +84,27 @@ namespace lms::db::tests
EXPECT_EQ(artwork.get()->getAbsoluteFilePath(), "/tmp/foo");
}
}
TEST_F(DatabaseFixture, Artwork_underlyingId)
{
ScopedImage image1{ session, "/MyImage" };
ScopedArtwork artwork1{ session, image1.lockAndGet() };
ScopedTrackEmbeddedImage image2{ session };
ScopedArtwork artwork2{ session, image2.lockAndGet() };
{
auto transaction{ session.createReadTransaction() };
const auto underlyingId{ artwork1.get()->getUnderlyingId() };
ASSERT_TRUE(std::holds_alternative<db::ImageId>(underlyingId));
EXPECT_EQ(std::get<db::ImageId>(underlyingId), image1.getId());
}
{
auto transaction{ session.createReadTransaction() };
const auto underlyingId{ artwork2.get()->getUnderlyingId() };
ASSERT_TRUE(std::holds_alternative<db::TrackEmbeddedImageId>(underlyingId));
EXPECT_EQ(std::get<db::TrackEmbeddedImageId>(underlyingId), image2.getId());
}
}
} // namespace lms::db::tests
+1
View File
@@ -13,6 +13,7 @@ add_executable(test-database
Medium.cpp
Migration.cpp
PlayListFile.cpp
Podcast.cpp
RatedArtist.cpp
RatedRelease.cpp
RatedTrack.cpp
+4
View File
@@ -28,6 +28,8 @@
#include "database/objects/Medium.hpp"
#include "database/objects/PlayListFile.hpp"
#include "database/objects/PlayQueue.hpp"
#include "database/objects/Podcast.hpp"
#include "database/objects/PodcastEpisode.hpp"
#include "database/objects/RatedArtist.hpp"
#include "database/objects/RatedRelease.hpp"
#include "database/objects/RatedTrack.hpp"
@@ -359,6 +361,8 @@ VALUES
EXPECT_FALSE(Listen::find(session, ListenId{}));
EXPECT_FALSE(PlayListFile::find(session, PlayListFileId{}));
EXPECT_FALSE(PlayQueue::find(session, PlayQueueId{}));
EXPECT_FALSE(Podcast::find(session, PodcastId{}));
EXPECT_FALSE(PodcastEpisode::find(session, PodcastEpisodeId{}));
EXPECT_FALSE(RatedArtist::find(session, RatedArtistId{}));
EXPECT_FALSE(RatedRelease::find(session, RatedReleaseId{}));
EXPECT_FALSE(RatedTrack::find(session, RatedTrackId{}));
+99
View File
@@ -0,0 +1,99 @@
/*
* Copyright (C) 2025 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Common.hpp"
#include "database/objects/Artwork.hpp"
#include "database/objects/Podcast.hpp"
namespace lms::db::tests
{
using ScopedDirectory = ScopedEntity<db::Directory>;
using ScopedPodcast = ScopedEntity<db::Podcast>;
TEST_F(DatabaseFixture, Podcast)
{
{
auto transaction{ session.createReadTransaction() };
EXPECT_EQ(Podcast::getCount(session), 0);
}
ScopedPodcast podcast{ session, "podcastUrl" };
{
auto transaction{ session.createReadTransaction() };
EXPECT_EQ(Podcast::getCount(session), 1);
Podcast::pointer p{ Podcast::find(session, podcast.getId()) };
ASSERT_NE(p, Podcast::pointer{});
EXPECT_EQ(p->getUrl(), "podcastUrl");
EXPECT_EQ(p->getTitle(), "");
EXPECT_EQ(p->getLink(), "");
EXPECT_EQ(p->getDescription(), "");
EXPECT_EQ(p->getLanguage(), "");
EXPECT_EQ(p->getCopyright(), "");
EXPECT_EQ(p->getLastBuildDate(), Wt::WDateTime());
EXPECT_EQ(p->getAuthor(), "");
EXPECT_EQ(p->getCategory(), "");
EXPECT_EQ(p->isExplicit(), false);
EXPECT_EQ(p->getImageUrl(), "");
EXPECT_EQ(p->getOwnerEmail(), "");
}
{
auto transaction{ session.createWriteTransaction() };
Podcast::pointer p{ Podcast::find(session, podcast.getId()) };
ASSERT_NE(p, Podcast::pointer{});
p.modify()->setUrl("newPodcastUrl");
p.modify()->setTitle("newTitle");
p.modify()->setLink("newLink");
p.modify()->setDescription("newDescription");
p.modify()->setLanguage("newLanguage");
p.modify()->setCopyright("newCopyright");
p.modify()->setLastBuildDate(Wt::WDateTime::currentDateTime());
p.modify()->setAuthor("newAuthor");
p.modify()->setCategory("newCategory");
p.modify()->setExplicit(true);
p.modify()->setImageUrl("newImageUrl");
p.modify()->setOwnerEmail("newOwnerEmail");
p.modify()->setOwnerName("newOwnerName");
}
{
auto transaction{ session.createReadTransaction() };
Podcast::pointer img{ Podcast::find(session, podcast.getId()) };
ASSERT_NE(img, Podcast::pointer{});
EXPECT_EQ(img->getUrl(), "newPodcastUrl");
EXPECT_EQ(img->getTitle(), "newTitle");
EXPECT_EQ(img->getLink(), "newLink");
EXPECT_EQ(img->getDescription(), "newDescription");
EXPECT_EQ(img->getLanguage(), "newLanguage");
EXPECT_EQ(img->getCopyright(), "newCopyright");
EXPECT_TRUE(img->getLastBuildDate().isValid());
EXPECT_EQ(img->getAuthor(), "newAuthor");
EXPECT_EQ(img->getCategory(), "newCategory");
EXPECT_TRUE(img->isExplicit());
EXPECT_EQ(img->getImageUrl(), "newImageUrl");
EXPECT_EQ(img->getOwnerEmail(), "newOwnerEmail");
EXPECT_EQ(img->getOwnerName(), "newOwnerName");
}
}
} // namespace lms::db::tests