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);
135 pRecording->setFileName ( pRecInfo.
GetPathname() );
136 pRecording->setFileSize ( pRecInfo.
GetFilesize() );
137 pRecording->setHostName ( pRecInfo.
GetHostname() );
147 pRecording->setEncoderId ( pRecInfo.
GetInputID() );
154 pProgram->enableRecording(
false);
157 if ( bIncArtwork && !pInfo->
GetInetRef().isEmpty() )
160 pProgram->enableArtwork(
false);
172 if (channel.
Load(nChanID))
191 pChannel->setChanId(channelInfo.
m_chanId);
192 pChannel->setChanNum(channelInfo.
m_chanNum);
193 pChannel->setCallSign(channelInfo.
m_callSign);
194 if (!channelInfo.
m_icon.isEmpty())
196 QString sIconURL = QString(
"/Guide/GetChannelIcon?FileName=%1")
197 .arg( channelInfo.
m_icon );
198 pChannel->setIconURL( sIconURL );
199 pChannel->setIcon( channelInfo.
m_icon );
201 pChannel->setChannelName(channelInfo.
m_name);
207 pChannel->setMplexId(channelInfo.
m_mplexId);
212 pChannel->setFineTune(channelInfo.
m_fineTune);
213 pChannel->setFrequencyId(channelInfo.
m_freqId);
215 pChannel->setSourceId(channelInfo.
m_sourceId);
218 pChannel->setXMLTVID(channelInfo.
m_xmltvId);
222 pChannel->setTimeOffset(channelInfo.
m_tmOffset);
227 for (
int x = 0; x < groupIds.size(); x++)
232 sGroupIds += QString::number(groupIds.at(x));
234 pChannel->setChannelGroups(sGroupIds);
238 for (
int x = 0; x < inputIds.size(); x++)
243 sInputIds += QString::number(inputIds.at(x));
245 pChannel->setInputs(sInputIds);
256 pGroup->setGroupId(pGroupItem.
m_grpId);
257 pGroup->setName(pGroupItem.
m_name);
258 pGroup->setPassword(
"");
268 if ((pRecRule ==
nullptr) || (pRule ==
nullptr))
274 pRecRule->setTitle ( pRule->
m_title );
277 pRecRule->setSeason ( pRule->
m_season );
278 pRecRule->setEpisode ( pRule->
m_episode );
280 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
281 pRecRule->setStartTime ( QDateTime(pRule->
m_startdate,
283 pRecRule->setEndTime ( QDateTime(pRule->
m_enddate,
286 static const QTimeZone utc(QTimeZone::UTC);
287 pRecRule->setStartTime ( QDateTime(pRule->
m_startdate,
289 pRecRule->setEndTime ( QDateTime(pRule->
m_enddate,
294 pRecRule->setInetref ( pRule->
m_inetref );
296 pRecRule->setCallSign ( pRule->
m_station );
297 pRecRule->setFindDay ( pRule->
m_findday );
302 pRecRule->setPreferredInput ( pRule->
m_prefInput );
308 pRecRule->setFilter ( pRule->
m_filter );
332 const QString &sInetref,
336 for (
auto i = map.cbegin(); i != map.cend(); ++i)
339 pArtInfo->setFileName(i.value().url);
343 pArtInfo->setStorageGroup(
"Fanart");
344 pArtInfo->setType(
"fanart");
345 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
348 QString(QUrl::toPercentEncoding(
349 QUrl(i.value().url).path()))));
352 pArtInfo->setStorageGroup(
"Banners");
353 pArtInfo->setType(
"banner");
354 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
357 QString(QUrl::toPercentEncoding(
358 QUrl(i.value().url).path()))));
362 pArtInfo->setStorageGroup(
"Coverart");
363 pArtInfo->setType(
"coverart");
364 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
367 QString(QUrl::toPercentEncoding(
368 QUrl(i.value().url).path()))));
380 query.
prepare(
"SELECT genre from videogenre "
381 "LEFT JOIN videometadatagenre ON videometadatagenre.idgenre = videogenre.intid "
382 "WHERE idvideo = :ID "
386 if (query.
exec() && query.
size() > 0)
391 QString genre = query.
value(0).toString();
392 pGenre->setName(genre);
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 #if QT_VERSION < QT_VERSION_CHECK(6,5,0)
415 pVideoMetadataInfo->setReleaseDate(
416 QDateTime(pMetadata->GetReleaseDate(),
417 QTime(0,0),Qt::LocalTime).toUTC());
418 pVideoMetadataInfo->setAddDate(
419 QDateTime(pMetadata->GetInsertdate(),
420 QTime(0,0),Qt::LocalTime).toUTC());
422 static const QTimeZone localtime(QTimeZone::LocalTime);
423 pVideoMetadataInfo->setReleaseDate(
424 QDateTime(pMetadata->GetReleaseDate(),
425 QTime(0,0),localtime).toUTC());
426 pVideoMetadataInfo->setAddDate(
427 QDateTime(pMetadata->GetInsertdate(),
428 QTime(0,0),localtime).toUTC());
430 pVideoMetadataInfo->setUserRating(pMetadata->GetUserRating());
431 pVideoMetadataInfo->setChildID(pMetadata->GetChildID());
432 pVideoMetadataInfo->setLength(pMetadata->GetLength().count());
433 pVideoMetadataInfo->setPlayCount(pMetadata->GetPlayCount());
434 pVideoMetadataInfo->setSeason(pMetadata->GetSeason());
435 pVideoMetadataInfo->setEpisode(pMetadata->GetEpisode());
436 pVideoMetadataInfo->setParentalLevel(pMetadata->GetShowLevel());
437 pVideoMetadataInfo->setVisible(pMetadata->GetBrowse());
438 pVideoMetadataInfo->setWatched(pMetadata->GetWatched());
439 pVideoMetadataInfo->setProcessed(pMetadata->GetProcessed());
441 pMetadata->GetContentType()));
442 pVideoMetadataInfo->setFileName(pMetadata->GetFilename());
443 pVideoMetadataInfo->setHash(pMetadata->GetHash());
444 pVideoMetadataInfo->setHostName(pMetadata->GetHost());
445 pVideoMetadataInfo->setCoverart(pMetadata->GetCoverFile());
446 pVideoMetadataInfo->setFanart(pMetadata->GetFanart());
447 pVideoMetadataInfo->setBanner(pMetadata->GetBanner());
448 pVideoMetadataInfo->setScreenshot(pMetadata->GetScreenshot());
449 pVideoMetadataInfo->setTrailer(pMetadata->GetTrailer());
453 if (!pMetadata->GetFanart().isEmpty())
456 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
457 pArtInfo->setStorageGroup(
"Fanart");
458 pArtInfo->setType(
"fanart");
459 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
463 QUrl::toPercentEncoding(pMetadata->GetFanart()))));
465 if (!pMetadata->GetCoverFile().isEmpty())
468 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
469 pArtInfo->setStorageGroup(
"Coverart");
470 pArtInfo->setType(
"coverart");
471 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
475 QUrl::toPercentEncoding(pMetadata->GetCoverFile()))));
477 if (!pMetadata->GetBanner().isEmpty())
480 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
481 pArtInfo->setStorageGroup(
"Banners");
482 pArtInfo->setType(
"banner");
483 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
487 QUrl::toPercentEncoding(pMetadata->GetBanner()))));
489 if (!pMetadata->GetScreenshot().isEmpty())
492 pVideoMetadataInfo->
Artwork()->AddNewArtworkInfo();
493 pArtInfo->setStorageGroup(
"Screenshots");
494 pArtInfo->setType(
"screenshot");
495 pArtInfo->setURL(QString(
"/Content/GetImageFile?StorageGroup=%1"
499 QUrl::toPercentEncoding(pMetadata->GetScreenshot()))));
505 auto castList = pMetadata->GetCast();
508 QString actors = QObject::tr(
"Actors");
512 pCastMember->setTranslatedRole(actors);
513 pCastMember->setRole(
"ACTOR");
514 pCastMember->setName(ent.second);
526 pVideoMetadataInfo->setId(pMetadata->
ID());
527 pVideoMetadataInfo->setArtist(pMetadata->
Artist());
529 pVideoMetadataInfo->setAlbum(pMetadata->
Album());
530 pVideoMetadataInfo->setTitle(pMetadata->
Title());
531 pVideoMetadataInfo->setTrackNo(pMetadata->
Track());
532 pVideoMetadataInfo->setGenre(pMetadata->
Genre());
533 pVideoMetadataInfo->setYear(pMetadata->
Year());
534 pVideoMetadataInfo->setPlayCount(pMetadata->
PlayCount());
535 pVideoMetadataInfo->setLength(pMetadata->
Length().count());
536 pVideoMetadataInfo->setRating(pMetadata->
Rating());
537 pVideoMetadataInfo->setFileName(pMetadata->
Filename());
538 pVideoMetadataInfo->setHostName(pMetadata->
Hostname());
539 pVideoMetadataInfo->setLastPlayed(pMetadata->
LastPlay());
540 pVideoMetadataInfo->setCompilation(pMetadata->
Compilation());
551 input->setInputName(inputInfo.
m_name);
566 if (!pCastMemberList || !pInfo)
573 table =
"recordedcredits";
577 query.
prepare(QString(
"SELECT role, people.name, roles.name FROM %1"
579 " LEFT JOIN people ON"
580 " credits.person = people.person"
581 " LEFT JOIN roles ON"
582 " credits.roleid = roles.roleid"
583 " WHERE credits.chanid = :CHANID"
584 " AND credits.starttime = :STARTTIME"
585 " ORDER BY role, priority;").arg(table));
590 if (query.
exec() && query.
size() > 0)
592 QMap<QString, QString> translations;
593 translations[
"ACTOR"] = QObject::tr(
"Actors");
594 translations[
"DIRECTOR"] = QObject::tr(
"Director");
595 translations[
"PRODUCER"] = QObject::tr(
"Producer");
596 translations[
"EXECUTIVE_PRODUCER"] = QObject::tr(
"Executive Producer");
597 translations[
"WRITER"] = QObject::tr(
"Writer");
598 translations[
"GUEST_STAR"] = QObject::tr(
"Guest Star");
599 translations[
"HOST"] = QObject::tr(
"Host");
600 translations[
"ADAPTER"] = QObject::tr(
"Adapter");
601 translations[
"PRESENTER"] = QObject::tr(
"Presenter");
602 translations[
"COMMENTATOR"] = QObject::tr(
"Commentator");
603 translations[
"GUEST"] = QObject::tr(
"Guest");
609 QString role = query.
value(0).toString();
610 pCastMember->setTranslatedRole(translations.value(role.toUpper()));
611 pCastMember->setRole(role);
627 pCastMember->setName(QString::fromUtf8(query.
value(1)
628 .toByteArray().constData()));
629 pCastMember->setCharacterName(QString::fromUtf8(query.
value(2)
630 .toByteArray().constData()));
640 frm_dir_map_t::const_iterator it;
647 it = markMap.cbegin();
648 if (it != markMap.cend())
651 pCutting->setMark(*it);
652 pCutting->setOffset(it.key());
658 for (it = markMap.cbegin(); it != markMap.cend(); ++it)
664 pCutting->setMark(*it);
665 pCutting->setOffset(it.key());
667 else if (marktype == 1)
673 pCutting->setMark(*it);
674 pCutting->setOffset(offset);
677 else if (marktype == 2)
683 pCutting->setMark(*it);
684 pCutting->setOffset(offset);
694 frm_dir_map_t::const_iterator it;
701 it = markMap.cbegin();
702 if (it != markMap.cend())
705 pCutting->setMark(*it);
706 pCutting->setOffset(it.key());
712 for (it = markMap.cbegin(); it != markMap.cend(); ++it)
718 pCutting->setMark(*it);
719 pCutting->setOffset(it.key());
721 else if (marktype == 1)
727 pCutting->setMark(*it);
728 pCutting->setOffset(offset);
731 else if (marktype == 2)
737 pCutting->setMark(*it);
738 pCutting->setOffset(offset);
752 frm_pos_map_t::const_iterator it;
758 for (it = markMap.cbegin(); it != markMap.cend(); ++it)
761 pCutting->setMark(it.key());
762 pCutting->setOffset(it.value());
771 for (
auto * elink : std::as_const(
gTVList))
773 if (elink !=
nullptr)
776 auto *pEncoder =
new V2Encoder( parent );
777 list.append( QVariant::fromValue<QObject *>( pEncoder ));
779 pEncoder->setId ( elink->GetInputID() );
780 pEncoder->setState ( elink->GetState() );
781 pEncoder->setLocal ( elink->IsLocal() );
782 pEncoder->setConnected ( elink->IsConnected() );
783 pEncoder->setSleepStatus ( elink->GetSleepStatus() );
785 if (pEncoder->GetLocal())
788 pEncoder->setHostName( elink->GetHostName() );
790 for (
const auto & inputInfo : std::as_const(inputInfoList))
792 if (inputInfo.m_inputId ==
static_cast<uint>(elink->GetInputID()))
794 V2Input *input = pEncoder->AddNewInput();
799 bool progFound =
false;
801 switch ( pEncoder->GetState() )
823 pProgram->setProperty(
"isNull",QVariant(
true));
836 const QString &Sort )
856 for (
auto it = tmpList.begin(); it < tmpList.end(); ++it)
858 if ((nRecStatus == -999
859 && (*it)->GetRecordingStatus() >= 0)
860 || (nRecStatus != 0 && nRecStatus != -999
861 && (*it)->GetRecordingStatus() != nRecStatus))
889 if (Sort.startsWith(
"channum", Qt::CaseInsensitive))
891 else if (Sort.startsWith(
"title", Qt::CaseInsensitive))
893 if (Sort.endsWith(
"desc", Qt::CaseInsensitive))
896 static QRegularExpression regex(
"[_-]");
907 return First->
GetChanNum().replace(regex,
".").toDouble()
908 < Second->GetChanNum().replace(regex,
".").toDouble();
910 return First->
GetChanNum().replace(regex,
".").toDouble()
911 > Second->GetChanNum().replace(regex,
".").toDouble();
913 return QString::compare(First->
GetTitle(), Second->GetTitle(), Qt::CaseInsensitive) < 0 ;
915 return QString::compare(First->
GetTitle(), Second->GetTitle(), Qt::CaseInsensitive) > 0 ;
922 std::stable_sort(recordingList.
begin(), recordingList.
end(), comp);
928 nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, (
int)recordingList.
size() ) : 0;
929 nCount = (nCount > 0) ? std::min( nCount, (
int)recordingList.
size() ) : recordingList.
size();
930 int nEndIndex = std::min((nStartIndex + nCount), (
int)recordingList.
size() );
932 for(
int n = nStartIndex; n < nEndIndex; n++)
935 auto *pProgram =
new V2Program( parent );
936 list.append( QVariant::fromValue<QObject *>( pProgram ));
940 return recordingList.
size();
945 QMap<QString, Frontend*> frontends;
951 for (
auto * fe : std::as_const(frontends))
954 list.append( QVariant::fromValue<QObject *>( pFrontend ));
955 pFrontend->setName(fe->m_name);
956 pFrontend->setIP(fe->m_ip.toString());
959 pFrontend->setPort(port);
960 pFrontend->setOnLine(fe->m_connectionCount > 0);
970 query.
prepare(
"INSERT INTO recgroups SET recgroup = :NAME, "
971 "displayname = :DISPLAYNAME");
973 query.
bindValue(
":DISPLAYNAME", groupName);
979 LOG(VB_GENERAL, LOG_ERR, QString(
"Could not create recording group (%1). "
980 "Does it already exist?").arg(groupName));
990 QJsonArray members = cast[
"CastMembers"].toArray();
991 for (
const auto & m : std::as_const(members))
993 QJsonObject actor = m.toObject();
994 QString name = actor.value(
"Name").toString(
"");
995 QString character = actor.value(
"CharacterName").toString(
"");
996 QString role = actor.value(
"Role").toString(
"");
998 credits->emplace_back(role, name, priority++, character);
1009 uint minor_max = 15;
1010 QString card = QString();
1013 QDir dev(
"/dev/v4l",
"video*", QDir::Name, QDir::System);
1015 card, driver,
false, pList, cardType);
1018 dev.setPath(
"/dev");
1020 card, driver,
false, pList, cardType);
1023 dev.setPath(
"/dev/dtv");
1025 card, driver,
false, pList, cardType);
1028 dev.setPath(
"/dev");
1029 dev.setNameFilters(QStringList(
"dtv*"));
1031 card, driver,
false, pList, cardType);
1038 const QString& card,
const QRegularExpression& driver,
1040 const QString & cardType)
1043 QMap<uint, uint> minorlist;
1044 QFileInfoList entries = dir.entryInfoList();
1045 for (
const auto & fi : std::as_const(entries))
1048 QString filepath = fi.absoluteFilePath();
1049 int err =
lstat(filepath.toLocal8Bit().constData(), &st);
1053 LOG(VB_GENERAL, LOG_ERR,
1054 QString(
"Could not stat file: %1").arg(filepath));
1059 if (!S_ISCHR(st.st_mode))
1064 if (minor_min > minor_num || minor_max < minor_num)
1068 if (!allow_duplicates && minorlist[minor_num])
1072 QByteArray
tmp = filepath.toLatin1();
1073 int videofd = open(
tmp.constData(), O_RDWR);
1077 QString driver_name;
1080 auto match = driver.match(driver_name);
1081 if ((!driver.pattern().isEmpty() || match.hasMatch()) &&
1082 (card.isEmpty() || (card_name == card)))
1085 pDev->setCardType (cardType);
1086 pDev->setVideoDevice (filepath);
1087 pDev->setFrontendName(card_name);
1090 pDev->setInputNames(inputs);
1092 pDev->setAudioDevices(inputs);
1093 if (cardType ==
"HDPVR")
1094 pDev->setChannelTimeout ( 15000 );
1101 minorlist[minor_num] = 1;
1111 #ifdef USING_FIREWIRE
1113 for (
auto &
info : list)
1115 auto* pDev = pList->AddCaptureDevice();
1116 pDev->setCardType (cardType);
1117 QString guid =
info.GetGUIDString();
1118 pDev->setVideoDevice (guid);
1120 pDev->setFirewireModel(model);
1121 pDev->setDescription(
info.m_product_name);
1122 pDev->setSignalTimeout ( 2000 );
1123 pDev->setChannelTimeout ( 9000 );
1125 #endif // USING_FIREWIRE