Skip to content

Commit

Permalink
limit flat recordings, disable archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Ehrnsperger committed Dec 1, 2023
1 parent 6b9dda8 commit 5de0a5d
Show file tree
Hide file tree
Showing 14 changed files with 304 additions and 175 deletions.
37 changes: 7 additions & 30 deletions largeString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,6 @@ void cLargeString::init(size_t initialSize, size_t increaseSize, bool debugBuffe
m_buffer_end = m_s + initialSize;
m_string_end = m_s;
}
void cLargeString::loadFile(const char *filename, bool *exists) {
if (exists) *exists = false;
if (!filename) return;
struct stat buffer;
if (stat(filename, &buffer) != 0) return;

// file exists, length buffer.st_size
if (exists) *exists = true;
if (buffer.st_size == 0) return; // empty file
m_s = (char *) malloc((size_t)(buffer.st_size + 1) * sizeof(char)); // add one. So we can add the 0 string terminator
if (!m_s) {
esyslog("cLargeString::loadFile, ERROR out of memory, name = %.*s, filename = %s, requested size = %zu", nameLen(), nameData(), filename, (size_t)(buffer.st_size + 1));
throw std::runtime_error("cLargeString::cLargeString, ERROR out of memory (file)");
return;
}
m_buffer_end = m_s + buffer.st_size + 1;
m_string_end = m_s;
FILE *f = fopen(filename, "rb");
if (!f) {
esyslog("cLargeString::loadFile, ERROR: stat OK, fopen fails, filename %s", filename);
return;
}
size_t num_read = fread (m_s, 1, (size_t)buffer.st_size, f);
fclose(f);
m_string_end = m_s + num_read;
if (num_read != (size_t)buffer.st_size) {
esyslog("cLargeString::loadFile, ERROR: num_read = %zu, buffer.st_size = %zu, ferror %i, name = %.*s, filename %s", num_read, (size_t)buffer.st_size, ferror(f), nameLen(), nameData(), filename);
m_string_end = m_s + std::min(num_read, (size_t)buffer.st_size);
}
}

