Detect if local file is actually a podcast
This commit is contained in:
committed by
craig.p.drummond
parent
7680e19374
commit
a8807d4e93
@@ -51,6 +51,7 @@
|
||||
#include "mpdconnection.h"
|
||||
#ifdef ENABLE_ONLINE_SERVICES
|
||||
#include "online/onlineservice.h"
|
||||
#include "online/podcastservice.h"
|
||||
#endif
|
||||
|
||||
#include <QDebug>
|
||||
@@ -403,6 +404,14 @@ Song MPDParseUtils::parseSong(const QList<QByteArray> &lines, Location location)
|
||||
}
|
||||
song.file=origFile;
|
||||
song.setKey(location);
|
||||
|
||||
#ifdef ENABLE_ONLINE_SERVICES
|
||||
// Check for downloaded podcasts played via local file playback
|
||||
if (Song::OnlineSvrTrack!=song.type && PodcastService::isPodcastFile(song.file)) {
|
||||
song.setIsFromOnlineService(PodcastService::constName);
|
||||
song.albumartist=song.artist=PodcastService::constName;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return song;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,18 @@ static const char * constRssUrlProperty="rss-url";
|
||||
static const char * constDestProperty="dest";
|
||||
static const QLatin1String constPartialExt(".partial");
|
||||
|
||||
bool PodcastService::isPodcastFile(const QString &file)
|
||||
{
|
||||
if (file.startsWith(Utils::constDirSep) && MPDConnection::self()->getDetails().isLocal()) {
|
||||
QString downloadPath=Settings::self()->podcastDownloadPath();
|
||||
if (downloadPath.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return file.startsWith(downloadPath);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QUrl PodcastService::fixUrl(const QString &url)
|
||||
{
|
||||
QString trimmed(url.trimmed());
|
||||
@@ -108,7 +120,7 @@ Song PodcastService::fixPath(const Song &orig, bool) const
|
||||
Song song=orig;
|
||||
song.setPodcastLocalPath(QString());
|
||||
song.setIsFromOnlineService(constName);
|
||||
song.album=constName;
|
||||
song.artist=constName;
|
||||
if (!orig.podcastLocalPath().isEmpty() && QFile::exists(orig.podcastLocalPath())) {
|
||||
if (!HttpServer::self()->forceUsage() && MPDConnection::self()->getDetails().isLocal()) {
|
||||
song.file=QLatin1String("file://")+orig.podcastLocalPath();
|
||||
@@ -190,7 +202,6 @@ void PodcastService::rssJobFinished()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MusicLibraryItemPodcast *podcast=new MusicLibraryItemPodcast(QString(), this);
|
||||
MusicLibraryItemPodcast::RssStatus loadStatus=podcast->loadRss(j->actualJob());
|
||||
if (MusicLibraryItemPodcast::Loaded==loadStatus) {
|
||||
@@ -698,16 +709,7 @@ void PodcastService::updateRss()
|
||||
|
||||
void PodcastService::currentMpdSong(const Song &s)
|
||||
{
|
||||
bool check=s.isFromOnlineService() && s.album==constName;
|
||||
|
||||
if (!check && s.file.startsWith(Utils::constDirSep) && MPDConnection::self()->getDetails().isLocal()) {
|
||||
QString downloadPath=Settings::self()->podcastDownloadPath();
|
||||
if (downloadPath.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
check=s.file.startsWith(downloadPath);
|
||||
}
|
||||
if (check) {
|
||||
if ((s.isFromOnlineService() && s.album==constName) || isPodcastFile(s.file)) {
|
||||
QString path=s.decodedPath();
|
||||
if (path.isEmpty()) {
|
||||
path=s.file;
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
void refreshSubscription(MusicLibraryItem *item);
|
||||
bool processingUrl(const QUrl &url) const;
|
||||
void addUrl(const QUrl &url, bool isNew=true);
|
||||
static bool isPodcastFile(const QString &file);
|
||||
static const QString & iconPath() { return iconFile; }
|
||||
static QUrl fixUrl(const QString &url);
|
||||
static QUrl fixUrl(const QUrl &orig);
|
||||
|
||||
Reference in New Issue
Block a user