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);
203 
204  pChannel->setSerializeDetails( bDetails );
205 
206  if (bDetails)
207  {
208  pChannel->setMplexId(channelInfo.m_mplexid);
209  pChannel->setServiceId(channelInfo.m_serviceid);
210  pChannel->setATSCMajorChan(channelInfo.m_atsc_major_chan);
211  pChannel->setATSCMinorChan(channelInfo.m_atsc_minor_chan);
212  pChannel->setFormat(channelInfo.m_tvformat);
213  pChannel->setFineTune(channelInfo.m_finetune);
214  pChannel->setFrequencyId(channelInfo.m_freqid);
215  pChannel->setChanFilters(channelInfo.m_videofilters);
216  pChannel->setSourceId(channelInfo.m_sourceid);
217  pChannel->setCommFree(channelInfo.m_commmethod == -2);
218  pChannel->setUseEIT(channelInfo.m_useonairguide);
219  pChannel->setXMLTVID(channelInfo.m_xmltvid);
220  pChannel->setDefaultAuth(channelInfo.m_default_authority);
221 
222  QList<uint> groupIds = channelInfo.GetGroupIds();
223  QString sGroupIds;
224  for (int x = 0; x < groupIds.size(); x++)
225  {
226  if (x > 0)
227  sGroupIds += ",";
228 
229  sGroupIds += QString::number(groupIds.at(x));
230  }
231  pChannel->setChannelGroups(sGroupIds);
232 
233  QList<uint> inputIds = channelInfo.GetInputIds();
234  QString sInputIds;
235  for (int x = 0; x < inputIds.size(); x++)
236  {
237  if (x > 0)
238  sInputIds += ",";
239 
240  sInputIds += QString::number(inputIds.at(x));
241  }
242  pChannel->setInputs(sInputIds);
243  }
244 
245  return true;
246 }
247 
249 //
251 
252 void FillChannelGroup(DTC::ChannelGroup* pGroup, const ChannelGroupItem& pGroupItem)
253 {
254  if (!pGroup)
255  return;
256 
257  pGroup->setGroupId(pGroupItem.m_grpid);
258  pGroup->setName(pGroupItem.m_name);
259  pGroup->setPassword(""); // Not currently supported
260 }
261 
263 //
265 
267  RecordingRule *pRule )
268 {
269  if ((pRecRule == nullptr) || (pRule == nullptr))
270  return;
271 
272  pRecRule->setId ( pRule->m_recordID );
273  pRecRule->setParentId ( pRule->m_parentRecID );
274  pRecRule->setInactive ( pRule->m_isInactive );
275  pRecRule->setTitle ( pRule->m_title );
276  pRecRule->setSubTitle ( pRule->m_subtitle );
277  pRecRule->setDescription ( pRule->m_description );
278  pRecRule->setSeason ( pRule->m_season );
279  pRecRule->setEpisode ( pRule->m_episode );
280  pRecRule->setCategory ( pRule->m_category );
281  pRecRule->setStartTime ( QDateTime(pRule->m_startdate,
282  pRule->m_starttime, Qt::UTC));
283  pRecRule->setEndTime ( QDateTime(pRule->m_enddate,
284  pRule->m_endtime, Qt::UTC));
285  pRecRule->setSeriesId ( pRule->m_seriesid );
286  pRecRule->setProgramId ( pRule->m_programid );
287  pRecRule->setInetref ( pRule->m_inetref );
288  pRecRule->setChanId ( pRule->m_channelid );
289  pRecRule->setCallSign ( pRule->m_station );
290  pRecRule->setFindDay ( pRule->m_findday );
291  pRecRule->setFindTime ( pRule->m_findtime );
292  pRecRule->setType ( toRawString(pRule->m_type) );
293  pRecRule->setSearchType ( toRawString(pRule->m_searchType));
294  pRecRule->setRecPriority ( pRule->m_recPriority );
295  pRecRule->setPreferredInput ( pRule->m_prefInput );
296  pRecRule->setStartOffset ( pRule->m_startOffset );
297  pRecRule->setEndOffset ( pRule->m_endOffset );
298  pRecRule->setDupMethod ( toRawString(pRule->m_dupMethod) );
299  pRecRule->setDupIn ( toRawString(pRule->m_dupIn) );
300  pRecRule->setFilter ( pRule->m_filter );
301  pRecRule->setRecProfile ( pRule->m_recProfile );
302  pRecRule->setRecGroup ( RecordingInfo::GetRecgroupString(pRule->m_recGroupID) );
303  pRecRule->setStorageGroup ( pRule->m_storageGroup );
304  pRecRule->setPlayGroup ( pRule->m_playGroup );
305  pRecRule->setAutoExpire ( pRule->m_autoExpire );
306  pRecRule->setMaxEpisodes ( pRule->m_maxEpisodes );
307  pRecRule->setMaxNewest ( pRule->m_maxNewest );
308  pRecRule->setAutoCommflag ( pRule->m_autoCommFlag );
309  pRecRule->setAutoTranscode ( pRule->m_autoTranscode );
310  pRecRule->setAutoMetaLookup ( pRule->m_autoMetadataLookup );
311  pRecRule->setAutoUserJob1 ( pRule->m_autoUserJob1 );
312  pRecRule->setAutoUserJob2 ( pRule->m_autoUserJob2 );
313  pRecRule->setAutoUserJob3 ( pRule->m_autoUserJob3 );
314  pRecRule->setAutoUserJob4 ( pRule->m_autoUserJob4 );
315  pRecRule->setTranscoder ( pRule->m_transcoder );
316  pRecRule->setNextRecording ( pRule->m_nextRecording );
317  pRecRule->setLastRecorded ( pRule->m_lastRecorded );
318  pRecRule->setLastDeleted ( pRule->m_lastDeleted );
319  pRecRule->setAverageDelay ( pRule->m_averageDelay );
320 }
321 
323 //
325 
327  const QString &sInetref,
328  uint nSeason )
329 {
330  ArtworkMap map = GetArtwork(sInetref, nSeason);
331 
332  for (ArtworkMap::const_iterator i = map.begin();
333  i != map.end(); ++i)
334  {
335  DTC::ArtworkInfo *pArtInfo = pArtworkInfoList->AddNewArtworkInfo();
336  pArtInfo->setFileName(i.value().url);
337  switch (i.key())
338  {
339  case kArtworkFanart:
340  pArtInfo->setStorageGroup("Fanart");
341  pArtInfo->setType("fanart");
342  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
343  "&FileName=%2").arg("Fanart")
344  .arg(QUrl(i.value().url).path()));
345  break;
346  case kArtworkBanner:
347  pArtInfo->setStorageGroup("Banners");
348  pArtInfo->setType("banner");
349  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
350  "&FileName=%2").arg("Banners")
351  .arg(QUrl(i.value().url).path()));
352  break;
353  case kArtworkCoverart:
354  default:
355  pArtInfo->setStorageGroup("Coverart");
356  pArtInfo->setType("coverart");
357  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
358  "&FileName=%2").arg("Coverart")
359  .arg(QUrl(i.value().url).path()));
360  break;
361  }
362  }
363 }
364 
366 //
368 
369 void FillGenreList(DTC::GenreList* pGenreList, int videoID)
370 {
371  if (!pGenreList)
372  return;
373 
374  MSqlQuery query(MSqlQuery::InitCon());
375  query.prepare("SELECT genre from videogenre "
376  "LEFT JOIN videometadatagenre ON videometadatagenre.idgenre = videogenre.intid "
377  "WHERE idvideo = :ID "
378  "ORDER BY genre;");
379  query.bindValue(":ID", videoID);
380 
381  if (query.exec() && query.size() > 0)
382  {
383  while (query.next())
384  {
385  DTC::Genre *pGenre = pGenreList->AddNewGenre();
386  QString genre = query.value(0).toString();
387  pGenre->setName(genre);
388  }
389  }
390 }
391 
393 //
395 
397  DTC::VideoMetadataInfo *pVideoMetadataInfo,
399  bool bDetails)
400 {
401  pVideoMetadataInfo->setId(pMetadata->GetID());
402  pVideoMetadataInfo->setTitle(pMetadata->GetTitle());
403  pVideoMetadataInfo->setSubTitle(pMetadata->GetSubtitle());
404  pVideoMetadataInfo->setTagline(pMetadata->GetTagline());
405  pVideoMetadataInfo->setDirector(pMetadata->GetDirector());
406  pVideoMetadataInfo->setStudio(pMetadata->GetStudio());
407  pVideoMetadataInfo->setDescription(pMetadata->GetPlot());
408  pVideoMetadataInfo->setCertification(pMetadata->GetRating());
409  pVideoMetadataInfo->setInetref(pMetadata->GetInetRef());
410  pVideoMetadataInfo->setCollectionref(pMetadata->GetCollectionRef());
411  pVideoMetadataInfo->setHomePage(pMetadata->GetHomepage());
412  pVideoMetadataInfo->setReleaseDate(
413  QDateTime(pMetadata->GetReleaseDate(),
414  QTime(0,0),Qt::LocalTime).toUTC());
415  pVideoMetadataInfo->setAddDate(
416  QDateTime(pMetadata->GetInsertdate(),
417  QTime(0,0),Qt::LocalTime).toUTC());
418  pVideoMetadataInfo->setUserRating(pMetadata->GetUserRating());
419  pVideoMetadataInfo->setChildID(pMetadata->GetChildID());
420  pVideoMetadataInfo->setLength(pMetadata->GetLength());
421  pVideoMetadataInfo->setPlayCount(pMetadata->GetPlayCount());
422  pVideoMetadataInfo->setSeason(pMetadata->GetSeason());
423  pVideoMetadataInfo->setEpisode(pMetadata->GetEpisode());
424  pVideoMetadataInfo->setParentalLevel(pMetadata->GetShowLevel());
425  pVideoMetadataInfo->setVisible(pMetadata->GetBrowse());
426  pVideoMetadataInfo->setWatched(pMetadata->GetWatched());
427  pVideoMetadataInfo->setProcessed(pMetadata->GetProcessed());
428  pVideoMetadataInfo->setContentType(ContentTypeToString(
429  pMetadata->GetContentType()));
430  pVideoMetadataInfo->setFileName(pMetadata->GetFilename());
431  pVideoMetadataInfo->setHash(pMetadata->GetHash());
432  pVideoMetadataInfo->setHostName(pMetadata->GetHost());
433  pVideoMetadataInfo->setCoverart(pMetadata->GetCoverFile());
434  pVideoMetadataInfo->setFanart(pMetadata->GetFanart());
435  pVideoMetadataInfo->setBanner(pMetadata->GetBanner());
436  pVideoMetadataInfo->setScreenshot(pMetadata->GetScreenshot());
437  pVideoMetadataInfo->setTrailer(pMetadata->GetTrailer());
438  pVideoMetadataInfo->setSerializeArtwork( true );
439 
440  if (bDetails)
441  {
442  if (!pMetadata->GetFanart().isEmpty())
443  {
444  DTC::ArtworkInfo *pArtInfo =
445  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
446  pArtInfo->setStorageGroup("Fanart");
447  pArtInfo->setType("fanart");
448  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
449  "&FileName=%2").arg("Fanart")
450  .arg(pMetadata->GetFanart()));
451  }
452  if (!pMetadata->GetCoverFile().isEmpty())
453  {
454  DTC::ArtworkInfo *pArtInfo =
455  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
456  pArtInfo->setStorageGroup("Coverart");
457  pArtInfo->setType("coverart");
458  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
459  "&FileName=%2").arg("Coverart")
460  .arg(pMetadata->GetCoverFile()));
461  }
462  if (!pMetadata->GetBanner().isEmpty())
463  {
464  DTC::ArtworkInfo *pArtInfo =
465  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
466  pArtInfo->setStorageGroup("Banners");
467  pArtInfo->setType("banner");
468  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
469  "&FileName=%2").arg("Banners")
470  .arg(pMetadata->GetBanner()));
471  }
472  if (!pMetadata->GetScreenshot().isEmpty())
473  {
474  DTC::ArtworkInfo *pArtInfo =
475  pVideoMetadataInfo->Artwork()->AddNewArtworkInfo();
476  pArtInfo->setStorageGroup("Screenshots");
477  pArtInfo->setType("screenshot");
478  pArtInfo->setURL(QString("/Content/GetImageFile?StorageGroup=%1"
479  "&FileName=%2").arg("Screenshots")
480  .arg(pMetadata->GetScreenshot()));
481  }
482  }
483 
484  FillGenreList(pVideoMetadataInfo->Genres(), pVideoMetadataInfo->Id());
485 }
486 
488 //
490 
492  MusicMetadata *pMetadata, bool bDetails)
493 {
494  pVideoMetadataInfo->setId(pMetadata->ID());
495  pVideoMetadataInfo->setArtist(pMetadata->Artist());
496  pVideoMetadataInfo->setCompilationArtist(pMetadata->CompilationArtist());
497  pVideoMetadataInfo->setAlbum(pMetadata->Album());
498  pVideoMetadataInfo->setTitle(pMetadata->Title());
499  pVideoMetadataInfo->setTrackNo(pMetadata->Track());
500  pVideoMetadataInfo->setGenre(pMetadata->Genre());
501  pVideoMetadataInfo->setYear(pMetadata->Year());
502  pVideoMetadataInfo->setPlayCount(pMetadata->PlayCount());
503  pVideoMetadataInfo->setLength(pMetadata->Length());
504  pVideoMetadataInfo->setRating(pMetadata->Rating());
505  pVideoMetadataInfo->setFileName(pMetadata->Filename());
506  pVideoMetadataInfo->setHostName(pMetadata->Hostname());
507  pVideoMetadataInfo->setLastPlayed(pMetadata->LastPlay());
508  pVideoMetadataInfo->setCompilation(pMetadata->Compilation());
509 
510  if (bDetails)
511  {
512  //TODO add coverart here
513  }
514 }
515 
517 //
519 
520 void FillInputInfo(DTC::Input* input, const InputInfo& inputInfo)
521 {
522  input->setId(inputInfo.m_inputid);
523  input->setInputName(inputInfo.m_name);
524  input->setCardId(inputInfo.m_inputid);
525  input->setSourceId(inputInfo.m_sourceid);
526  input->setDisplayName(inputInfo.m_displayName);
527  input->setLiveTVOrder(inputInfo.m_livetvorder);
528  input->setScheduleOrder(inputInfo.m_scheduleOrder);
529  input->setRecPriority(inputInfo.m_recPriority);
530  input->setQuickTune(inputInfo.m_quickTune);
531 }
532 
534 //
536 
538  ProgramInfo* pInfo)
539 {
540  if (!pCastMemberList || !pInfo)
541  return;
542 
543  MSqlQuery query(MSqlQuery::InitCon());
544  if (pInfo->GetFilesize() > 0) // FIXME: This shouldn't be the way to determine what is or isn't a recording!
545  query.prepare("SELECT role, people.name FROM recordedcredits"
546  " AS credits"
547  " LEFT JOIN people ON credits.person = people.person"
548  " WHERE credits.chanid = :CHANID"
549  " AND credits.starttime = :STARTTIME"
550  " ORDER BY role;");
551  else
552  query.prepare("SELECT role, people.name FROM credits"
553  " LEFT JOIN people ON credits.person = people.person"
554  " WHERE credits.chanid = :CHANID"
555  " AND credits.starttime = :STARTTIME"
556  " ORDER BY role;");
557  query.bindValue(":CHANID", pInfo->GetChanID());
558  query.bindValue(":STARTTIME", pInfo->GetScheduledStartTime());
559 
560  if (query.exec() && query.size() > 0)
561  {
562  QMap<QString, QString> translations;
563  translations["ACTOR"] = QObject::tr("Actors");
564  translations["DIRECTOR"] = QObject::tr("Director");
565  translations["PRODUCER"] = QObject::tr("Producer");
566  translations["EXECUTIVE_PRODUCER"] = QObject::tr("Executive Producer");
567  translations["WRITER"] = QObject::tr("Writer");
568  translations["GUEST_STAR"] = QObject::tr("Guest Star");
569  translations["HOST"] = QObject::tr("Host");
570  translations["ADAPTER"] = QObject::tr("Adapter");
571  translations["PRESENTER"] = QObject::tr("Presenter");
572  translations["COMMENTATOR"] = QObject::tr("Commentator");
573  translations["GUEST"] = QObject::tr("Guest");
574 
575  while (query.next())
576  {
577  DTC::CastMember *pCastMember = pCastMemberList->AddNewCastMember();
578 
579  QString role = query.value(0).toString();
580  pCastMember->setRole(role);
581  pCastMember->setTranslatedRole(translations.value(role.toUpper()));
582  /* The people.name column uses utf8_bin collation.
583  * Qt-MySQL drivers use QVariant::ByteArray for string-type
584  * MySQL fields marked with the BINARY attribute (those using a
585  * *_bin collation) and QVariant::String for all others.
586  * Since QVariant::toString() uses QString::fromAscii()
587  * (through QVariant::convert()) when the QVariant's type is
588  * QVariant::ByteArray, we have to use QString::fromUtf8()
589  * explicitly to prevent corrupting characters.
590  * The following code should be changed to use the simpler
591  * toString() approach, as above, if we do a DB update to
592  * coalesce the people.name values that differ only in case and
593  * change the collation to utf8_general_ci, to match the
594  * majority of other columns, or we'll have the same problem in
595  * reverse.
596  */
597  pCastMember->setName(QString::fromUtf8(query.value(1)
598  .toByteArray().constData()));
599 
600  }
601  }
602 
603  //pCastMemberList->setCount(query.size());
604  //pCastMemberList->setTotalAvailable(query.size());
605 }
606 
608 //
610 
611 void FillCutList(DTC::CutList* pCutList, RecordingInfo* rInfo, int marktype)
612 {
613  frm_dir_map_t markMap;
614  frm_dir_map_t::const_iterator it;
615 
616  if (rInfo && rInfo->GetChanID())
617  {
618  rInfo->QueryCutList(markMap);
619 
620  for (it = markMap.begin(); it != markMap.end(); ++it)
621  {
622  bool isend = (*it) == MARK_CUT_END || (*it) == MARK_COMM_END;
623  if (marktype == 0)
624  {
625  DTC::Cutting *pCutting = pCutList->AddNewCutting();
626  pCutting->setMark(*it);
627  pCutting->setOffset(it.key());
628  }
629  else if (marktype == 1)
630  {
631  uint64_t offset;
632  if (rInfo->QueryKeyFramePosition(&offset, it.key(), isend))
633  {
634  DTC::Cutting *pCutting = pCutList->AddNewCutting();
635  pCutting->setMark(*it);
636  pCutting->setOffset(offset);
637  }
638  }
639  else if (marktype == 2)
640  {
641  uint64_t offset;
642  if (rInfo->QueryKeyFrameDuration(&offset, it.key(), isend))
643  {
644  DTC::Cutting *pCutting = pCutList->AddNewCutting();
645  pCutting->setMark(*it);
646  pCutting->setOffset(offset);
647  }
648  }
649  }
650  }
651 }
652 
654 //
656 
657 void FillCommBreak(DTC::CutList* pCutList, RecordingInfo* rInfo, int marktype)
658 {
659  frm_dir_map_t markMap;
660  frm_dir_map_t::const_iterator it;
661 
662  if (rInfo && rInfo->GetChanID())
663  {
664  rInfo->QueryCommBreakList(markMap);
665 
666  for (it = markMap.begin(); it != markMap.end(); ++it)
667  {
668  bool isend = (*it) == MARK_CUT_END || (*it) == MARK_COMM_END;
669  if (marktype == 0)
670  {
671  DTC::Cutting *pCutting = pCutList->AddNewCutting();
672  pCutting->setMark(*it);
673  pCutting->setOffset(it.key());
674  }
675  else if (marktype == 1)
676  {
677  uint64_t offset;
678  if (rInfo->QueryKeyFramePosition(&offset, it.key(), isend))
679  {
680  DTC::Cutting *pCutting = pCutList->AddNewCutting();
681  pCutting->setMark(*it);
682  pCutting->setOffset(offset);
683  }
684  }
685  else if (marktype == 2)
686  {
687  uint64_t offset;
688  if (rInfo->QueryKeyFrameDuration(&offset, it.key(), isend))
689  {
690  DTC::Cutting *pCutting = pCutList->AddNewCutting();
691  pCutting->setMark(*it);
692  pCutting->setOffset(offset);
693  }
694  }
695  }
696  }
697 }
698 
700 //
702 
703 void FillSeek(DTC::CutList* pCutList, RecordingInfo* rInfo, MarkTypes marktype)
704 {
705  frm_pos_map_t markMap;
706  frm_pos_map_t::const_iterator it;
707 
708  if (rInfo && rInfo->GetChanID())
709  {
710  rInfo->QueryPositionMap(markMap, marktype);
711 
712  for (it = markMap.begin(); it != markMap.end(); ++it)
713  {
714  DTC::Cutting *pCutting = pCutList->AddNewCutting();
715  pCutting->setMark(it.key());
716  pCutting->setOffset(it.value());
717  }
718  }
719 }
QString m_subtitle
Definition: recordingrule.h:81
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:782
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:434
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:863
uint GetInputID(void) const
Definition: programinfo.h:455
QString m_programid
Definition: recordingrule.h:94
QString m_displayName
Definition: inputinfo.h:74
QString m_name
Definition: channelinfo.h:82
RecordingDupMethodType GetDuplicateCheckMethod(void) const
What should be compared to determine if two programs are the same?
Definition: programinfo.h:451
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
uint m_livetvorder
order for live TV use
Definition: inputinfo.h:77
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_videofilters
Definition: channelinfo.h:86
bool QueryCutList(frm_dir_map_t &, bool loadAutosave=false) const
QString GetTitle(void) const
Definition: programinfo.h:353
QString m_storageGroup
int size(void) const
Definition: mythdbcon.h:203
QString m_station
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:34
uint m_inputid
unique key in DB for this input
Definition: inputinfo.h:71
int Length() const
void QueryCommBreakList(frm_dir_map_t &) const
int m_recordID
Unique Recording Rule ID.
Definition: recordingrule.h:72
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:81
unsigned int uint
Definition: compat.h:140
Cutting * AddNewCutting()
Definition: cutList.h:53
RecordingType m_type
RecordingDupMethodType m_dupMethod
int GetRecordingPriority(void) const
Definition: programinfo.h:432
QString m_xmltvid
Definition: channelinfo.h:87
uint GetAudioProperties(void) const
Definition: programinfo.h:488
int Rating() const
void FillCastMemberList(DTC::CastMemberList *pCastMemberList, ProgramInfo *pInfo)
int PlayCount() const
uint GetVideoProperties(void) const
Definition: programinfo.h:486
QString m_tvformat
Definition: channelinfo.h:95
QString GetInetRef(void) const
Definition: programinfo.h:429
QDateTime m_nextRecording
QDate GetOriginalAirDate(void) const
Definition: programinfo.h:420
QString GetStorageGroup(void) const
Definition: programinfo.h:414
QString m_icon
Definition: channelinfo.h:83
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
Definition: programinfo.h:382
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:66
QDateTime m_lastRecorded
uint m_serviceid
Definition: channelinfo.h:101
uint32_t GetProgramFlags(void) const
Definition: programinfo.h:464
uint m_atsc_major_chan
Definition: channelinfo.h:102
QString GetDescription(void) const
Definition: programinfo.h:357
bool m_autoMetadataLookup
int m_findday
callsign?
QString m_freqid
Definition: channelinfo.h:77
uint m_sourceid
Definition: channelinfo.h:79
IdType ID() const
QString m_playGroup
void FillCutList(DTC::CutList *pCutList, RecordingInfo *rInfo, int marktype)
int m_finetune
Definition: channelinfo.h:85
uint m_mplexid
Definition: channelinfo.h:100
int m_recPriority
Definition: inputinfo.h:75
QString GetSubtitle(void) const
Definition: programinfo.h:355
bool IsRepeat(void) const
Definition: programinfo.h:478
int Track() const
int m_commmethod
Definition: channelinfo.h:108
QString GetRecordingGroup(void) const
Definition: programinfo.h:411
QString m_description
Definition: recordingrule.h:83
uint GetRecordingID(void) const
Definition: programinfo.h:438
void FillGenreList(DTC::GenreList *pGenreList, int videoID)
uint GetSeason(void) const
Definition: programinfo.h:358
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
QString GetCategoryTypeString(void) const
Returns catType as a string.
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:32
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
Definition: programinfo.h:389
QString Album() const
const QList< uint > GetGroupIds() const
Definition: channelinfo.h:47
QString m_seriesid
Definition: recordingrule.h:93
QString m_channum
Definition: channelinfo.h:76
QString GetPlaybackGroup(void) const
Definition: programinfo.h:412
RecordingDupInType m_dupIn
QString m_inetref
Definition: recordingrule.h:96
bool QueryKeyFramePosition(uint64_t *, uint64_t keyframe, bool backwards) const
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:427
uint64_t GetFilesize(void) const override
void FillCommBreak(DTC::CutList *pCutList, RecordingInfo *rInfo, int marktype)
uint GetYearOfInitialRelease(void) const
Definition: programinfo.h:415
QString m_name
input name
Definition: inputinfo.h:69
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:807
bool Load(uint lchanid=-1)
int Year() const
uint GetSubtitleType(void) const
Definition: programinfo.h:484
QString m_title
Definition: recordingrule.h:79
RecStatus::Type GetRecordingStatus(void) const
Definition: programinfo.h:439
uint GetEpisodeTotal(void) const
Definition: programinfo.h:360
QDateTime m_lastDeleted
uint m_atsc_minor_chan
Definition: channelinfo.h:103
uint m_sourceid
associated channel listings source
Definition: inputinfo.h:70
QString Title() const
RecordingType GetRecordingRuleType(void) const
Definition: programinfo.h:443
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:364
bool m_quickTune
Definition: inputinfo.h:78
static QString GetRecgroupString(uint recGroupID)
Temporary helper during transition from string to ID.
QString m_recProfile
uint GetRecordingRuleID(void) const
Definition: programinfo.h:441
QString ContentTypeToString(VideoContentType type)
Definition: videoutils.cpp:301
QString Filename(bool find=true)
uint m_scheduleOrder
Definition: inputinfo.h:76
QString GetProgramID(void) const
Definition: programinfo.h:428
bool m_visible
Definition: channelinfo.h:96
Genre * AddNewGenre()
Definition: genreList.h:53
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:396
void FillMusicMetadataInfo(DTC::MusicMetadataInfo *pVideoMetadataInfo, MusicMetadata *pMetadata, bool bDetails)
unsigned m_filter
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
Definition: programinfo.h:404
QString m_category
Definition: recordingrule.h:86
QString m_callsign
Definition: channelinfo.h:81
void FillInputInfo(DTC::Input *input, const InputInfo &inputInfo)
QDateTime GetLastModifiedTime(void) const
Definition: programinfo.h:421
QDateTime LastPlay() const
QString CompilationArtist() const
QString GetHostname(void) const
Definition: programinfo.h:413
QString GetInputName(void) const
Definition: programinfo.h:456
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
bool m_useonairguide
Definition: channelinfo.h:98
QString GetCategory(void) const
Definition: programinfo.h:361
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
Definition: programtypes.h:46
void FillVideoMetadataInfo(DTC::VideoMetadataInfo *pVideoMetadataInfo, const VideoMetadataListManager::VideoMetadataPtr &pMetadata, bool bDetails)
RecordingDupInType GetDuplicateCheckSource(void) const
Where should we check for duplicates?
Definition: programinfo.h:447
QString m_default_authority
Definition: channelinfo.h:107
void QueryPositionMap(frm_pos_map_t &, MarkTypes type) const
QString toRawString(RecordingType rectype)
Converts "rectype" into an untranslated string.
QMultiMap< VideoArtworkType, ArtworkInfo > ArtworkMap
QString GetPathname(void) const
Definition: programinfo.h:335
const QList< uint > GetInputIds() const
Definition: channelinfo.h:57
uint m_chanid
Definition: channelinfo.h:75
RecSearchType m_searchType
bool QueryKeyFrameDuration(uint64_t *, uint64_t keyframe, bool backwards) const
ArtworkMap GetArtwork(const QString &inetref, uint season, bool strict)
CastMember * AddNewCastMember()
uint GetEpisode(void) const
Definition: programinfo.h:359