Skip to content

Commit 5eb563a

Browse files
author
Robert McNamara
committed
Content API: Add a GetRecordingArtworkList API.
Returns a list of artwork available for a recording by starttime and chanid. This is useful so that you don't have to try each and every type of art for each and every item, you can just see what's available for the recording, and only ask for that. Usage: http://BackendServerIP:6544/Content/GetRecordingArtworkList?Chanid=1234&StartTime=2011-11-10T09:00:00
1 parent c6fc90f commit 5eb563a

File tree

6 files changed

+246
-5
lines changed

6 files changed

+246
-5
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//////////////////////////////////////////////////////////////////////////////
2+
// Program Name: artworkInfo.h
3+
// Created : Nov. 12, 2011
4+
//
5+
// Copyright (c) 2011 Robert McNamara <rmcnamara@mythtv.org>
6+
//
7+
// This library is free software; you can redistribute it and/or
8+
// modify it under the terms of the GNU Lesser General Public
9+
// License as published by the Free Software Foundation; either
10+
// version 2.1 of the License, or at your option any later version of the LGPL.
11+
//
12+
// This library 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 GNU
15+
// Lesser General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU Lesser General Public
18+
// License along with this library. If not, see <http://www.gnu.org/licenses/>.
19+
//
20+
//////////////////////////////////////////////////////////////////////////////
21+
22+
#ifndef ARTWORKINFO_H_
23+
#define ARTWORKINFO_H_
24+
25+
#include <QString>
26+
27+
#include "serviceexp.h"
28+
#include "datacontracthelper.h"
29+
30+
namespace DTC
31+
{
32+
33+
/////////////////////////////////////////////////////////////////////////////
34+
35+
class SERVICE_PUBLIC ArtworkInfo : public QObject
36+
{
37+
Q_OBJECT
38+
Q_CLASSINFO( "version" , "1.0" );
39+
40+
Q_PROPERTY( QString URL READ URL WRITE setURL )
41+
Q_PROPERTY( QString FileName READ FileName WRITE setFileName )
42+
Q_PROPERTY( QString StorageGroup READ StorageGroup WRITE setStorageGroup )
43+
Q_PROPERTY( QString Type READ Type WRITE setType )
44+
45+
PROPERTYIMP ( QString , URL )
46+
PROPERTYIMP ( QString , FileName )
47+
PROPERTYIMP ( QString , StorageGroup )
48+
PROPERTYIMP ( QString , Type )
49+
50+
public:
51+
52+
static void InitializeCustomTypes()
53+
{
54+
qRegisterMetaType< ArtworkInfo >();
55+
qRegisterMetaType< ArtworkInfo* >();
56+
}
57+
58+
public:
59+
60+
ArtworkInfo(QObject *parent = 0)
61+
: QObject ( parent )
62+
{
63+
}
64+
65+
ArtworkInfo( const ArtworkInfo &src )
66+
{
67+
Copy( src );
68+
}
69+
70+
void Copy( const ArtworkInfo &src )
71+
{
72+
m_URL = src.m_URL ;
73+
m_FileName = src.m_FileName ;
74+
m_StorageGroup = src.m_StorageGroup ;
75+
m_Type = src.m_Type ;
76+
}
77+
};
78+
79+
} // namespace DTC
80+
81+
Q_DECLARE_METATYPE( DTC::ArtworkInfo )
82+
Q_DECLARE_METATYPE( DTC::ArtworkInfo* )
83+
84+
#endif
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
//////////////////////////////////////////////////////////////////////////////
2+
// Program Name: artworkInfoList.h
3+
// Created : Nov. 12, 2011
4+
//
5+
// Copyright (c) 2011 Robert McNamara <rmcnamara@mythtv.org>
6+
//
7+
// This library is free software; you can redistribute it and/or
8+
// modify it under the terms of the GNU Lesser General Public
9+
// License as published by the Free Software Foundation; either
10+
// version 2.1 of the License, or at your option any later version of the LGPL.
11+
//
12+
// This library 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 GNU
15+
// Lesser General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU Lesser General Public
18+
// License along with this library. If not, see <http://www.gnu.org/licenses/>.
19+
//
20+
//////////////////////////////////////////////////////////////////////////////
21+
22+
#ifndef ARTWORKINFOLIST_H_
23+
#define ARTWORKINFOLIST_H_
24+
25+
#include <QString>
26+
#include <QVariantList>
27+
28+
#include "serviceexp.h"
29+
#include "datacontracthelper.h"
30+
31+
#include "artworkInfo.h"
32+
33+
namespace DTC
34+
{
35+
36+
class SERVICE_PUBLIC ArtworkInfoList : public QObject
37+
{
38+
Q_OBJECT
39+
Q_CLASSINFO( "version", "1.0" );
40+
41+
// We need to know the type that will ultimately be contained in
42+
// any QVariantList or QVariantMap. We do his by specifying
43+
// A Q_CLASSINFO entry with "<PropName>_type" as the key
44+
// and the type name as the value
45+
46+
Q_CLASSINFO( "ArtworkInfos_type", "DTC::ArtworkInfo");
47+
48+
Q_PROPERTY( QVariantList ArtworkInfos READ ArtworkInfos DESIGNABLE true )
49+
50+
PROPERTYIMP_RO_REF( QVariantList, ArtworkInfos )
51+
52+
public:
53+
54+
static void InitializeCustomTypes()
55+
{
56+
qRegisterMetaType< ArtworkInfoList >();
57+
qRegisterMetaType< ArtworkInfoList* >();
58+
59+
ArtworkInfo::InitializeCustomTypes();
60+
}
61+
62+
public:
63+
64+
ArtworkInfoList(QObject *parent = 0)
65+
: QObject ( parent )
66+
{
67+
}
68+
69+
ArtworkInfoList( const ArtworkInfoList &src )
70+
{
71+
Copy( src );
72+
}
73+
74+
void Copy( const ArtworkInfoList &src )
75+
{
76+
CopyListContents< ArtworkInfo >( this, m_ArtworkInfos, src.m_ArtworkInfos );
77+
}
78+
79+
ArtworkInfo *AddNewArtworkInfo()
80+
{
81+
// We must make sure the object added to the QVariantList has
82+
// a parent of 'this'
83+
84+
ArtworkInfo *pObject = new ArtworkInfo( this );
85+
m_ArtworkInfos.append( QVariant::fromValue<QObject *>( pObject ));
86+
87+
return pObject;
88+
}
89+
90+
};
91+
92+
} // namespace DTC
93+
94+
Q_DECLARE_METATYPE( DTC::ArtworkInfoList )
95+
Q_DECLARE_METATYPE( DTC::ArtworkInfoList* )
96+
97+
#endif

mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ HEADERS += datacontracts/timeZoneInfo.h datacontracts/videoLookupInfo.h
3434
HEADERS += datacontracts/videoLookupInfoList.h datacontracts/versionInfo.h
3535
HEADERS += datacontracts/lineup.h datacontracts/captureCard.h
3636
HEADERS += datacontracts/captureCardList.h datacontracts/recRule.h
37-
HEADERS += datacontracts/recRuleList.h
38-
HEADERS += datacontracts/frontendStatus.h
37+
HEADERS += datacontracts/recRuleList.h datacontracts/artworkInfo.h
38+
HEADERS += datacontracts/artworkInfoList.h datacontracts/frontendStatus.h
3939
HEADERS += datacontracts/frontendActionList.h
4040

4141
SOURCES += service.cpp
@@ -71,8 +71,8 @@ incDatacontracts.files += datacontracts/timeZoneInfo.h datacontracts/vide
7171
incDatacontracts.files += datacontracts/versionInfo.h datacontracts/lineup.h
7272
incDatacontracts.files += datacontracts/captureCard.h datacontracts/captureCardList.h
7373
incDatacontracts.files += datacontracts/recRule.h datacontracts/recRuleList.h
74-
incDatacontracts.files += datacontracts/frontendStatus.h
75-
incDatacontracts.files += datacontracts/frontendActionList.h
74+
incDatacontracts.files += datacontracts/artworkInfo.h datacontracts/artworkInfoList.h
75+
incDatacontracts.files += datacontracts/frontendStatus.h datacontracts/frontendActionList.h
7676

7777
INSTALLS += inc incServices incDatacontracts
7878

mythtv/libs/libmythservicecontracts/services/contentServices.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <QStringList>
2929

3030
#include "service.h"
31+
#include "datacontracts/artworkInfoList.h"
3132

