MythTV  master
serviceUtil.cpp
Go to the documentation of this file.
1 // Program Name: serviceUtil.cpp
3 // Created : Mar. 7, 2011
4 //
5 // Copyright (c) 2011 David Blain <dblain@mythtv.org>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program 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
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //
25 
26 #include <QUrl>
27 
28 #include "serviceUtil.h"
29 
30 #include "programinfo.h"
31 #include "recordinginfo.h"
32 #include "recordingtypes.h"
33 #include "channelutil.h"
34 #include "channelinfo.h"
35 #include "videoutils.h"
36 #include "metadataimagehelper.h"
37 #include "cardutil.h"
38 #include "datacontracts/cutList.h"
39 
41 //
43 
44 void FillProgramInfo( DTC::Program *pProgram,
45  ProgramInfo *pInfo,
46  bool bIncChannel /* = true */,
47  bool bDetails /* = true */,
48  bool bIncCast /* = true */)
49 {
50  if ((pProgram == nullptr) || (pInfo == nullptr))
51  return;
52 
53  pProgram->setStartTime ( pInfo->GetScheduledStartTime());
54  pProgram->setEndTime ( pInfo->GetScheduledEndTime ());
55  pProgram->setTitle ( pInfo->GetTitle() );
56  pProgram->setSubTitle ( pInfo->GetSubtitle() );
57  pProgram->setCategory ( pInfo->GetCategory() );
58  pProgram->setCatType ( pInfo->GetCategoryTypeString());
59  pProgram->setRepeat ( pInfo->IsRepeat() );
60  pProgram->setVideoProps( pInfo->GetVideoProperties() );
61  pProgram->setAudioProps( pInfo->GetAudioProperties() );
62  pProgram->setSubProps ( pInfo->GetSubtitleType() );
63 
64  pProgram->setSerializeDetails( bDetails );
65 
66  if (bDetails)
67  {
68  pProgram->setSeriesId ( pInfo->GetSeriesID() );
69  pProgram->setProgramId ( pInfo->GetProgramID() );
70  pProgram->setStars ( pInfo->GetStars() );
71  pProgram->setLastModified( pInfo->GetLastModifiedTime() );
72  pProgram->setProgramFlags( pInfo->GetProgramFlags() );
73 
74  // ----
75  // DEPRECATED - See RecordingInfo instead
76  pProgram->setFileName ( pInfo->GetPathname() );
77  pProgram->setFileSize ( pInfo->GetFilesize() );
78  pProgram->setHostName ( pInfo->GetHostname() );
79  // ----
80 
81  if (pInfo->GetOriginalAirDate().isValid())
82  pProgram->setAirdate( pInfo->GetOriginalAirDate() );
83  else if (pInfo->GetYearOfInitialRelease() > 0)
84  {
85  QDate year;
86  year.setDate(pInfo->GetYearOfInitialRelease(), 1, 1);
87  pProgram->setAirdate( year );
88  }
89 
90  pProgram->setDescription( pInfo->GetDescription() );
91  pProgram->setInetref ( pInfo->GetInetRef() );
92  pProgram->setSeason ( pInfo->GetSeason() );
93  pProgram->setEpisode ( pInfo->GetEpisode() );
94  pProgram->setTotalEpisodes( pInfo->GetEpisodeTotal() );
95  }
96 
97  pProgram->setSerializeCast(bIncCast);
98  if (bIncCast)
99  {
100  FillCastMemberList( pProgram->Cast(), pInfo );
101  }
102 
103  pProgram->setSerializeChannel( bIncChannel );
104 
105  if ( bIncChannel )
106  {
107  // Build Channel Child Element
108  if (!FillChannelInfo( pProgram->Channel(), pInfo->GetChanID(), bDetails ))
109  {
110  // The channel associated with a given recording may no longer exist
111  // however the ChanID is one half of the unique identifier for the
112  // recording and therefore MUST be included in the return data
113  pProgram->Channel()->setChanId(pInfo->GetChanID());
114  }
115  }
116 
117  // Build Recording Child Element
118 
119  if ( pInfo->GetRecordingStatus() != RecStatus::Unknown )
120  {
121  pProgram->setSerializeRecording( true );
122 
123  DTC::RecordingInfo *pRecording = pProgram->Recording();
124 
125  const RecordingInfo pRecInfo(*pInfo);
126 
127  pRecording->setRecordedId ( pRecInfo.GetRecordingID() );
128  pRecording->setStatus ( pRecInfo.GetRecordingStatus() );
129  pRecording->setPriority( pRecInfo.GetRecordingPriority() );
130  pRecording->setStartTs ( pRecInfo.GetRecordingStartTime() );
131  pRecording->setEndTs ( pRecInfo.GetRecordingEndTime() );
132 
133  pRecording->setSerializeDetails( bDetails );
134 
135  if (bDetails)
136  {
137  pRecording->setFileName ( pRecInfo.GetPathname() );
138  pRecording->setFileSize ( pRecInfo.GetFilesize() );
139  pRecording->setHostName ( pRecInfo.GetHostname() );
140  pRecording->setLastModified( pRecInfo.GetLastModifiedTime() );
141 
142  pRecording->setRecordId ( pRecInfo.GetRecordingRuleID() );
143  pRecording->setRecGroup ( pRecInfo.GetRecordingGroup() );
144  pRecording->setPlayGroup ( pRecInfo.GetPlaybackGroup() );
145  pRecording->setStorageGroup( pRecInfo.GetStorageGroup() );
146  pRecording->setRecType ( pRecInfo.GetRecordingRuleType() );
147  pRecording->setDupInType ( pRecInfo.GetDuplicateCheckSource() );
148  pRecording->setDupMethod ( pRecInfo.GetDuplicateCheckMethod() );
149  pRecording->setEncoderId ( pRecInfo.GetInputID() );
150  pRecording->setEncoderName ( pRecInfo.GetInputName() );
151  pRecording->setProfile ( pRecInfo.GetProgramRecordingProfile() );
152  }
153  }
154 
155  if (!pInfo->GetInetRef().isEmpty() )
156  {
157  pProgram->setSerializeArtwork( true );
158 
159  FillArtworkInfoList( pProgram->Artwork(), pInfo->GetInetRef(),
160  pInfo->GetSeason());
161  }
162 }
163 
165 //
167 
169  uint nChanID,
170  bool bDetails /* = true */ )
171 {
172  ChannelInfo channel;
173  if (channel.Load(nChanID))
174  {
175  return FillChannelInfo(pChannel, channel, bDetails);
176  }
177 
178  return false;
179 }
180 
182 //
184 
186  const ChannelInfo &channelInfo,
187  bool bDetails /* = true */ )
188 {
189 
190  // TODO update DTC::ChannelInfo to match functionality of ChannelInfo,
191  // ultimately replacing it's progenitor?
192  pChannel->setChanId(channelInfo.m_chanId);
193  pChannel->setChanNum(channelInfo.m_chanNum);
194  pChannel->setCallSign(channelInfo.m_callSign);
195  if (!channelInfo.m_icon.isEmpty())
196  {
197  QString sIconURL = QString( "/Guide/GetChannelIcon?ChanId=%3")
198  .arg( channelInfo.m_chanId );
199  pChannel->setIconURL( sIconURL );
200  }
201  pChannel->setChannelName(channelInfo.m_name);
202  pChannel->setVisible(channelInfo.m_visible > kChannelNotVisible);
203  pChannel->setExtendedVisible(toRawString(channelInfo.m_visible));
204 
205  pChannel->setSerializeDetails( bDetails );
206 
207  if (bDetails)
208  {
209  pChannel->setMplexId(channelInfo.m_mplexId);
210  pChannel->setServiceId(channelInfo.m_serviceId);
211  pChannel->setATSCMajorChan(channelInfo.m_atscMajorChan);
212  pChannel->setATSCMinorChan(channelInfo.m_atscMinorChan);
213  pChannel->setFormat(channelInfo.m_tvFormat);
214  pChannel->setFineTune(channelInfo.m_fineTune);
215  pChannel->setFrequencyId(channelInfo.m_freqId);
216  pChannel->setChanFilters(channelInfo.m_videoFilters);
217  pChannel->setSourceId(channelInfo.m_sourceId);
218  pChannel->setCommFree(channelInfo.m_commMethod == -2);
219  pChannel->setUseEIT(channelInfo.m_useOnAirGuide);
220  pChannel->setXMLTVID(channelInfo.m_xmltvId);
221  pChannel->setDefaultAuth(channelInfo.m_defaultAuthority);
222  pChannel->setServiceType(channelInfo.m_serviceType);
223 
224  QList<uint> groupIds = channelInfo.GetGroupIds();
225  QString sGroupIds;
226  for (int x = 0; x < groupIds.size(); x++)
227  {
228  if (x > 0)
229  sGroupIds += ",";
230 
231  sGroupIds += QString::number(groupIds.at(x));
232  }
233  pChannel->setChannelGroups(sGroupIds);
234 
235  QList<uint> inputIds = channelInfo.GetInputIds();
236  QString sInputIds;
237  for (int x = 0; x < inputIds.size(); x++)
238  {
239  if (x > 0)
240  sInputIds += ",";
241 
242  sInputIds += QString::number(inputIds.at(x));
243  }
244  pChannel->setInputs(sInputIds);
245  }
246 
247  return true;
248 }
249 
251 //
253 
254 void FillChannelGroup(DTC::ChannelGroup* pGroup, const ChannelGroupItem& pGroupItem)
255 {
256  if (!pGroup)
257  return;
258 
259  pGroup->setGroupId(pGroupItem.m_grpId);
260  pGroup->setName(pGroupItem.m_name);
261  pGroup->setPassword(""); // Not currently supported
262 }
263 
265 //
267 
269  RecordingRule *pRule )
270 {
271  if ((pRecRule == nullptr) || (pRule == nullptr))
272  return;
273 
274  pRecRule->setId ( pRule->m_recordID );
275  pRecRule->setParentId ( pRule->m_parentRecID );
276  pRecRule->setInactive ( pRule->m_isInactive );
277  pRecRule->setTitle ( pRule->m_title );
278  pRecRule->setSubTitle ( pRule->m_subtitle );
279  pRecRule->setDescription ( pRule->m_description );
280  pRecRule->setSeason ( pRule->m_season );
281  pRecRule->setEpisode ( pRule->m_episode );
282  pRecRule->setCategory ( pRule->m_category );
283  pRecRule->setStartTime ( QDateTime(pRule->m_startdate,
284  pRule->m_starttime, Qt::UTC));
285  pRecRule->setEndTime ( QDateTime(pRule->m_enddate,
286  pRule->m_endtime, Qt::UTC));
287  pRecRule->setSeriesId ( pRule->m_seriesid );
288  pRecRule->setProgramId ( pRule->m_programid );
289  pRecRule->setInetref ( pRule->m_inetref );
290  pRecRule->setChanId ( pRule->m_channelid );
291  pRecRule->setCallSign ( pRule->m_station );
292  pRecRule->setFindDay ( pRule->m_findday );
293  pRecRule->setFindTime ( pRule->m_findtime );
294  pRecRule->setType ( toRawString(pRule->m_type) );
295  pRecRule->setSearchType ( toRawString(pRule->m_searchType));
296  pRecRule->setRecPriority ( pRule->m_recPriority );
297  pRecRule->setPreferredInput ( pRule->m_prefInput );
298  pRecRule->setStartOffset ( pRule->m_startOffset );
299  pRecRule->setEndOffset ( pRule->m_endOffset );
300  pRecRule->setDupMethod ( toRawString(pRule->m_dupMethod) );
301  pRecRule->setDupIn ( toRawString(pRule->m_dupIn) );
302  pRecRule->setFilter ( pRule->m_filter );
303  pRecRule->setRecProfile ( pRule->m_recProfile );
304  pRecRule->setRecGroup ( RecordingInfo::GetRecgroupString(pRule->m_recGroupID) );
305  pRecRule->setStorageGroup ( pRule->m_storageGroup );
306  pRecRule->setPlayGroup ( pRule->m_playGroup );
307  pRecRule->setAutoExpire ( pRule->m_autoExpire );
308  pRecRule->setMaxEpisodes ( pRule->m_maxEpisodes );
309  pRecRule->setMaxNewest ( pRule->m_maxNewest );
310  pRecRule->setAutoCommflag ( pRule->m_autoCommFlag );
311  pRecRule->setAutoTranscode ( pRule->m_autoTranscode );
312  pRecRule->setAutoMetaLookup ( pRule->m_autoMetadataLookup );
313  pRecRule->setAutoUserJob1 ( pRule->m_autoUserJob1 );
314  pRecRule->setAutoUserJob2 ( pRule->m_autoUserJob2 );
315  pRecRule->setAutoUserJob3 ( pRule->m_autoUserJob3 );
316  pRecRule->setAutoUserJob4 ( pRule->m_autoUserJob4 );
317  pRecRule->setTranscoder ( pRule->m_transcoder );
318  pRecRule->setNextRecording ( pRule->m_nextRecording );
319  pRecRule->setLastRecorded ( pRule->m_lastRecorded );
320  pRecRule->setLastDeleted ( pRule->m_lastDeleted );
321  pRecRule->setAverageDelay ( pRule->m_averageDelay );
322 }
323 
325 //
327 
329  const QString &sInetref,
330  uint nSeason )
331 {
332  ArtworkMap map = GetArtwork(sInetref, nSeason);
333 
334  for (ArtworkMap::const_iterator i = map.begin();
335  i != map.end(); ++i)
336  {
337  DTC::ArtworkInfo *pArtInfo = pArtworkInfoList->AddNewArtworkInfo();
338  pArtInfo->setFileName(i.value().url);
339  switch (i.key())
340  {
341  case kArtworkFanart:
342  pArtInfo->setStorageGroup("Fanart");
343  pArtInfo->setType("fanart");
344  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
345  "&FileName=%2").arg("Fanart")
346  .arg(QUrl(i.value().url).path()));
347  break;
348  case kArtworkBanner:
349  pArtInfo->setStorageGroup("Banners");
350  pArtInfo->setType("banner");
351  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
352  "&FileName=%2").arg("Banners")
353  .arg(QUrl(i.value().url).path()));
354  break;
355  case kArtworkCoverart:
356  default:
357  pArtInfo->setStorageGroup("Coverart");
358  pArtInfo->setType("coverart");
359  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
360  "&FileName=%2").arg("Coverart")
361  .arg(QUrl(i.value().url).path()));
362  break;
363  }
364  }
365 }
366 
368 //
370 
371 void FillGenreList(DTC::GenreList* pGenreList, int videoID)
372 {
373  if (!pGenreList)
374  return;
375 
376  MSqlQuery query(MSqlQuery::InitCon());
377  query.prepare("SELECT genre from videogenre "
378  "LEFT JOIN videometadatagenre ON videometadatagenre.idgenre = videogenre.intid "
379  "WHERE idvideo = :ID "
380  "ORDER BY genre;");
381  query.bindValue(":ID", videoID);
382 
383  if (query.exec() && query.size() > 0)
384  {
385  while (query.next())
386  {
387  DTC::Genre *pGenre = pGenreList->AddNewGenre();
388  QString genre = query.value(0).toString();
389  pGenre->setName(genre);
390  }
391  }
392 }
393 
395 //
397 
399  DTC::VideoMetadataInfo *pVideoMetadataInfo,
401  bool bDetails)
402 {
403  pVideoMetadataInfo->setId(pMetadata->GetID());
404  pVideoMetadataInfo->setTitle(pMetadata->GetTitle());
405  pVideoMetadataInfo->setSubTitle(pMetadata->GetSubtitle());
406  pVideoMetadataInfo->setTagline(pMetadata->GetTagline());
407  pVideoMetadataInfo->setDirector(pMetadata->GetDirector());
408  pVideoMetadataInfo->setStudio(pMetadata->GetStudio());
409  pVideoMetadataInfo->setDescription(pMetadata->GetPlot());
410  pVideoMetadataInfo->setCertification(pMetadata->GetRating());
411  pVideoMetadataInfo->setInetref(pMetadata->GetInetRef());
412  pVideoMetadataInfo->setCollectionref(pMetadata->GetCollectionRef());
413  pVideoMetadataInfo->setHomePage(pMetadata->GetHomepage());
414  pVideoMetadataInfo->setReleaseDate(
415  QDateTime(pMetadata->GetReleaseDate(),
416  QTime(0,0),Qt::LocalTime).toUTC());
417  pVideoMetadataInfo->setAddDate(
418  QDateTime(pMetadata->GetInsertdate(),
419  QTime(0,0),Qt::LocalTime).toUTC());
420  pVideoMetadataInfo->setUserRating(pMetadata->GetUserRating());
421  pVideoMetadataInfo->setChildID(pMetadata->GetChildID());
422  pVideoMetadataInfo->setLength(pMetadata->GetLength());
423  pVideoMetadataInfo->setPlayCount(pMetadata->GetPlayCount());
424  pVideoMetadataInfo->setSeason(pMetadata->GetSeason());
425  pVideoMetadataInfo->setEpisode(pMetadata->GetEpisode());
426  pVideoMetadataInfo->setParentalLevel(pMetadata->GetShowLevel());
427  pVideoMetadataInfo->setVisible(pMetadata->GetBrowse());
428  pVideoMetadataInfo->setWatched(pMetadata->GetWatched());
429  pVideoMetadataInfo->setProcessed(pMetadata->GetProcessed());
430  pVideoMetadataInfo->setContentType(ContentTypeToString(
431  pMetadata->GetContentType()));
432  pVideoMetadataInfo->setFileName(pMetadata->GetFilename());
433  pVideoMetadataInfo->setHash(pMetadata->GetHash());
434  pVideoMetadataInfo->setHostName(pMetadata->GetHost());
435  pVideoMetadataInfo->setCoverart(pMetadata->GetCoverFile());
436  pVideoMetadataInfo->setFanart(pMetadata->GetFanart());
437  pVideoMetadataInfo->setBanner(pMetadata->GetBanner());
438  pVideoMetadataInfo->setScreenshot(pMetadata->GetScreenshot());
439  pVideoMetadataInfo->setTrailer(pMetadata->GetTrailer());
440  pVideoMetadataInfo->setSerializeArtwork( true );
441 
442  if (bDetails)
443  {
444  if (!pMetadata->GetFanart().isEmpty())
445  {
446  DTC::ArtworkInfo *pArtInfo =
447  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
448  pArtInfo->setStorageGroup("Fanart");
449  pArtInfo->setType("fanart");
450  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
451  "&FileName=%2").arg("Fanart")
452  .arg(pMetadata->GetFanart()));
453  }
454  if (!pMetadata->GetCoverFile().isEmpty())
455  {
456  DTC::ArtworkInfo *pArtInfo =
457  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
458  pArtInfo->setStorageGroup("Coverart");
459  pArtInfo->setType("coverart");
460  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
461  "&FileName=%2").arg("Coverart")
462  .arg(pMetadata->GetCoverFile()));
463  }
464  if (!pMetadata->GetBanner().isEmpty())
465  {
466  DTC::ArtworkInfo *pArtInfo =
467  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
468  pArtInfo->setStorageGroup("Banners");
469  pArtInfo->setType("banner");
470  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
471  "&FileName=%2").arg("Banners")
472  .arg(pMetadata->GetBanner()));
473  }
474  if (!pMetadata->GetScreenshot().isEmpty())
475  {
476  DTC::ArtworkInfo *pArtInfo =
477  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
478  pArtInfo->setStorageGroup("Screenshots");
479  pArtInfo->setType("screenshot");
480  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
481  "&FileName=%2").arg("Screenshots")
482  .arg(pMetadata->GetScreenshot()));
483  }
484  }
485 
486  FillGenreList(pVideoMetadataInfo->Genres(), pVideoMetadataInfo->Id());
487 }
488 
490 //
492 
494  MusicMetadata *pMetadata, bool bDetails)
495 {
496  pVideoMetadataInfo->setId(pMetadata->ID());
497  pVideoMetadataInfo->setArtist(pMetadata->Artist());
498  pVideoMetadataInfo->setCompilationArtist(pMetadata->CompilationArtist());
499  pVideoMetadataInfo->setAlbum(pMetadata->Album());
500  pVideoMetadataInfo->setTitle(pMetadata->Title());
501  pVideoMetadataInfo->setTrackNo(pMetadata->Track());
502  pVideoMetadataInfo->setGenre(pMetadata->Genre());
503  pVideoMetadataInfo->setYear(pMetadata->Year());
504  pVideoMetadataInfo->setPlayCount(pMetadata->PlayCount());
505  pVideoMetadataInfo->setLength(pMetadata->Length());
506  pVideoMetadataInfo->setRating(pMetadata->Rating());
507  pVideoMetadataInfo->setFileName(pMetadata->Filename());
508  pVideoMetadataInfo->setHostName(pMetadata->Hostname());
509  pVideoMetadataInfo->setLastPlayed(pMetadata->LastPlay());
510  pVideoMetadataInfo->setCompilation(pMetadata->Compilation());
511 
512  if (bDetails)
513  {
514  //TODO add coverart here
515  }
516 }
517 
519 //
521 
522 void FillInputInfo(DTC::Input* input, const InputInfo& inputInfo)
523 {
524  input->setId(inputInfo.m_inputId);
525  input->setInputName(inputInfo.m_name);
526  input->setCardId(inputInfo.m_inputId);
527  input->setSourceId(inputInfo.m_sourceId);
528  input->setDisplayName(inputInfo.m_displayName);
529  input->setLiveTVOrder(inputInfo.m_liveTvOrder);
530  input->setScheduleOrder(inputInfo.m_scheduleOrder);
531  input->setRecPriority(inputInfo.m_recPriority);
532  input->setQuickTune(inputInfo.m_quickTune);
533 }
534 
536 //
538 
540  ProgramInfo* pInfo)
541 {
542  if (!pCastMemberList || !pInfo)
543  return;
544 
545  MSqlQuery query(MSqlQuery::InitCon());
546  if (pInfo->GetFilesize() > 0) // FIXME: This shouldn't be the way to determine what is or isn't a recording!
547  {
548  query.prepare("SELECT role, people.name FROM recordedcredits"
549  " AS credits"
550  " LEFT JOIN people ON credits.person = people.person"
551  " WHERE credits.chanid = :CHANID"
552  " AND credits.starttime = :STARTTIME"
553  " ORDER BY role;");
554  }
555  else
556  {
557  query.prepare("SELECT role, people.name FROM credits"
558  " LEFT JOIN people ON credits.person = people.person"
559  " WHERE credits.chanid = :CHANID"
560  " AND credits.starttime = :STARTTIME"
561  " ORDER BY role;");
562  }
563  query.bindValue(":CHANID", pInfo->GetChanID());
564  query.bindValue(":STARTTIME", pInfo->GetScheduledStartTime());
565 
566  if (query.exec() && query.size() > 0)
567  {
568  QMap<QString, QString> translations;
569  translations["ACTOR"] = QObject::tr("Actors");
570  translations["DIRECTOR"] = QObject::tr("Director");
571  translations["PRODUCER"] = QObject::tr("Producer");
572  translations["EXECUTIVE_PRODUCER"] = QObject::tr("Executive Producer");
573  translations["WRITER"] = QObject::tr("Writer");
574  translations["GUEST_STAR"] = QObject::tr("Guest Star");
575  translations["HOST"] = QObject::tr("Host");
576  translations["ADAPTER"] = QObject::tr("Adapter");
577  translations["PRESENTER"] = QObject::tr("Presenter");
578  translations["COMMENTATOR"] = QObject::tr("Commentator");
579  translations["GUEST"] = QObject::tr("Guest");
580 
581  while (query.next())
582  {
583  DTC::CastMember *pCastMember = pCastMemberList->AddNewCastMember();
584 
585  QString role = query.value(0).toString();
586  pCastMember->setRole(role);
587  pCastMember->setTranslatedRole(translations.value(role.toUpper()));
588  /* The people.name column uses utf8_bin collation.
589  * Qt-MySQL drivers use QVariant::ByteArray for string-type
590  * MySQL fields marked with the BINARY attribute (those using a
591  * *_bin collation) and QVariant::String for all others.
592  * Since QVariant::toString() uses QString::fromAscii()
593  * (through QVariant::convert()) when the QVariant's type is
594  * QVariant::ByteArray, we have to use QString::fromUtf8()
595  * explicitly to prevent corrupting characters.
596  * The following code should be changed to use the simpler
597  * toString() approach, as above, if we do a DB update to
598  * coalesce the people.name values that differ only in case and
599  * change the collation to utf8_general_ci, to match the
600  * majority of other columns, or we'll have the same problem in
601  * reverse.
602  */
603  pCastMember->setName(QString::fromUtf8(query.value(1)
604  .toByteArray().constData()));
605 
606  }
607  }
608 
609  //pCastMemberList->setCount(query.size());
610  //pCastMemberList->setTotalAvailable(query.size());
611 }
612 
614 //
616 
617 void FillCutList(DTC::CutList* pCutList, RecordingInfo* rInfo, int marktype)
618 {
619  frm_dir_map_t markMap;
620  frm_dir_map_t::const_iterator it;
621 
622  if (rInfo && rInfo->GetChanID())
623  {
624  rInfo->QueryCutList(markMap);
625 
626  for (it = markMap.begin(); it != markMap.end(); ++it)
627  {
628  bool isend = (*it) == MARK_CUT_END || (*it) == MARK_COMM_END;
629  if (marktype == 0)
630  {
631  DTC::Cutting *pCutting = pCutList->AddNewCutting();
632  pCutting->setMark(*it);
633  pCutting->setOffset(it.key());
634  }
635  else if (marktype == 1)
636  {
637  uint64_t offset = 0;
638  if (rInfo->QueryKeyFramePosition(&offset, it.key(), isend))
639  {
640  DTC::Cutting *pCutting = pCutList->AddNewCutting();
641  pCutting->setMark(*it);
642  pCutting->setOffset(offset);
643  }
644  }
645  else if (marktype == 2)
646  {
647  uint64_t offset = 0;
648  if (rInfo->QueryKeyFrameDuration(&offset, it.key(), isend))
649  {
650  DTC::Cutting *pCutting = pCutList->AddNewCutting();
651  pCutting->setMark(*it);
652  pCutting->setOffset(offset);
653  }
654  }
655  }
656  }
657 }
658 
660 //
662 
663 void FillCommBreak(DTC::CutList* pCutList, RecordingInfo* rInfo, int marktype)
664 {
665  frm_dir_map_t markMap;
666  frm_dir_map_t::const_iterator it;
667 
668  if (rInfo && rInfo->GetChanID())
669  {
670  rInfo->QueryCommBreakList(markMap);
671 
672  for (it = markMap.begin(); it != markMap.end(); ++it)
673  {
674  bool isend = (*it) == MARK_CUT_END || (*it) == MARK_COMM_END;
675  if (marktype == 0)
676  {
677  DTC::Cutting *pCutting = pCutList->AddNewCutting();
678  pCutting->setMark(*it);
679  pCutting->setOffset(it.key());
680  }
681  else if (marktype == 1)
682  {
683  uint64_t offset = 0;
684  if (rInfo->QueryKeyFramePosition(&offset, it.key(), isend))
685  {
686  DTC::Cutting *pCutting = pCutList->AddNewCutting();
687  pCutting->setMark(*it);
688  pCutting->setOffset(offset);
689  }
690  }
691  else if (marktype == 2)
692  {
693  uint64_t offset = 0;
694  if (rInfo->QueryKeyFrameDuration(&offset, it.key(), isend))
695  {
696  DTC::Cutting *pCutting = pCutList->AddNewCutting();
697  pCutting->setMark(*it);
698  pCutting->setOffset(offset);
699  }
700  }
701  }
702  }
703 }
704 
706 //
708 
709 void FillSeek(DTC::CutList* pCutList, RecordingInfo* rInfo, MarkTypes marktype)
710 {
711  frm_pos_map_t markMap;
712  frm_pos_map_t::const_iterator it;
713 
714  if (rInfo && rInfo->GetChanID())
715  {
716  rInfo->QueryPositionMap(markMap, marktype);
717 
718  for (it = markMap.begin(); it != markMap.end(); ++it)
719  {
720  DTC::Cutting *pCutting = pCutList->AddNewCutting();
721  pCutting->setMark(it.key());
722  pCutting->setOffset(it.value());
723  }
724  }
725 }
bool QueryKeyFrameDuration(uint64_t *duration, uint64_t keyframe, bool backwards) const
QString m_subtitle
Definition: recordingrule.h:81
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:783
QTime m_findtime
Time for timeslot rules.
bool m_isInactive
Recording rule is enabled?
Definition: recordingrule.h:76
float GetStars(void) const
Definition: programinfo.h:436
void FillChannelGroup(DTC::ChannelGroup *pGroup, const ChannelGroupItem &pGroupItem)
ArtworkInfo * AddNewArtworkInfo()
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:864
uint GetInputID(void) const
Definition: programinfo.h:457
QString m_programid
Definition: recordingrule.h:94
QString m_displayName
Definition: inputinfo.h:52
uint m_mplexId
Definition: channelinfo.h:112
QString m_name
Definition: channelinfo.h:94
void QueryPositionMap(frm_pos_map_t &posMap, MarkTypes type) const
RecordingDupMethodType GetDuplicateCheckMethod(void) const
What should be compared to determine if two programs are the same?
Definition: programinfo.h:453
void FillArtworkInfoList(DTC::ArtworkInfoList *pArtworkInfoList, const QString &sInetref, uint nSeason)
void FillProgramInfo(DTC::Program *pProgram, ProgramInfo *pInfo, bool bIncChannel, bool bDetails, bool bIncCast)
Definition: serviceUtil.cpp:44
virtual uint64_t GetFilesize(void) const
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
QString Genre() const
QString Hostname(void)
void FillRecRuleInfo(DTC::RecRule *pRecRule, RecordingRule *pRule)
QString m_freqId
Definition: channelinfo.h:89
QString GetTitle(void) const
Definition: programinfo.h:355
QString m_storageGroup
int size(void) const
Definition: mythdbcon.h:203
QString m_station
bool m_useOnAirGuide
Definition: channelinfo.h:110
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:34
int Length() const
int m_recordID
Unique Recording Rule ID.
Definition: recordingrule.h:72
uint m_chanId
Definition: channelinfo.h:87
Cutting * AddNewCutting()
Definition: cutList.h:53
RecordingType m_type
RecordingDupMethodType m_dupMethod
int GetRecordingPriority(void) const
Definition: programinfo.h:434
uint GetAudioProperties(void) const
Definition: programinfo.h:490
uint m_liveTvOrder
order for live TV use
Definition: inputinfo.h:55
uint m_inputId
unique key in DB for this input
Definition: inputinfo.h:49
int Rating() const
void FillCastMemberList(DTC::CastMemberList *pCastMemberList, ProgramInfo *pInfo)
int PlayCount() const
int m_fineTune
Definition: channelinfo.h:97
uint GetVideoProperties(void) const
Definition: programinfo.h:488
QString GetInetRef(void) const
Definition: programinfo.h:431
QDateTime m_nextRecording
QDate GetOriginalAirDate(void) const
Definition: programinfo.h:422
QString GetStorageGroup(void) const
Definition: programinfo.h:416
QString m_icon
Definition: channelinfo.h:95
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
Definition: programtypes.h:46
uint m_atscMajorChan
Definition: channelinfo.h:115
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
Definition: programinfo.h:384
QVariant value(int i) const
Definition: mythdbcon.h:198
MarkTypes
Definition: programtypes.h:48
bool FillChannelInfo(DTC::ChannelInfo *pChannel, uint nChanID, bool bDetails)
QString Artist() const
Holds information on recordings and videos.
Definition: programinfo.h:67
QDateTime m_lastRecorded
int m_commMethod
Definition: channelinfo.h:121
uint32_t GetProgramFlags(void) const
Definition: programinfo.h:466
void QueryCommBreakList(frm_dir_map_t &frames) const
QString GetDescription(void) const
Definition: programinfo.h:359
bool m_autoMetadataLookup
int m_findday
callsign?
QList< uint > GetGroupIds() const
Definition: channelinfo.h:59
uint m_atscMinorChan
Definition: channelinfo.h:116
IdType ID() const
QString m_playGroup
void FillCutList(DTC::CutList *pCutList, RecordingInfo *rInfo, int marktype)
int m_recPriority
Definition: inputinfo.h:53
QString GetSubtitle(void) const
Definition: programinfo.h:357
bool IsRepeat(void) const
Definition: programinfo.h:480
int Track() const
QString GetRecordingGroup(void) const
Definition: programinfo.h:413
QString m_description
Definition: recordingrule.h:83
QString m_chanNum
Definition: channelinfo.h:88
uint m_sourceId
associated channel listings source
Definition: inputinfo.h:48
uint GetRecordingID(void) const
Definition: programinfo.h:440
void FillGenreList(DTC::GenreList *pGenreList, int videoID)
uint GetSeason(void) const
Definition: programinfo.h:360
unsigned int uint
Definition: compat.h:140
QString GetCategoryTypeString(void) const
Returns catType as a string.
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:32
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
Definition: programinfo.h:391
QString Album() const
QString m_seriesid
Definition: recordingrule.h:93
uint m_sourceId
Definition: channelinfo.h:91
QString GetPlaybackGroup(void) const
Definition: programinfo.h:414
RecordingDupInType m_dupIn
QString m_inetref
Definition: recordingrule.h:96
uint m_serviceId
Definition: channelinfo.h:113
void FillSeek(DTC::CutList *pCutList, RecordingInfo *rInfo, MarkTypes marktype)
bool Compilation() const
QString GetProgramRecordingProfile(void) const
Returns recording profile name that will be, or was used, for this program, creating "record" field i...
QString GetSeriesID(void) const
Definition: programinfo.h:429
uint64_t GetFilesize(void) const override
void FillCommBreak(DTC::CutList *pCutList, RecordingInfo *rInfo, int marktype)
uint GetYearOfInitialRelease(void) const
Definition: programinfo.h:417
QString m_name
input name
Definition: inputinfo.h:47
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:808
bool Load(uint lchanid=-1)
int Year() const
uint GetSubtitleType(void) const
Definition: programinfo.h:486
QString m_title
Definition: recordingrule.h:79
RecStatus::Type GetRecordingStatus(void) const
Definition: programinfo.h:441
uint GetEpisodeTotal(void) const
Definition: programinfo.h:362
QDateTime m_lastDeleted
QString Title() const
RecordingType GetRecordingRuleType(void) const
Definition: programinfo.h:445
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:366
bool m_quickTune
Definition: inputinfo.h:56
static QString GetRecgroupString(uint recGroupID)
Temporary helper during transition from string to ID.
QString m_recProfile
uint GetRecordingRuleID(void) const
Definition: programinfo.h:443
QString ContentTypeToString(VideoContentType type)
Definition: videoutils.cpp:299
QString Filename(bool find=true)
uint m_scheduleOrder
Definition: inputinfo.h:54
QString GetProgramID(void) const
Definition: programinfo.h:430
Genre * AddNewGenre()
Definition: genreList.h:53
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:398
void FillMusicMetadataInfo(DTC::MusicMetadataInfo *pVideoMetadataInfo, MusicMetadata *pMetadata, bool bDetails)
QString m_callSign
Definition: channelinfo.h:93
unsigned m_filter
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
Definition: programinfo.h:406
QString m_category
Definition: recordingrule.h:86
QList< uint > GetInputIds() const
Definition: channelinfo.h:69
void FillInputInfo(DTC::Input *input, const InputInfo &inputInfo)
QDateTime GetLastModifiedTime(void) const
Definition: programinfo.h:423
QDateTime LastPlay() const
QString m_tvFormat
Definition: channelinfo.h:107
QString CompilationArtist() const
QString GetHostname(void) const
Definition: programinfo.h:415
QString GetInputName(void) const
Definition: programinfo.h:458
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:81
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
QString GetCategory(void) const
Definition: programinfo.h:363
QMultiMap< VideoArtworkType, ArtworkInfo > ArtworkMap
void FillVideoMetadataInfo(DTC::VideoMetadataInfo *pVideoMetadataInfo, const VideoMetadataListManager::VideoMetadataPtr &pMetadata, bool bDetails)
QString m_xmltvId
Definition: channelinfo.h:99
RecordingDupInType GetDuplicateCheckSource(void) const
Where should we check for duplicates?
Definition: programinfo.h:449
QString toRawString(RecordingType rectype)
Converts "rectype" into an untranslated string.
QString m_defaultAuthority
Definition: channelinfo.h:120
bool QueryCutList(frm_dir_map_t &delMap, bool loadAutosave=false) const
QString GetPathname(void) const
Definition: programinfo.h:337
bool QueryKeyFramePosition(uint64_t *position, uint64_t keyframe, bool backwards) const
RecSearchType m_searchType
ArtworkMap GetArtwork(const QString &inetref, uint season, bool strict)
uint m_serviceType
Definition: channelinfo.h:114
ChannelVisibleType m_visible
Definition: channelinfo.h:108
CastMember * AddNewCastMember()
uint GetEpisode(void) const
Definition: programinfo.h:361
QString m_videoFilters
Definition: channelinfo.h:98