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);
115 pProgram->enableChannel(
false);
136 pRecording->setFileName ( pRecInfo.
GetPathname() );
137 pRecording->setFileSize ( pRecInfo.
GetFilesize() );
138 pRecording->setHostName ( pRecInfo.
GetHostname() );
148 pRecording->setEncoderId ( pRecInfo.
GetInputID() );
155 pProgram->enableRecording(
false);
158 if ( bIncArtwork && !pInfo->
GetInetRef().isEmpty() )
161 pProgram->enableArtwork(
false);
173 if (channel.
Load(nChanID))
192 pChannel->setChanId(channelInfo.
m_chanId);
193 pChannel->setChanNum(channelInfo.
m_chanNum);
194 pChannel->setCallSign(channelInfo.
m_callSign);
195 if (!channelInfo.
m_icon.isEmpty())
197 QString sIconURL = QString(
"/Guide/GetChannelIcon?FileName=%1")
198 .arg( channelInfo.
m_icon );
199 pChannel->setIconURL( sIconURL );
200 pChannel->setIcon( channelInfo.
m_icon );
202 pChannel->setChannelName(channelInfo.
m_name);
208 pChannel->setMplexId(channelInfo.
m_mplexId);
213 pChannel->setFineTune(channelInfo.
m_fineTune);
214 pChannel->setFrequencyId(channelInfo.
m_freqId);
216 pChannel->setSourceId(channelInfo.
m_sourceId);
219 pChannel->setXMLTVID(channelInfo.
m_xmltvId);
223 pChannel->setTimeOffset(channelInfo.
m_tmOffset);
228 for (
int x = 0; x < groupIds.size(); x++)
233 sGroupIds += QString::number(groupIds.at(x));
235 pChannel->setChannelGroups(sGroupIds);
239 for (
int x = 0; x < inputIds.size(); x++)
244 sInputIds += QString::number(inputIds.at(x));
246 pChannel->setInputs(sInputIds);
257 pGroup->setGroupId(pGroupItem.
m_grpId);
258 pGroup->setName(pGroupItem.
m_name);
259 pGroup->setPassword(
"");
269 if ((pRecRule ==
nullptr) || (pRule ==
nullptr))
275 pRecRule->setTitle ( pRule->
m_title );
278 pRecRule->setSeason ( pRule->
m_season );
279 pRecRule->setEpisode ( pRule->
m_episode );
281 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
282 pRecRule->setStartTime ( QDateTime(pRule->
m_startdate,
284 pRecRule->setEndTime ( QDateTime(pRule->
m_enddate,
287 static const QTimeZone utc(QTimeZone::UTC);
288 pRecRule->setStartTime ( QDateTime(pRule->
m_startdate,
290 pRecRule->setEndTime ( QDateTime(pRule->
m_enddate,
295 pRecRule->setInetref ( pRule->
m_inetref );
297 pRecRule->setCallSign ( pRule->
m_station );
298 pRecRule->setFindDay ( pRule->
m_findday );
303 pRecRule->setPreferredInput ( pRule->
m_prefInput );
309 pRecRule->setFilter ( pRule->
m_filter );
333 const QString &sInetref,
337 for (
auto i = map.cbegin(); i != map.cend(); ++i)
340 pArtInfo->setFileName(i.value().url);
344 pArtInfo->setStorageGroup(
"Fanart");
345 pArtInfo->setType(
"fanart");
346 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
349 QString(QUrl::toPercentEncoding(
350 QUrl(i.value().url).path()))));
353 pArtInfo->setStorageGroup(
"Banners");
354 pArtInfo->setType(
"banner");
355 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
358 QString(QUrl::toPercentEncoding(
359 QUrl(i.value().url).path()))));
363 pArtInfo->setStorageGroup(
"Coverart");
364 pArtInfo->setType(
"coverart");
365 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
368 QString(QUrl::toPercentEncoding(
369 QUrl(i.value().url).path()))));
381 query.
prepare(
"SELECT genre from videogenre "
382 "LEFT JOIN videometadatagenre ON videometadatagenre.idgenre = videogenre.intid "
383 "WHERE idvideo = :ID "
387 if (query.
exec() && query.
size() > 0)
392 QString genre = query.
value(0).toString();
393 pGenre->setName(genre);
404 pVideoMetadataInfo->setId(pMetadata->GetID());
405 pVideoMetadataInfo->setTitle(pMetadata->GetTitle());
406 pVideoMetadataInfo->setSubTitle(pMetadata->GetSubtitle());
407 pVideoMetadataInfo->setTagline(pMetadata->GetTagline());
408 pVideoMetadataInfo->setDirector(pMetadata->GetDirector());
409 pVideoMetadataInfo->setStudio(pMetadata->GetStudio());
410 pVideoMetadataInfo->setDescription(pMetadata->GetPlot());
411 pVideoMetadataInfo->setCertification(pMetadata->GetRating());
412 pVideoMetadataInfo->setInetref(pMetadata->GetInetRef());
413 pVideoMetadataInfo->setCollectionref(pMetadata->GetCollectionRef());
414 pVideoMetadataInfo->setHomePage(pMetadata->GetHomepage());
415 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
416 pVideoMetadataInfo->setReleaseDate(
417 QDateTime(pMetadata->GetReleaseDate(),
418 QTime(0,0),Qt::LocalTime).toUTC());
419 pVideoMetadataInfo->setAddDate(
420 QDateTime(pMetadata->GetInsertdate(),
421 QTime(0,0),Qt::LocalTime).toUTC());
423 static const QTimeZone localtime(QTimeZone::LocalTime);
424 pVideoMetadataInfo->setReleaseDate(
425 QDateTime(pMetadata->GetReleaseDate(),
426 QTime(0,0),localtime).toUTC());
427 pVideoMetadataInfo->setAddDate(
428 QDateTime(pMetadata->GetInsertdate(),
429 QTime(0,0),localtime).toUTC());
431 pVideoMetadataInfo->setUserRating(pMetadata->GetUserRating());
432 pVideoMetadataInfo->setChildID(pMetadata->GetChildID());
433 pVideoMetadataInfo->setLength(pMetadata->GetLength().count());
434 pVideoMetadataInfo->setPlayCount(pMetadata->GetPlayCount());
435 pVideoMetadataInfo->setSeason(pMetadata->GetSeason());
436 pVideoMetadataInfo->setEpisode(pMetadata->GetEpisode());
437 pVideoMetadataInfo->setParentalLevel(pMetadata->GetShowLevel());
438 pVideoMetadataInfo->setVisible(pMetadata->GetBrowse());
439 pVideoMetadataInfo->setWatched(pMetadata->GetWatched());
440 pVideoMetadataInfo->setProcessed(pMetadata->GetProcessed());
442 pMetadata->GetContentType()));
443 pVideoMetadataInfo->setFileName(pMetadata->GetFilename());
444 pVideoMetadataInfo->setHash(pMetadata->GetHash());
445 pVideoMetadataInfo->setHostName(pMetadata->GetHost());
446 pVideoMetadataInfo->setCoverart(pMetadata->GetCoverFile());
447 pVideoMetadataInfo->setFanart(pMetadata->GetFanart());
448 pVideoMetadataInfo->setBanner(pMetadata->GetBanner());
449 pVideoMetadataInfo->setScreenshot(pMetadata->GetScreenshot());
450 pVideoMetadataInfo->setTrailer(pMetadata->GetTrailer());
454 if (!pMetadata->GetFanart().isEmpty())
457 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
458 pArtInfo->setStorageGroup(
"Fanart");
459 pArtInfo->setType(
"fanart");
460 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
464 QUrl::toPercentEncoding(pMetadata->GetFanart()))));
466 if (!pMetadata->GetCoverFile().isEmpty())
469 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
470 pArtInfo->setStorageGroup(
"Coverart");
471 pArtInfo->setType(
"coverart");
472 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
476 QUrl::toPercentEncoding(pMetadata->GetCoverFile()))));
478 if (!pMetadata->GetBanner().isEmpty())
481 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
482 pArtInfo->setStorageGroup(
"Banners");
483 pArtInfo->setType(
"banner");
484 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
488 QUrl::toPercentEncoding(pMetadata->GetBanner()))));
490 if (!pMetadata->GetScreenshot().isEmpty())
493 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
494 pArtInfo->setStorageGroup(
"Screenshots");
495 pArtInfo->setType(
"screenshot");
496 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
500 QUrl::toPercentEncoding(pMetadata->GetScreenshot()))));
506 auto castList = pMetadata->GetCast();
509 QString actors = QObject::tr(
"Actors");
513 pCastMember->setTranslatedRole(actors);
514 pCastMember->setRole(
"ACTOR");
515 pCastMember->setName(ent.second);
527 pVideoMetadataInfo->setId(pMetadata->
ID());
528 pVideoMetadataInfo->setArtist(pMetadata->
Artist());
530 pVideoMetadataInfo->setAlbum(pMetadata->
Album());
531 pVideoMetadataInfo->setTitle(pMetadata->
Title());
532 pVideoMetadataInfo->setTrackNo(pMetadata->
Track());
533 pVideoMetadataInfo->setGenre(pMetadata->
Genre());
534 pVideoMetadataInfo->setYear(pMetadata->
Year());
535 pVideoMetadataInfo->setPlayCount(pMetadata->
PlayCount());
536 pVideoMetadataInfo->setLength(pMetadata->
Length().count());
537 pVideoMetadataInfo->setRating(pMetadata->
Rating());
538 pVideoMetadataInfo->setFileName(pMetadata->
Filename());
539 pVideoMetadataInfo->setHostName(pMetadata->
Hostname());
540 pVideoMetadataInfo->setLastPlayed(pMetadata->
LastPlay());
541 pVideoMetadataInfo->setCompilation(pMetadata->
Compilation());
552 input->setInputName(inputInfo.
m_name);
567 if (!pCastMemberList || !pInfo)
574 table =
"recordedcredits";
578 query.
prepare(QString(
"SELECT role, people.name, roles.name FROM %1"
580 " LEFT JOIN people ON"
581 " credits.person = people.person"
582 " LEFT JOIN roles ON"
583 " credits.roleid = roles.roleid"
584 " WHERE credits.chanid = :CHANID"
585 " AND credits.starttime = :STARTTIME"
586 " ORDER BY role, priority;").arg(table));
591 if (query.
exec() && query.
size() > 0)
593 QMap<QString, QString> translations;
594 translations[
"ACTOR"] = QObject::tr(
"Actors");
595 translations[
"DIRECTOR"] = QObject::tr(
"Director");
596 translations[
"PRODUCER"] = QObject::tr(
"Producer");
597 translations[
"EXECUTIVE_PRODUCER"] = QObject::tr(
"Executive Producer");
598 translations[
"WRITER"] = QObject::tr(
"Writer");
599 translations[
"GUEST_STAR"] = QObject::tr(
"Guest Star");
600 translations[
"HOST"] = QObject::tr(
"Host");
601 translations[
"ADAPTER"] = QObject::tr(
"Adapter");
602 translations[
"PRESENTER"] = QObject::tr(
"Presenter");
603 translations[
"COMMENTATOR"] = QObject::tr(
"Commentator");
604 translations[
"GUEST"] = QObject::tr(
"Guest");
610 QString role = query.
value(0).toString();
611 pCastMember->setTranslatedRole(translations.value(role.toUpper()));
612 pCastMember->setRole(role);
628 pCastMember->setName(QString::fromUtf8(query.
value(1)
629 .toByteArray().constData()));
630 pCastMember->setCharacterName(QString::fromUtf8(query.
value(2)
631 .toByteArray().constData()));
641 frm_dir_map_t::const_iterator it;
648 it = markMap.cbegin();
649 if (it != markMap.cend())
652 pCutting->setMark(*it);
653 pCutting->setOffset(it.key());
659 for (it = markMap.cbegin(); it != markMap.cend(); ++it)
665 pCutting->setMark(*it);
666 pCutting->setOffset(it.key());
668 else if (marktype == 1)
674 pCutting->setMark(*it);
675 pCutting->setOffset(offset);
678 else if (marktype == 2)
684 pCutting->setMark(*it);
685 pCutting->setOffset(offset);
695 frm_dir_map_t::const_iterator it;
702 it = markMap.cbegin();
703 if (it != markMap.cend())
706 pCutting->setMark(*it);
707 pCutting->setOffset(it.key());
713 for (it = markMap.cbegin(); it != markMap.cend(); ++it)
719 pCutting->setMark(*it);
720 pCutting->setOffset(it.key());
722 else if (marktype == 1)
728 pCutting->setMark(*it);
729 pCutting->setOffset(offset);
732 else if (marktype == 2)
738 pCutting->setMark(*it);
739 pCutting->setOffset(offset);
753 frm_pos_map_t::const_iterator it;
759 for (it = markMap.cbegin(); it != markMap.cend(); ++it)
762 pCutting->setMark(it.key());
763 pCutting->setOffset(it.value());
772 for (
auto * elink : std::as_const(
gTVList))
774 if (elink !=
nullptr)
777 auto *pEncoder =
new V2Encoder( parent );
778 list.append( QVariant::fromValue<QObject *>( pEncoder ));
780 pEncoder->setId ( elink->GetInputID() );
781 pEncoder->setState ( elink->GetState() );
782 pEncoder->setLocal ( elink->IsLocal() );
783 pEncoder->setConnected ( elink->IsConnected() );
784 pEncoder->setSleepStatus ( elink->GetSleepStatus() );
786 if (pEncoder->GetLocal())
789 pEncoder->setHostName( elink->GetHostName() );
791 for (
const auto & inputInfo : std::as_const(inputInfoList))
793 if (inputInfo.m_inputId ==
static_cast<uint>(elink->GetInputID()))
795 V2Input *input = pEncoder->AddNewInput();
800 bool progFound =
false;
802 switch ( pEncoder->GetState() )
824 pProgram->setProperty(
"isNull",QVariant(
true));
837 const QString &Sort )
857 for (
auto it = tmpList.begin(); it < tmpList.end(); ++it)
859 if ((nRecStatus == -999
860 && (*it)->GetRecordingStatus() >= 0)
861 || (nRecStatus != 0 && nRecStatus != -999
862 && (*it)->GetRecordingStatus() != nRecStatus))
890 if (Sort.startsWith(
"channum", Qt::CaseInsensitive))
892 else if (Sort.startsWith(
"title", Qt::CaseInsensitive))
894 if (Sort.endsWith(
"desc", Qt::CaseInsensitive))
897 static QRegularExpression regex(
"[_-]");
908 return First->
GetChanNum().replace(regex,
".").toDouble()
909 < Second->GetChanNum().replace(regex,
".").toDouble();
911 return First->
GetChanNum().replace(regex,
".").toDouble()
912 > Second->GetChanNum().replace(regex,
".").toDouble();
914 return QString::compare(First->
GetTitle(), Second->GetTitle(), Qt::CaseInsensitive) < 0 ;
916 return QString::compare(First->
GetTitle(), Second->GetTitle(), Qt::CaseInsensitive) > 0 ;
923 std::stable_sort(recordingList.
begin(), recordingList.
end(), comp);
929 nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, (
int)recordingList.
size() ) : 0;
930 nCount = (nCount > 0) ? std::min( nCount, (
int)recordingList.
size() ) : recordingList.
size();
931 int nEndIndex = std::min((nStartIndex + nCount), (
int)recordingList.
size() );
933 for(
int n = nStartIndex; n < nEndIndex; n++)
936 auto *pProgram =
new V2Program( parent );
937 list.append( QVariant::fromValue<QObject *>( pProgram ));
941 return recordingList.
size();
946 QMap<QString, Frontend*> frontends;
952 for (
auto * fe : std::as_const(frontends))
955 list.append( QVariant::fromValue<QObject *>( pFrontend ));
956 pFrontend->setName(fe->m_name);
957 pFrontend->setIP(fe->m_ip.toString());
960 pFrontend->setPort(port);
961 pFrontend->setOnLine(fe->m_connectionCount > 0);
971 query.
prepare(
"INSERT INTO recgroups SET recgroup = :NAME, "
972 "displayname = :DISPLAYNAME");
974 query.
bindValue(
":DISPLAYNAME", groupName);
980 LOG(VB_GENERAL, LOG_ERR, QString(
"Could not create recording group (%1). "
981 "Does it already exist?").arg(groupName));
991 QJsonArray members = cast[
"CastMembers"].toArray();
992 for (
const auto & m : std::as_const(members))
994 QJsonObject actor = m.toObject();
995 QString name = actor.value(
"Name").toString(
"");
996 QString character = actor.value(
"CharacterName").toString(
"");
997 QString role = actor.value(
"Role").toString(
"");
999 credits->emplace_back(role, name, priority++, character);
1010 uint minor_max = 15;
1011 QString card = QString();
1014 QDir dev(
"/dev/v4l",
"video*", QDir::Name, QDir::System);
1016 card, driver,
false, pList, cardType);
1019 dev.setPath(
"/dev");
1021 card, driver,
false, pList, cardType);
1024 dev.setPath(
"/dev/dtv");
1026 card, driver,
false, pList, cardType);
1029 dev.setPath(
"/dev");
1030 dev.setNameFilters(QStringList(
"dtv*"));
1032 card, driver,
false, pList, cardType);
1039 const QString& card,
const QRegularExpression& driver,
1041 const QString & cardType)
1044 QMap<uint, uint> minorlist;
1045 QFileInfoList entries = dir.entryInfoList();
1046 for (
const auto & fi : std::as_const(entries))
1049 QString filepath = fi.absoluteFilePath();
1050 int err =
lstat(filepath.toLocal8Bit().constData(), &st);
1054 LOG(VB_GENERAL, LOG_ERR,
1055 QString(
"Could not stat file: %1").arg(filepath));
1060 if (!S_ISCHR(st.st_mode))
1065 if (minor_min > minor_num || minor_max < minor_num)
1069 if (!allow_duplicates && minorlist[minor_num])
1073 QByteArray
tmp = filepath.toLatin1();
1074 int videofd = open(
tmp.constData(), O_RDWR);
1078 QString driver_name;
1081 auto match = driver.match(driver_name);
1082 if ((!driver.pattern().isEmpty() || match.hasMatch()) &&
1083 (card.isEmpty() || (card_name == card)))
1086 pDev->setCardType (cardType);
1087 pDev->setVideoDevice (filepath);
1088 pDev->setFrontendName(card_name);
1091 pDev->setInputNames(inputs);
1093 pDev->setAudioDevices(inputs);
1094 if (cardType ==
"HDPVR")
1095 pDev->setChannelTimeout ( 15000 );
1102 minorlist[minor_num] = 1;
1112 #ifdef USING_FIREWIRE
1114 for (
auto &
info : list)
1116 auto* pDev = pList->AddCaptureDevice();
1117 pDev->setCardType (cardType);
1118 QString guid =
info.GetGUIDString();
1119 pDev->setVideoDevice (guid);
1121 pDev->setFirewireModel(model);
1122 pDev->setDescription(
info.m_product_name);
1123 pDev->setSignalTimeout ( 2000 );
1124 pDev->setChannelTimeout ( 9000 );
1126 #endif // USING_FIREWIRE