00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00022 #include <QUrl>
00023
00024 #include "serviceUtil.h"
00025
00026 #include "programinfo.h"
00027 #include "recordinginfo.h"
00028 #include "recordingtypes.h"
00029 #include "channelutil.h"
00030 #include "videoutils.h"
00031 #include "metadataimagehelper.h"
00032
00034
00036
00037 void FillProgramInfo( DTC::Program *pProgram,
00038 ProgramInfo *pInfo,
00039 bool bIncChannel ,
00040 bool bDetails )
00041 {
00042 if ((pProgram == NULL) || (pInfo == NULL))
00043 return;
00044
00045 pProgram->setStartTime ( pInfo->GetScheduledStartTime());
00046 pProgram->setEndTime ( pInfo->GetScheduledEndTime ());
00047 pProgram->setTitle ( pInfo->GetTitle() );
00048 pProgram->setSubTitle ( pInfo->GetSubtitle() );
00049 pProgram->setCategory ( pInfo->GetCategory() );
00050 pProgram->setCatType ( pInfo->GetCategoryType() );
00051 pProgram->setRepeat ( pInfo->IsRepeat() );
00052 pProgram->setVideoProps( pInfo->GetVideoProperties() );
00053 pProgram->setAudioProps( pInfo->GetAudioProperties() );
00054 pProgram->setSubProps ( pInfo->GetSubtitleType() );
00055
00056 pProgram->setSerializeDetails( bDetails );
00057
00058 if (bDetails)
00059 {
00060 pProgram->setSeriesId ( pInfo->GetSeriesID() );
00061 pProgram->setProgramId ( pInfo->GetProgramID() );
00062 pProgram->setStars ( pInfo->GetStars() );
00063 pProgram->setFileSize ( pInfo->GetFilesize() );
00064 pProgram->setLastModified( pInfo->GetLastModifiedTime() );
00065 pProgram->setProgramFlags( pInfo->GetProgramFlags() );
00066 pProgram->setFileName ( pInfo->GetPathname() );
00067 pProgram->setHostName ( pInfo->GetHostname() );
00068
00069 if (pInfo->GetOriginalAirDate().isValid())
00070 pProgram->setAirdate( pInfo->GetOriginalAirDate() );
00071
00072 pProgram->setDescription( pInfo->GetDescription() );
00073 pProgram->setInetref ( pInfo->GetInetRef() );
00074 pProgram->setSeason ( pInfo->GetSeason() );
00075 pProgram->setEpisode ( pInfo->GetEpisode() );
00076 }
00077
00078 pProgram->setSerializeChannel( bIncChannel );
00079
00080 if ( bIncChannel )
00081 {
00082
00083
00084 FillChannelInfo( pProgram->Channel(), pInfo, bDetails );
00085 }
00086
00087
00088
00089 if ( pInfo->GetRecordingStatus() != rsUnknown )
00090 {
00091 pProgram->setSerializeRecording( true );
00092
00093 DTC::RecordingInfo *pRecording = pProgram->Recording();
00094
00095 pRecording->setStatus ( pInfo->GetRecordingStatus() );
00096 pRecording->setPriority( pInfo->GetRecordingPriority() );
00097 pRecording->setStartTs ( pInfo->GetRecordingStartTime() );
00098 pRecording->setEndTs ( pInfo->GetRecordingEndTime() );
00099
00100 pRecording->setSerializeDetails( bDetails );
00101
00102 if (bDetails)
00103 {
00104 pRecording->setRecordId ( pInfo->GetRecordingRuleID() );
00105 pRecording->setRecGroup ( pInfo->GetRecordingGroup() );
00106 pRecording->setPlayGroup ( pInfo->GetPlaybackGroup() );
00107 pRecording->setStorageGroup( pInfo->GetStorageGroup() );
00108 pRecording->setRecType ( pInfo->GetRecordingRuleType() );
00109 pRecording->setDupInType ( pInfo->GetDuplicateCheckSource() );
00110 pRecording->setDupMethod ( pInfo->GetDuplicateCheckMethod() );
00111 pRecording->setEncoderId ( pInfo->GetCardID() );
00112
00113 const RecordingInfo ri(*pInfo);
00114 pRecording->setProfile( ri.GetProgramRecordingProfile() );
00115 }
00116 }
00117
00118 if (!pInfo->GetInetRef().isEmpty() )
00119 {
00120 pProgram->setSerializeArtwork( true );
00121
00122 FillArtworkInfoList( pProgram->Artwork(), pInfo->GetInetRef(),
00123 pInfo->GetSeason());
00124 }
00125 }
00126
00128
00130
00131 void FillChannelInfo( DTC::ChannelInfo *pChannel,
00132 ProgramInfo *pInfo,
00133 bool bDetails )
00134 {
00135 if (pInfo)
00136 {
00137 if (!ChannelUtil::GetIcon(pInfo->GetChanID()).isEmpty())
00138 {
00139 QString sIconURL = QString( "/Guide/GetChannelIcon?ChanId=%3")
00140 .arg( pInfo->GetChanID() );
00141 pChannel->setIconURL ( sIconURL );
00142 }
00143
00144 pChannel->setChanId ( pInfo->GetChanID() );
00145 pChannel->setChanNum ( pInfo->GetChanNum() );
00146 pChannel->setCallSign ( pInfo->GetChannelSchedulingID() );
00147 pChannel->setChannelName( pInfo->GetChannelName() );
00148
00149 pChannel->setSerializeDetails( bDetails );
00150
00151 if (bDetails)
00152 {
00153 pChannel->setChanFilters( pInfo->GetChannelPlaybackFilters() );
00154 pChannel->setSourceId ( pInfo->GetSourceID() );
00155 pChannel->setInputId ( pInfo->GetInputID() );
00156 pChannel->setCommFree ( (pInfo->IsCommercialFree()) ? 1 : 0);
00157 }
00158 }
00159
00160 }
00161
00163
00165
00166 void FillRecRuleInfo( DTC::RecRule *pRecRule,
00167 RecordingRule *pRule )
00168 {
00169 if ((pRecRule == NULL) || (pRule == NULL))
00170 return;
00171
00172 pRecRule->setId ( pRule->m_recordID );
00173 pRecRule->setParentId ( pRule->m_parentRecID );
00174 pRecRule->setInactive ( pRule->m_isInactive );
00175 pRecRule->setTitle ( pRule->m_title );
00176 pRecRule->setSubTitle ( pRule->m_subtitle );
00177 pRecRule->setDescription ( pRule->m_description );
00178 pRecRule->setSeason ( pRule->m_season );
00179 pRecRule->setEpisode ( pRule->m_episode );
00180 pRecRule->setCategory ( pRule->m_category );
00181 pRecRule->setStartTime ( QDateTime(pRule->m_startdate,
00182 pRule->m_starttime) );
00183 pRecRule->setEndTime ( QDateTime(pRule->m_enddate,
00184 pRule->m_endtime) );
00185 pRecRule->setSeriesId ( pRule->m_seriesid );
00186 pRecRule->setProgramId ( pRule->m_programid );
00187 pRecRule->setInetref ( pRule->m_inetref );
00188 pRecRule->setChanId ( pRule->m_channelid );
00189 pRecRule->setCallSign ( pRule->m_station );
00190 pRecRule->setDay ( pRule->m_findday );
00191 pRecRule->setTime ( pRule->m_findtime );
00192 pRecRule->setFindId ( pRule->m_findid );
00193 pRecRule->setType ( toRawString(pRule->m_type) );
00194 pRecRule->setSearchType ( toRawString(pRule->m_searchType));
00195 pRecRule->setRecPriority ( pRule->m_recPriority );
00196 pRecRule->setPreferredInput ( pRule->m_prefInput );
00197 pRecRule->setStartOffset ( pRule->m_startOffset );
00198 pRecRule->setEndOffset ( pRule->m_endOffset );
00199 pRecRule->setDupMethod ( toRawString(pRule->m_dupMethod) );
00200 pRecRule->setDupIn ( toRawString(pRule->m_dupIn) );
00201 pRecRule->setFilter ( pRule->m_filter );
00202 pRecRule->setRecProfile ( pRule->m_recProfile );
00203 pRecRule->setRecGroup ( pRule->m_recGroup );
00204 pRecRule->setStorageGroup ( pRule->m_storageGroup );
00205 pRecRule->setPlayGroup ( pRule->m_playGroup );
00206 pRecRule->setAutoExpire ( pRule->m_autoExpire );
00207 pRecRule->setMaxEpisodes ( pRule->m_maxEpisodes );
00208 pRecRule->setMaxNewest ( pRule->m_maxNewest );
00209 pRecRule->setAutoCommflag ( pRule->m_autoCommFlag );
00210 pRecRule->setAutoTranscode ( pRule->m_autoTranscode );
00211 pRecRule->setAutoMetaLookup ( pRule->m_autoMetadataLookup );
00212 pRecRule->setAutoUserJob1 ( pRule->m_autoUserJob1 );
00213 pRecRule->setAutoUserJob2 ( pRule->m_autoUserJob2 );
00214 pRecRule->setAutoUserJob3 ( pRule->m_autoUserJob3 );
00215 pRecRule->setAutoUserJob4 ( pRule->m_autoUserJob4 );
00216 pRecRule->setTranscoder ( pRule->m_transcoder );
00217 pRecRule->setNextRecording ( pRule->m_nextRecording );
00218 pRecRule->setLastRecorded ( pRule->m_lastRecorded );
00219 pRecRule->setLastDeleted ( pRule->m_lastDeleted );
00220 pRecRule->setAverageDelay ( pRule->m_averageDelay );
00221 }
00222
00224
00226
00227 void FillArtworkInfoList( DTC::ArtworkInfoList *pArtworkInfoList,
00228 const QString &sInetref,
00229 uint nSeason )
00230 {
00231 ArtworkMap map = GetArtwork(sInetref, nSeason);
00232
00233 for (ArtworkMap::const_iterator i = map.begin();
00234 i != map.end(); ++i)
00235 {
00236 DTC::ArtworkInfo *pArtInfo = pArtworkInfoList->AddNewArtworkInfo();
00237 pArtInfo->setFileName(i.value().url);
00238 switch (i.key())
00239 {
00240 case kArtworkFanart:
00241 pArtInfo->setStorageGroup("Fanart");
00242 pArtInfo->setType("fanart");
00243 pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
00244 "&FileName=%2").arg("Fanart")
00245 .arg(QUrl(i.value().url).path()));
00246 break;
00247 case kArtworkBanner:
00248 pArtInfo->setStorageGroup("Banners");
00249 pArtInfo->setType("banner");
00250 pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
00251 "&FileName=%2").arg("Banners")
00252 .arg(QUrl(i.value().url).path()));
00253 break;
00254 case kArtworkCoverart:
00255 default:
00256 pArtInfo->setStorageGroup("Coverart");
00257 pArtInfo->setType("coverart");
00258 pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
00259 "&FileName=%2").arg("Coverart")
00260 .arg(QUrl(i.value().url).path()));
00261 break;
00262 }
00263 }
00264 }
00265
00267
00269
00270 void FillVideoMetadataInfo (
00271 DTC::VideoMetadataInfo *pVideoMetadataInfo,
00272 VideoMetadataListManager::VideoMetadataPtr pMetadata,
00273 bool bDetails)
00274 {
00275 pVideoMetadataInfo->setId(pMetadata->GetID());
00276 pVideoMetadataInfo->setTitle(pMetadata->GetTitle());
00277 pVideoMetadataInfo->setSubTitle(pMetadata->GetSubtitle());
00278 pVideoMetadataInfo->setTagline(pMetadata->GetTagline());
00279 pVideoMetadataInfo->setDirector(pMetadata->GetDirector());
00280 pVideoMetadataInfo->setStudio(pMetadata->GetStudio());
00281 pVideoMetadataInfo->setDescription(pMetadata->GetPlot());
00282 pVideoMetadataInfo->setCertification(pMetadata->GetRating());
00283 pVideoMetadataInfo->setInetref(pMetadata->GetInetRef());
00284 pVideoMetadataInfo->setCollectionref(pMetadata->GetCollectionRef());
00285 pVideoMetadataInfo->setHomePage(pMetadata->GetHomepage());
00286 pVideoMetadataInfo->setReleaseDate(QDateTime(pMetadata->GetReleaseDate()));
00287 pVideoMetadataInfo->setAddDate(QDateTime(pMetadata->GetInsertdate()));
00288 pVideoMetadataInfo->setUserRating(pMetadata->GetUserRating());
00289 pVideoMetadataInfo->setLength(pMetadata->GetLength());
00290 pVideoMetadataInfo->setPlayCount(pMetadata->GetPlayCount());
00291 pVideoMetadataInfo->setSeason(pMetadata->GetSeason());
00292 pVideoMetadataInfo->setEpisode(pMetadata->GetEpisode());
00293 pVideoMetadataInfo->setParentalLevel(pMetadata->GetShowLevel());
00294 pVideoMetadataInfo->setVisible(pMetadata->GetBrowse());
00295 pVideoMetadataInfo->setWatched(pMetadata->GetWatched());
00296 pVideoMetadataInfo->setProcessed(pMetadata->GetProcessed());
00297 pVideoMetadataInfo->setContentType(ContentTypeToString(
00298 pMetadata->GetContentType()));
00299 pVideoMetadataInfo->setFileName(pMetadata->GetFilename());
00300 pVideoMetadataInfo->setHash(pMetadata->GetHash());
00301 pVideoMetadataInfo->setHostName(pMetadata->GetHost());
00302 pVideoMetadataInfo->setCoverart(pMetadata->GetCoverFile());
00303 pVideoMetadataInfo->setFanart(pMetadata->GetFanart());
00304 pVideoMetadataInfo->setBanner(pMetadata->GetBanner());
00305 pVideoMetadataInfo->setScreenshot(pMetadata->GetScreenshot());
00306 pVideoMetadataInfo->setTrailer(pMetadata->GetTrailer());
00307 pVideoMetadataInfo->setSerializeArtwork( true );
00308
00309 if (bDetails)
00310 {
00311 if (!pMetadata->GetFanart().isEmpty())
00312 {
00313 DTC::ArtworkInfo *pArtInfo =
00314 pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
00315 pArtInfo->setStorageGroup("Fanart");
00316 pArtInfo->setType("fanart");
00317 pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
00318 "&FileName=%2").arg("Fanart")
00319 .arg(pMetadata->GetFanart()));
00320 }
00321 if (!pMetadata->GetCoverFile().isEmpty())
00322 {
00323 DTC::ArtworkInfo *pArtInfo =
00324 pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
00325 pArtInfo->setStorageGroup("Coverart");
00326 pArtInfo->setType("coverart");
00327 pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
00328 "&FileName=%2").arg("Coverart")
00329 .arg(pMetadata->GetCoverFile()));
00330 }
00331 if (!pMetadata->GetBanner().isEmpty())
00332 {
00333 DTC::ArtworkInfo *pArtInfo =
00334 pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
00335 pArtInfo->setStorageGroup("Banners");
00336 pArtInfo->setType("banner");
00337 pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
00338 "&FileName=%2").arg("Banners")
00339 .arg(pMetadata->GetBanner()));
00340 }
00341 if (!pMetadata->GetScreenshot().isEmpty())
00342 {
00343 DTC::ArtworkInfo *pArtInfo =
00344 pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
00345 pArtInfo->setStorageGroup("Screenshots");
00346 pArtInfo->setType("screenshot");
00347 pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
00348 "&FileName=%2").arg("Screenshots")
00349 .arg(pMetadata->GetScreenshot()));
00350 }
00351 }
00352 }