3233
/////////////////////////////////////////////////////////////////////////////
3334
/////////////////////////////////////////////////////////////////////////////
@@ -48,7 +49,7 @@
4849
class SERVICE_PUBLIC ContentServices : public Service //, public QScriptable ???
4950
{
5051
Q_OBJECT
51-
Q_CLASSINFO( "version" , "1.3" );
52+
Q_CLASSINFO( "version" , "1.31" );
5253
Q_CLASSINFO( "DownloadFile_Method", "POST" )
5354

5455
public:
@@ -58,6 +59,7 @@ class SERVICE_PUBLIC ContentServices : public Service //, public QScriptable ??
5859

5960
ContentServices( QObject *parent = 0 ) : Service( parent )
6061
{
62+
DTC::ArtworkInfoList::InitializeCustomTypes();
6163
}
6264

6365
public slots:
@@ -76,6 +78,10 @@ class SERVICE_PUBLIC ContentServices : public Service //, public QScriptable ??
7678
int Season, int Width,
7779
int Height ) = 0;
7880

81+
virtual DTC::ArtworkInfoList*
82+
GetRecordingArtworkList( int ChanId,
83+
const QDateTime &StartTime ) = 0;
84+
7985
virtual QFileInfo GetVideoArtwork ( const QString &Type,
8086
int Id, int Width,
8187
int Height ) = 0;

mythtv/programs/mythbackend/services/content.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,56 @@ QFileInfo Content::GetRecordingArtwork ( const QString &sType,
255255
//
256256
/////////////////////////////////////////////////////////////////////////////
257257

258+
DTC::ArtworkInfoList* Content::GetRecordingArtworkList( int nChanId,
259+
const QDateTime &dStartTime )
260+
{
261+
if (nChanId <= 0 || !dStartTime.isValid())
262+
throw( QString("Channel ID or StartTime appears invalid."));
263+
264+
ProgramInfo *pInfo = new ProgramInfo(nChanId, dStartTime);
265+
ArtworkMap map = GetArtwork(pInfo->GetInetRef(), pInfo->GetSeason());
266+
267+
DTC::ArtworkInfoList *pInfos = new DTC::ArtworkInfoList();
268+
269+
for (ArtworkMap::const_iterator i = map.begin();
270+
i != map.end(); ++i)
271+
{
272+
DTC::ArtworkInfo *pArtInfo = pInfos->AddNewArtworkInfo();
273+
pArtInfo->setFileName(i.value().url);
274+
switch (i.key())
275+
{
276+
case kArtworkFanart:
277+
pArtInfo->setStorageGroup("Fanart");
278+
pArtInfo->setType("fanart");
279+
pArtInfo->setURL(QString("/Content/GetRecordingArtwork?InetRef=%1"
280+
"&Season=%2&Type=fanart").arg(pInfo->GetInetRef())
281+
.arg(pInfo->GetSeason()));
282+
// LOG(VB_GENERAL, LOG_ERR, QString("Type: %1 URL: %2").arg(pArtInfo->Type()).arg(pArtInfo->URL()));
283+
break;
284+
case kArtworkBanner:
285+
pArtInfo->setStorageGroup("Banners");
286+
pArtInfo->setType("banner");
287+
pArtInfo->setURL(QString("/Content/GetRecordingArtwork?InetRef=%1"
288+
"&Season=%2&Type=banner").arg(pInfo->GetInetRef())
289+
.arg(pInfo->GetSeason()));
290+
break;
291+
case kArtworkCoverart:
292+
default:
293+
pArtInfo->setStorageGroup("Coverart");
294+
pArtInfo->setType("coverart");
295+
pArtInfo->setURL(QString("/Content/GetRecordingArtwork?InetRef=%1"
296+
"&Season=%2&Type=coverart").arg(pInfo->GetInetRef())
297+
.arg(pInfo->GetSeason()));
298+
break;
299+
}
300+
}
301+
delete pInfo;
302+
return pInfos;
303+
}
304+
/////////////////////////////////////////////////////////////////////////////
305+
//
306+
/////////////////////////////////////////////////////////////////////////////
307+
258308
QFileInfo Content::GetVideoArtwork( const QString &sType,
259309
int nId, int nWidth, int nHeight )
260310
{

mythtv/programs/mythbackend/services/content.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class Content : public ContentServices
5050
int Season, int Width,
5151
int Height);
5252

53+
DTC::ArtworkInfoList*
54+
GetRecordingArtworkList( int ChanId,
55+
const QDateTime &StartTime );
56+
5357
QFileInfo GetVideoArtwork ( const QString &Type,
5458
int Id, int Width, int Height );
5559

0 commit comments

Comments
 (0)