4 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(_WIN32)
7 #include <sys/sysmacros.h>
13 #include <QFileInfoList>
15 #include <QJsonObject>
48 if ((pProgram ==
nullptr) || (pInfo ==
nullptr))
53 pProgram->setTitle ( pInfo->
GetTitle() );
57 pProgram->setRepeat ( pInfo->
IsRepeat() );
69 pProgram->setStars ( pInfo->
GetStars() );
87 pProgram->setAirdate( year );
92 pProgram->setSeason ( pInfo->
GetSeason() );
100 pProgram->enableCast(
false);
114 pProgram->enableChannel(
false);
133 pRecording->setFileName ( pRecInfo.
GetPathname() );
134 pRecording->setFileSize ( pRecInfo.
GetFilesize() );
135 pRecording->setHostName ( pRecInfo.
GetHostname() );
145 pRecording->setEncoderId ( pRecInfo.
GetInputID() );
151 pProgram->enableRecording(
false);
153 if ( bIncArtwork && !pInfo->
GetInetRef().isEmpty() )
156 pProgram->enableArtwork(
false);
168 if (channel.
Load(nChanID))
187 pChannel->setChanId(channelInfo.
m_chanId);
188 pChannel->setChanNum(channelInfo.
m_chanNum);
189 pChannel->setCallSign(channelInfo.
m_callSign);
190 if (!channelInfo.
m_icon.isEmpty())
192 QString sIconURL = QString(
"/Guide/GetChannelIcon?FileName=%1")
193 .arg( channelInfo.
m_icon );
194 pChannel->setIconURL( sIconURL );
195 pChannel->setIcon( channelInfo.
m_icon );
197 pChannel->setChannelName(channelInfo.
m_name);
203 pChannel->setMplexId(channelInfo.
m_mplexId);
208 pChannel->setFineTune(channelInfo.
m_fineTune);
209 pChannel->setFrequencyId(channelInfo.
m_freqId);
211 pChannel->setSourceId(channelInfo.
m_sourceId);
214 pChannel->setXMLTVID(channelInfo.
m_xmltvId);
218 pChannel->setTimeOffset(channelInfo.
m_tmOffset);
223 for (
int x = 0; x < groupIds.size(); x++)
228 sGroupIds += QString::number(groupIds.at(x));
230 pChannel->setChannelGroups(sGroupIds);
234 for (
int x = 0; x < inputIds.size(); x++)
239 sInputIds += QString::number(inputIds.at(x));
241 pChannel->setInputs(sInputIds);
252 pGroup->setGroupId(pGroupItem.
m_grpId);
253 pGroup->setName(pGroupItem.
m_name);
254 pGroup->setPassword(
"");
264 if ((pRecRule ==
nullptr) || (pRule ==
nullptr))
270 pRecRule->setTitle ( pRule->
m_title );
273 pRecRule->setSeason ( pRule->
m_season );
274 pRecRule->setEpisode ( pRule->
m_episode );
276 pRecRule->setStartTime ( QDateTime(pRule->
m_startdate,
278 pRecRule->setEndTime ( QDateTime(pRule->
m_enddate,
282 pRecRule->setInetref ( pRule->
m_inetref );
284 pRecRule->setCallSign ( pRule->
m_station );
285 pRecRule->setFindDay ( pRule->
m_findday );
290 pRecRule->setPreferredInput ( pRule->
m_prefInput );
296 pRecRule->setFilter ( pRule->
m_filter );
320 const QString &sInetref,
324 for (
auto i = map.cbegin(); i != map.cend(); ++i)
327 pArtInfo->setFileName(i.value().url);
331 pArtInfo->setStorageGroup(
"Fanart");
332 pArtInfo->setType(
"fanart");
333 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
336 QString(QUrl::toPercentEncoding(
337 QUrl(i.value().url).path()))));
340 pArtInfo->setStorageGroup(
"Banners");
341 pArtInfo->setType(
"banner");
342 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
345 QString(QUrl::toPercentEncoding(
346 QUrl(i.value().url).path()))));
350 pArtInfo->setStorageGroup(
"Coverart");
351 pArtInfo->setType(
"coverart");
352 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
355 QString(QUrl::toPercentEncoding(
356 QUrl(i.value().url).path()))));
368 query.
prepare(
"SELECT genre from videogenre "
369 "LEFT JOIN videometadatagenre ON videometadatagenre.idgenre = videogenre.intid "
370 "WHERE idvideo = :ID "
374 if (query.
exec() && query.
size() > 0)
379 QString genre = query.
value(0).toString();
380 pGenre->setName(genre);
391 pVideoMetadataInfo->setId(pMetadata->GetID());
392 pVideoMetadataInfo->setTitle(pMetadata->GetTitle());
393 pVideoMetadataInfo->setSubTitle(pMetadata->GetSubtitle());
394 pVideoMetadataInfo->setTagline(pMetadata->GetTagline());
395 pVideoMetadataInfo->setDirector(pMetadata->GetDirector());
396 pVideoMetadataInfo->setStudio(pMetadata->GetStudio());
397 pVideoMetadataInfo->setDescription(pMetadata->GetPlot());
398 pVideoMetadataInfo->setCertification(pMetadata->GetRating());
399 pVideoMetadataInfo->setInetref(pMetadata->GetInetRef());
400 pVideoMetadataInfo->setCollectionref(pMetadata->GetCollectionRef());
401 pVideoMetadataInfo->setHomePage(pMetadata->GetHomepage());
402 pVideoMetadataInfo->setReleaseDate(
403 QDateTime(pMetadata->GetReleaseDate(),
404 QTime(0,0),Qt::LocalTime).toUTC());
405 pVideoMetadataInfo->setAddDate(
406 QDateTime(pMetadata->GetInsertdate(),
407 QTime(0,0),Qt::LocalTime).toUTC());
408 pVideoMetadataInfo->setUserRating(pMetadata->GetUserRating());
409 pVideoMetadataInfo->setChildID(pMetadata->GetChildID());
410 pVideoMetadataInfo->setLength(pMetadata->GetLength().count());
411 pVideoMetadataInfo->setPlayCount(pMetadata->GetPlayCount());
412 pVideoMetadataInfo->setSeason(pMetadata->GetSeason());
413 pVideoMetadataInfo->setEpisode(pMetadata->GetEpisode());
414 pVideoMetadataInfo->setParentalLevel(pMetadata->GetShowLevel());
415 pVideoMetadataInfo->setVisible(pMetadata->GetBrowse());
416 pVideoMetadataInfo->setWatched(pMetadata->GetWatched());
417 pVideoMetadataInfo->setProcessed(pMetadata->GetProcessed());
419 pMetadata->GetContentType()));
420 pVideoMetadataInfo->setFileName(pMetadata->GetFilename());
421 pVideoMetadataInfo->setHash(pMetadata->GetHash());
422 pVideoMetadataInfo->setHostName(pMetadata->GetHost());
423 pVideoMetadataInfo->setCoverart(pMetadata->GetCoverFile());
424 pVideoMetadataInfo->setFanart(pMetadata->GetFanart());
425 pVideoMetadataInfo->setBanner(pMetadata->GetBanner());
426 pVideoMetadataInfo->setScreenshot(pMetadata->GetScreenshot());
427 pVideoMetadataInfo->setTrailer(pMetadata->GetTrailer());
431 if (!pMetadata->GetFanart().isEmpty())
434 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
435 pArtInfo->setStorageGroup(
"Fanart");
436 pArtInfo->setType(
"fanart");
437 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
441 QUrl::toPercentEncoding(pMetadata->GetFanart()))));
443 if (!pMetadata->GetCoverFile().isEmpty())
446 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
447 pArtInfo->setStorageGroup(
"Coverart");
448 pArtInfo->setType(
"coverart");
449 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
453 QUrl::toPercentEncoding(pMetadata->GetCoverFile()))));
455 if (!pMetadata->GetBanner().isEmpty())
458 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
459 pArtInfo->setStorageGroup(
"Banners");
460 pArtInfo->setType(
"banner");
461 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
465 QUrl::toPercentEncoding(pMetadata->GetBanner()))));
467 if (!pMetadata->GetScreenshot().isEmpty())
470 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
471 pArtInfo->setStorageGroup(
"Screenshots");
472 pArtInfo->setType(
"screenshot");
473 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
477 QUrl::toPercentEncoding(pMetadata->GetScreenshot()))));
483 auto castList = pMetadata->GetCast();
486 QString actors = QObject::tr(
"Actors");
490 pCastMember->setTranslatedRole(actors);
491 pCastMember->setRole(
"ACTOR");
492 pCastMember->setName(ent.second);
504 pVideoMetadataInfo->setId(pMetadata->
ID());
505 pVideoMetadataInfo->setArtist(pMetadata->
Artist());
507 pVideoMetadataInfo->setAlbum(pMetadata->
Album());
508 pVideoMetadataInfo->setTitle(pMetadata->
Title());
509 pVideoMetadataInfo->setTrackNo(pMetadata->
Track());
510 pVideoMetadataInfo->setGenre(pMetadata->
Genre());
511 pVideoMetadataInfo->setYear(pMetadata->
Year());
512 pVideoMetadataInfo->setPlayCount(pMetadata->
PlayCount());
513 pVideoMetadataInfo->setLength(pMetadata->
Length().count());
514 pVideoMetadataInfo->setRating(pMetadata->
Rating());
515 pVideoMetadataInfo->setFileName(pMetadata->
Filename());
516 pVideoMetadataInfo->setHostName(pMetadata->
Hostname());
517 pVideoMetadataInfo->setLastPlayed(pMetadata->
LastPlay());
518 pVideoMetadataInfo->setCompilation(pMetadata->
Compilation());
529 input->setInputName(inputInfo.
m_name);
544 if (!pCastMemberList || !pInfo)
551 table =
"recordedcredits";
555 query.
prepare(QString(
"SELECT role, people.name, roles.name FROM %1"
557 " LEFT JOIN people ON"
558 " credits.person = people.person"
559 " LEFT JOIN roles ON"
560 " credits.roleid = roles.roleid"
561 " WHERE credits.chanid = :CHANID"
562 " AND credits.starttime = :STARTTIME"
563 " ORDER BY role, priority;").arg(table));
568 if (query.
exec() && query.
size() > 0)
570 QMap<QString, QString> translations;
571 translations[
"ACTOR"] = QObject::tr(
"Actors");
572 translations[
"DIRECTOR"] = QObject::tr(
"Director");
573 translations[
"PRODUCER"] = QObject::tr(
"Producer");
574 translations[
"EXECUTIVE_PRODUCER"] = QObject::tr(
"Executive Producer");
575 translations[
"WRITER"] = QObject::tr(
"Writer");
576 translations[
"GUEST_STAR"] = QObject::tr(
"Guest Star");
577 translations[
"HOST"] = QObject::tr(
"Host");
578 translations[
"ADAPTER"] = QObject::tr(
"Adapter");
579 translations[
"PRESENTER"] = QObject::tr(
"Presenter");
580 translations[
"COMMENTATOR"] = QObject::tr(
"Commentator");
581 translations[
"GUEST"] = QObject::tr(
"Guest");
587 QString role = query.
value(0).toString();
588 pCastMember->setTranslatedRole(translations.value(role.toUpper()));
589 pCastMember->setRole(role);
605 pCastMember->setName(QString::fromUtf8(query.
value(1)
606 .toByteArray().constData()));
607 pCastMember->setCharacterName(QString::fromUtf8(query.
value(2)
608 .toByteArray().constData()));
618 frm_dir_map_t::const_iterator it;
624 for (it = markMap.cbegin(); it != markMap.cend(); ++it)
630 pCutting->setMark(*it);
631 pCutting->setOffset(it.key());
633 else if (marktype == 1)
639 pCutting->setMark(*it);
640 pCutting->setOffset(offset);
643 else if (marktype == 2)
649 pCutting->setMark(*it);
650 pCutting->setOffset(offset);
660 frm_dir_map_t::const_iterator it;
666 for (it = markMap.cbegin(); it != markMap.cend(); ++it)
672 pCutting->setMark(*it);
673 pCutting->setOffset(it.key());
675 else if (marktype == 1)
681 pCutting->setMark(*it);
682 pCutting->setOffset(offset);
685 else if (marktype == 2)
691 pCutting->setMark(*it);
692 pCutting->setOffset(offset);
706 frm_pos_map_t::const_iterator it;
712 for (it = markMap.cbegin(); it != markMap.cend(); ++it)
715 pCutting->setMark(it.key());
716 pCutting->setOffset(it.value());
725 for (
auto * elink : std::as_const(
gTVList))
727 if (elink !=
nullptr)
730 auto *pEncoder =
new V2Encoder( parent );
731 list.append( QVariant::fromValue<QObject *>( pEncoder ));
733 pEncoder->setId ( elink->GetInputID() );
734 pEncoder->setState ( elink->GetState() );
735 pEncoder->setLocal ( elink->IsLocal() );
736 pEncoder->setConnected ( elink->IsConnected() );
737 pEncoder->setSleepStatus ( elink->GetSleepStatus() );
739 if (pEncoder->GetLocal())
742 pEncoder->setHostName( elink->GetHostName() );
744 for (
const auto & inputInfo : std::as_const(inputInfoList))
746 if (inputInfo.m_inputId ==
static_cast<uint>(elink->GetInputID()))
748 V2Input *input = pEncoder->AddNewInput();
753 bool progFound =
false;
755 switch ( pEncoder->GetState() )
777 pProgram->setProperty(
"isNull",QVariant(
true));
790 const QString &Sort )
810 for (
auto it = tmpList.begin(); it < tmpList.end(); ++it)
812 if ((nRecStatus == -999
813 && (*it)->GetRecordingStatus() >= 0)
814 || (nRecStatus != 0 && nRecStatus != -999
815 && (*it)->GetRecordingStatus() != nRecStatus))
843 if (Sort.startsWith(
"channum", Qt::CaseInsensitive))
845 else if (Sort.startsWith(
"title", Qt::CaseInsensitive))
847 if (Sort.endsWith(
"desc"), Qt::CaseInsensitive)
859 return First->
GetChanNum().replace(
'-',
'.').toDouble() < Second->GetChanNum().replace(
'-',
'.').toDouble();
861 return First->
GetChanNum().replace(
'-',
'.').toDouble() > Second->GetChanNum().replace(
'-',
'.').toDouble();
863 return QString::compare(First->
GetTitle(), Second->GetTitle(), Qt::CaseInsensitive) < 0 ;
865 return QString::compare(First->
GetTitle(), Second->GetTitle(), Qt::CaseInsensitive) > 0 ;
872 std::stable_sort(recordingList.
begin(), recordingList.
end(), comp);
878 nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, (
int)recordingList.
size() ) : 0;
879 nCount = (nCount > 0) ? std::min( nCount, (
int)recordingList.
size() ) : recordingList.
size();
880 int nEndIndex = std::min((nStartIndex + nCount), (
int)recordingList.
size() );
882 for(
int n = nStartIndex; n < nEndIndex; n++)
885 auto *pProgram =
new V2Program( parent );
886 list.append( QVariant::fromValue<QObject *>( pProgram ));
890 return recordingList.
size();
895 QMap<QString, Frontend*> frontends;
901 for (
auto * fe : std::as_const(frontends))
904 list.append( QVariant::fromValue<QObject *>( pFrontend ));
905 pFrontend->setName(fe->m_name);
906 pFrontend->setIP(fe->m_ip.toString());
909 pFrontend->setPort(port);
910 pFrontend->setOnLine(fe->m_connectionCount > 0);
920 query.
prepare(
"INSERT INTO recgroups SET recgroup = :NAME, "
921 "displayname = :DISPLAYNAME");
923 query.
bindValue(
":DISPLAYNAME", groupName);
929 LOG(VB_GENERAL, LOG_ERR, QString(
"Could not create recording group (%1). "
930 "Does it already exist?").arg(groupName));
940 QJsonArray members = cast[
"CastMembers"].toArray();
941 for (
const auto & m : std::as_const(members))
943 QJsonObject actor = m.toObject();
944 QString name = actor.value(
"Name").toString(
"");
945 QString character = actor.value(
"CharacterName").toString(
"");
946 QString role = actor.value(
"Role").toString(
"");
948 credits->emplace_back(role, name, priority++, character);
960 QString card = QString();
963 QDir dev(
"/dev/v4l",
"video*", QDir::Name, QDir::System);
965 card, driver,
false, pList, cardType);
970 card, driver,
false, pList, cardType);
973 dev.setPath(
"/dev/dtv");
975 card, driver,
false, pList, cardType);
979 dev.setNameFilters(QStringList(
"dtv*"));
981 card, driver,
false, pList, cardType);
988 const QString& card,
const QRegularExpression& driver,
990 const QString & cardType)
993 QMap<uint, uint> minorlist;
994 QFileInfoList entries = dir.entryInfoList();
995 for (
const auto & fi : std::as_const(entries))
998 QString filepath = fi.absoluteFilePath();
999 int err =
lstat(filepath.toLocal8Bit().constData(), &st);
1003 LOG(VB_GENERAL, LOG_ERR,
1004 QString(
"Could not stat file: %1").arg(filepath));
1009 if (!S_ISCHR(st.st_mode))
1014 if (minor_min > minor_num || minor_max < minor_num)
1018 if (!allow_duplicates && minorlist[minor_num])
1022 QByteArray
tmp = filepath.toLatin1();
1023 int videofd = open(
tmp.constData(), O_RDWR);
1027 QString driver_name;
1030 auto match = driver.match(driver_name);
1031 if ((!driver.pattern().isEmpty() || match.hasMatch()) &&
1032 (card.isEmpty() || (card_name == card)))
1035 pDev->setCardType (cardType);
1036 pDev->setVideoDevice (filepath);
1037 pDev->setFrontendName(card_name);
1040 pDev->setInputNames(inputs);
1042 pDev->setAudioDevices(inputs);
1043 if (cardType ==
"HDPVR")
1044 pDev->setChannelTimeout ( 15000 );
1051 minorlist[minor_num] = 1;
1061 #ifdef USING_FIREWIRE
1063 for (
auto & info : list)
1065 auto* pDev = pList->AddCaptureDevice();
1066 pDev->setCardType (cardType);
1067 QString guid = info.GetGUIDString();
1068 pDev->setVideoDevice (guid);
1070 pDev->setFirewireModel(model);
1071 pDev->setDescription(info.m_product_name);
1072 pDev->setSignalTimeout ( 2000 );
1073 pDev->setChannelTimeout ( 9000 );
1075 #endif // USING_FIREWIRE