cLargeString::~cLargeString() {
if (m_s == m_s_initial) return;
Expand Down Expand Up @@ -152,3 +122,10 @@ void cLargeString::enlarge(size_t increaseSize) {
m_buffer_end = m_s + newSize;
m_string_end = m_s + stringLength;
}

std::string cLargeString::substr(size_t pos, size_t count) const {
if (pos >= length() ) return "";
std::string result(m_s + pos, std::min(length() - pos, count) );
for (char &si: result) if (si == 0) si = '%';
return result;
}
7 changes: 0 additions & 7 deletions largeString.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class cLargeString {
}
void setMaxSize() { m_maxSize = std::max(m_maxSize, (size_t)(m_string_end - m_s)); }
void init(size_t initialSize, size_t increaseSize, bool debugBufferSize);
void loadFile(const char *filename, bool *exists);
public:
cLargeString(const cLargeString& o) = delete;
cLargeString &operator= (const cLargeString &) = delete;
Expand All @@ -39,12 +38,6 @@ class cLargeString {
m_nameLen = static_cast<int>(N) - 1;
init(initialSize, increaseSize, debugBufferSize);
}
template<std::size_t N>
cLargeString(const char (&name)[N], const char *filename, bool *exists = NULL) {
m_nameData = name;
m_nameLen = static_cast<int>(N) - 1;
loadFile(filename, exists);
}
~cLargeString();
char *data() { *m_string_end = 0; return m_s; }
const char *c_str() const { *m_string_end = 0; return m_s; }
Expand Down
2 changes: 1 addition & 1 deletion live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class cLiveImageProviderImp: public cLiveImageProvider {
m_errorMessages = false;
return fullPath?imagePath:LiveSetup().GetTvscraperImageDir() + imagePath;
}
return concatenate(LiveSetup().GetServerUrlImages(), (fullPath?ScraperImagePath2Live(imagePath):imagePath));
return concat(LiveSetup().GetServerUrlImages(), (fullPath?ScraperImagePath2Live(imagePath):imagePath));
}
virtual ~cLiveImageProviderImp() {}
private:
Expand Down
7 changes: 4 additions & 3 deletions pages/ibox.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ TimerConflictNotifier timerNotifier();
LOCK_RECORDINGS_READ;
cRecording *recording = (cRecording *)Recordings->GetByName(NowReplaying);
if (recording) {
epgEvent = EpgEvents::CreateEpgInfo(recManager->Md5Hash(recording),
recording,
tr("playing recording"));
epgEvent = EpgEvents::CreateEpgInfo(
concat("recording_", cToSvXxHash128(XXH3_128bits(NowReplaying, strlen(NowReplaying))) ),
recording,
tr("playing recording"));
}
}
else {
Expand Down
53 changes: 30 additions & 23 deletions pages/recordings.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,6 @@ const recs = [];
const vdr_start = <$ cSv(cToSvInt(LiveSetup().GetVdrStart() )) $>;
const recordings_tree_creation = <$ cSv(cToSvInt(recordingsTree->getCreationTimestamp() )) $>;
const param_name_recs = '&r<$ TNT_ARRAY $>=';
<%cpp>
/*
for (const RecordingsItemPtr &rPtr: *recordingsTree->allRecordings()) {
recoring_item.clear();
rPtr->AppendAsJSArray(recoring_item, currentFlat == "true" || currentSort == "duplicates");
</%cpp>
recs[<$cSv(cToSvInt(rPtr->IdI()))$>]=[<$$ recoring_item.c_str() $>]
<%cpp>
}
*/
</%cpp>
const rec_ids = Object.create(null)
rec_ids["T"] = [1, 2]

Expand Down Expand Up @@ -211,11 +200,11 @@ function RecordingsSt_int(s, level, displayFolder, data) {
s.a += '" />'
}
s.a += '</div></td>' // end of recording_imgs
<%cpp> if (!LiveSetup().GetTvscraperImageDir().empty() ) { </%cpp>
% if (!LiveSetup().GetTvscraperImageDir().empty() ) {
s.a += '<td class=\"space\">'
addScraperImageTitle(s, obj[3], obj[4], obj[5], obj[6], obj[7], obj[8], '<$$lf$>');
s.a += '</td>'
<%cpp> } </%cpp>
% }
s.a += '<td class="td-hidden-xs"><div class="hidden-xs recording_day margin-bottom">'
s.a += obj[9]
s.a += '</div><div class="hidden-xs recording_channel">'
Expand Down Expand Up @@ -249,20 +238,17 @@ function RecordingsSt_int(s, level, displayFolder, data) {
% if (cDevice::PrimaryDevice() && cDevice::PrimaryDevice()->HasDecoder() ) {
RecordingActionS(s, obj[0], "vdr_request/play_recording?param=", "play.png", "<$tr("play this recording")$>")
% }
<%cpp> if (LiveSetup().GetShowPlayMediaplayer() ) { </%cpp>
% if (LiveSetup().GetShowPlayMediaplayer() ) {
RecordingActionS(s, obj[0], "playlist.m3u?recid=", "playlist.png", "<$tr("Stream this recording into media player.")$>")
<%cpp> } if (LiveSetup().GetShowIMDb() ) { </%cpp>
% } if (LiveSetup().GetShowIMDb() ) {
IMDBS(s, obj[2], obj[14])
<%cpp> } </%cpp>
% }
RecordingActionS(s, obj[0], "edit_recording.html?recid=", "edit.png", "<$tr("Edit recording")$>")
<# s.a += '<div class=\"hidden-ts\">' #>
RecordingActionS(s, obj[0], "epginfo.html?epgid=del_", "del.png", "<$tr("Delete this recording from hard disc!")$>")
<# RecordingActionS(s, obj[0], "recordings.html?todel=", "del.png", "<$tr("Delete this recording from hard disc!")$>") #>
<# s.a += '</div>' #>
<%cpp> if (LiveSetup().GetShowIMDb() ) { </%cpp>
% if (LiveSetup().GetShowIMDb() ) {
} else {
IMDBS(s, obj[2], obj[14])
<%cpp> } </%cpp>
% }
}
s.a += '</div>'
if (obj[1].length != 0) {
Expand Down Expand Up @@ -446,7 +432,28 @@ if (currentFlat != "true") {
} else {
// here we prepare the items in case of a flat list, no folders
if (currentSort != "duplicates") {
recItemsC = recordingsTree->allRecordings(sortOrder);
recItems.clear();
size_t max_items = 100;
if (reverse) {
reverse = false;
std::vector<RecordingsItemPtr>::const_iterator recIterFirst = recordingsTree->allRecordings(sortOrder)->begin();
std::vector<RecordingsItemPtr>::const_iterator recIterLast = recordingsTree->allRecordings(sortOrder)->end();
for (; recIterFirst != recIterLast;) {
--recIterLast;
RecordingsItemPtr recItem = *recIterLast;
if (!recItem->matchesFilter(currentFilter)) continue;
recItems.push_back(recItem);
if (recItems.size() >= max_items) break;
}
} else {
for (const RecordingsItemPtr &rPtr: *recordingsTree->allRecordings(sortOrder) ) {
if (!rPtr->matchesFilter(currentFilter)) continue;
recItems.push_back(rPtr);
if (recItems.size() >= max_items) break;
}
}
// recItemsC = recordingsTree->allRecordings(sortOrder);
recItemsC = &recItems;
} else {
recItems.clear();
addDuplicateRecordingsSd(recItems, recordingsTree);
Expand Down Expand Up @@ -658,7 +665,7 @@ if (currentSort.compare(0, current.length(), current) == 0) { </%cpp>class="acti
</div>
<div class="epg_content">
<form>
<div class="about_head"><div><div><$ Format(tr("Delete recording \"%s\"?"), recording->Name()?recording->Name():"No recording name available") $></div></div></div>
<div class="about_head"><div><div><$ cSv(cToSvFormated(tr("Delete recording \"%s\"?"), recording->Name()?recording->Name():"No recording name available")) $></div></div></div>
<input type="hidden" name="epgid" value="<$todel$>" \>
<input type="hidden" name="delete_rec" value="confirmed" \>
<input type="hidden" name="history_num_back" value="<$ history_num_back $>" id="history_del_<$ todel $>"\>
Expand Down
2 changes: 1 addition & 1 deletion pages/stream.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ if (Event) {
timeSpan = headTime;
startDate = headDate;
}
std::string longDescription = concatenate(
std::string longDescription = concat(
StringEscapeAndBreak(StringWordTruncate(epgEvent->LongDescr(), LiveSetup().GetMaxTooltipChars())),
"<br/><br/>",
tr("Click to view details."));
Expand Down
2 changes: 1 addition & 1 deletion pages/timerconflicts.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
#endif
if (timer->Event()) {
epgEvent = EpgEvents::CreateEpgInfo(timer->Channel(), timer->Event());
longDescription = concatenate(
longDescription = concat(
StringEscapeAndBreak(SortedTimers::GetTimerInfo(*timer)),
"<hr>",
StringEscapeAndBreak(StringWordTruncate(epgEvent->LongDescr(), LiveSetup().GetMaxTooltipChars())),
Expand Down
Loading

0 comments on commit 5de0a5d

Please sign in to comment.