Skip to content

Commit

Permalink
newR
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Ehrnsperger committed Dec 2, 2023
1 parent 87977a7 commit 9046473
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 221 deletions.
2 changes: 1 addition & 1 deletion pages/pageelems.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ function existingRecordingString(col_span, bottomrow, id, archiveDescr, imdb_id,
// if (LiveSetup().GetShowIMDb())
{
if (s_IMDB_ID.empty() ) { </%cpp>
<a href="http://www.imdb.com/find?s=all&q=<$ (!title.empty() && title[0] == '%')?StringUrlEncode(cSv(title).substr_csv(1)):StringUrlEncode(title) $>"
<a href="http://www.imdb.com/find?s=all&q=<$ (!title.empty() && title[0] == '%')?StringUrlEncode(cSv(title).substr(1)):StringUrlEncode(title) $>"
<%cpp> } else { </%cpp>
<a href="http://www.imdb.com/title/<$ s_IMDB_ID $>"
<%cpp> } </%cpp>
Expand Down
10 changes: 5 additions & 5 deletions pages/recordings.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ if (!deleteResult.empty()) {
<%cpp>
} else {
uintptr_t irecoring_item = (uintptr_t)&recoring_item;
RecordingsItemPtr recItemRoot = recordingsTree->getRoot();
RecordingsItemDirPtr recItemRoot = recordingsTree->getRoot();
uintptr_t iRecItemRoot = (uintptr_t)&recItemRoot;
uintptr_t iRecordingsTree = (uintptr_t)&recordingsTree;
uintptr_t iOpenTreeNodes = (uintptr_t)&openTreeNodes;
Expand Down Expand Up @@ -350,7 +350,7 @@ if (currentSort.compare(0, 8, "errorsdur", 8) == 0) sortOrder = eSortOrder::dur
if (currentSort.compare(0, 10, "duplicates", 10) == 0) sortOrder = eSortOrder::duplicatesLanguage;
if (currentSort == "datedesc" || currentSort == "namedesc") reverse = true;
// get rec item of this (current) dir
RecordingsItemPtr recItemThisDir = *(static_cast<RecordingsItemPtr *>((void *)iRecItem) );
RecordingsItemDirPtr recItemThisDir = *(static_cast<RecordingsItemDirPtr *>((void *)iRecItem) );
RecordingsTreePtr recordingsTree = *(static_cast<RecordingsTreePtr *>((void *)iRecordingsTree) );
cLargeString *recoring_item = static_cast<cLargeString *>((void *)irecoring_item );
std::string openTreeNodes= *(static_cast<std::string *>((void *)iOpenTreeNodes) );
Expand All @@ -362,8 +362,8 @@ std::vector<RecordingsItemRecPtr> recItems;
const std::vector<RecordingsItemRecPtr> *recItemsC = NULL;

// data for dirs, and loop over dirs
const std::vector<RecordingsItemPtr> *dirItems = recItemThisDir->getDirs();
std::vector<RecordingsItemPtr>::const_iterator dirIterS, dirIterE, dirIter;
const std::vector<RecordingsItemDirPtr> *dirItems = recItemThisDir->getDirs();
std::vector<RecordingsItemDirPtr>::const_iterator dirIterS, dirIterE, dirIter;
int direction; // for dirs
if (currentFlat != "true") {
if (currentSort != "duplicates") {
Expand All @@ -384,7 +384,7 @@ if (currentFlat != "true") {
// this is the loop over the subdirs
// each subdir is a node, which can be expanded (or not)
// each subdir has an identifier in <ul> tag: fldr_<$ idHash $>
RecordingsItemPtr recItem = *dirIter;
RecordingsItemDirPtr recItem = *dirIter;

/* search trough directory for new recordings */
bool newR = false;
Expand Down
87 changes: 35 additions & 52 deletions recman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ namespace vdrlive {
if(i != 0) return i < 0;
return first->CompareStD(second) < 0;
}
bool RecordingsItemPtrCompare::ByAscendingNameSort(const RecordingsItemPtr & first, const RecordingsItemPtr & second) // return first < second
bool RecordingsItemPtrCompare::ByAscendingNameSort(const RecordingsItemDirPtr & first, const RecordingsItemDirPtr & second) // return first < second
{
return compareWithLocale(first->Name(), second->Name()) < 0;
}
Expand All @@ -377,7 +377,7 @@ namespace vdrlive {
return first->scraperEpisodeNumber() < second->scraperEpisodeNumber();
}

bool RecordingsItemPtrCompare::BySeason(const RecordingsItemPtr & first, const RecordingsItemPtr & second) {
bool RecordingsItemPtrCompare::BySeason(const RecordingsItemDirPtr & first, const RecordingsItemDirPtr & second) {
return first->scraperSeasonNumber() < second->scraperSeasonNumber();
}

Expand Down Expand Up @@ -463,23 +463,21 @@ bool searchNameDesc(RecordingsItemRecPtr &RecItem, const std::vector<RecordingsI
}

/**
* Implementation of class RecordingsItem:
* Implementation of class RecordingsItemDir:
*/
RecordingsItem::RecordingsItem(cSv name) :
m_name(name)
{ }
RecordingsItemDir::RecordingsItemDir(cSv name, int level):
m_name(name),
m_level(level) { }

RecordingsItem::~RecordingsItem()
{
}
RecordingsItemDir::~RecordingsItemDir() { }

int RecordingsItem::numberOfRecordings() {
int RecordingsItemDir::numberOfRecordings() const {
int result = m_entries.size();
for (const auto &item: m_subdirs) result += item->numberOfRecordings();
return result;
}

void RecordingsItem::finishRecordingsTree() {
void RecordingsItemDir::finishRecordingsTree() {
for (auto &item: m_subdirs) item->finishRecordingsTree();
if (m_cmp_rec) std::sort(m_entries.begin(), m_entries.end(), m_cmp_rec);
if (m_cmp_dir) std::sort(m_subdirs.begin(), m_subdirs.end(), m_cmp_dir);
Expand All @@ -488,31 +486,31 @@ bool searchNameDesc(RecordingsItemRecPtr &RecItem, const std::vector<RecordingsI
m_subdirs.shrink_to_fit();
}

RecordingsItemPtr RecordingsItem::addDirIfNotExists(cSv dirName) {
std::vector<RecordingsItemPtr>::iterator iter = std::lower_bound(m_subdirs.begin(), m_subdirs.end(), dirName);
RecordingsItemDirPtr RecordingsItemDir::addDirIfNotExists(cSv dirName) {
std::vector<RecordingsItemDirPtr>::iterator iter = std::lower_bound(m_subdirs.begin(), m_subdirs.end(), dirName);
if (iter != m_subdirs.end() && !(dirName < *iter) ) return *iter;
RecordingsItemPtr recPtr (new RecordingsItemDir(dirName, Level() + 1));
RecordingsItemDirPtr recPtr (new RecordingsItemDir(dirName, Level() + 1));
m_subdirs.insert(iter, recPtr);
return recPtr;
}

RecordingsItemPtr RecordingsItem::addDirCollectionIfNotExists(int collectionId, const RecordingsItemRecPtr &rPtr) {
std::vector<RecordingsItemPtr>::iterator iter = std::lower_bound(m_subdirs.begin(), m_subdirs.end(), collectionId);
RecordingsItemDirPtr RecordingsItemDir::addDirCollectionIfNotExists(int collectionId, const RecordingsItemRecPtr &rPtr) {
std::vector<RecordingsItemDirPtr>::iterator iter = std::lower_bound(m_subdirs.begin(), m_subdirs.end(), collectionId);
if (iter != m_subdirs.end() && !(collectionId < *iter) ) return *iter;
RecordingsItemPtr recPtr2 (new RecordingsItemDirCollection(Level() + 1, rPtr));
RecordingsItemDirPtr recPtr2 (new RecordingsItemDirCollection(Level() + 1, rPtr));
m_subdirs.insert(iter, recPtr2);
return recPtr2;
}

RecordingsItemPtr RecordingsItem::addDirSeasonIfNotExists(int seasonNumber, const RecordingsItemRecPtr &rPtr) {
std::vector<RecordingsItemPtr>::iterator iter = std::lower_bound(m_subdirs.begin(), m_subdirs.end(), seasonNumber);
RecordingsItemDirPtr RecordingsItemDir::addDirSeasonIfNotExists(int seasonNumber, const RecordingsItemRecPtr &rPtr) {
std::vector<RecordingsItemDirPtr>::iterator iter = std::lower_bound(m_subdirs.begin(), m_subdirs.end(), seasonNumber);
if (iter != m_subdirs.end() && !(seasonNumber < *iter) ) return *iter;
RecordingsItemPtr recPtr2 (new RecordingsItemDirSeason(Level() + 1, rPtr));
RecordingsItemDirPtr recPtr2 (new RecordingsItemDirSeason(Level() + 1, rPtr));
m_subdirs.insert(iter, recPtr2);
return recPtr2;
}

const std::vector<RecordingsItemRecPtr> *RecordingsItem::getRecordings(eSortOrder sortOrder)
const std::vector<RecordingsItemRecPtr> *RecordingsItemDir::getRecordings(eSortOrder sortOrder)
{
if (m_cmp_rec) return &m_entries;
if (sortOrder == eSortOrder::name) {
Expand All @@ -529,12 +527,12 @@ bool searchNameDesc(RecordingsItemRecPtr &RecItem, const std::vector<RecordingsI
return &m_entries_other_sort;
}

bool RecordingsItem::checkNew() {
bool RecordingsItemDir::checkNew() const{
for (const auto &rec:m_entries) if (rec->checkNew()) return true;
for (const auto &subdir:m_subdirs) if (subdir->checkNew() ) return true;
return false;
}
void RecordingsItem::addDirList(std::vector<std::string> &dirs, cSv basePath)
void RecordingsItemDir::addDirList(std::vector<std::string> &dirs, cSv basePath) const
{
std::string basePath0(basePath);
if (basePath.empty() ) dirs.push_back("");
Expand All @@ -548,15 +546,15 @@ bool searchNameDesc(RecordingsItemRecPtr &RecItem, const std::vector<RecordingsI
}
}

void RecordingsItem::setTvShow(const RecordingsItemRecPtr &rPtr) {
void RecordingsItemDir::setTvShow(const RecordingsItemRecPtr &rPtr) {
if (m_cmp_dir) return;
m_cmp_dir = RecordingsItemPtrCompare::BySeason;
m_imageLevels = cImageLevels(eImageLevel::tvShowCollection, eImageLevel::anySeasonCollection);
m_rec_item = rPtr;
m_s_season_number = m_rec_item->scraperSeasonNumber();
}

const cTvMedia &RecordingsItem::scraperImage() const {
const cTvMedia &RecordingsItemDir::scraperImage() const {
if (!m_s_image_requested) {
m_s_image_requested = true;
if (m_rec_item && m_rec_item->m_scraperVideo)
Expand All @@ -565,21 +563,6 @@ bool searchNameDesc(RecordingsItemRecPtr &RecItem, const std::vector<RecordingsI
return m_s_image;
}

/**
* Implementation of class RecordingsItemDir:
*/
RecordingsItemDir::RecordingsItemDir(cSv name, int level):
RecordingsItem(name),
m_level(level)
{
// dsyslog("live: REC: C: dir %s -> %s", name.c_str(), parent ? parent->Name().c_str() : "ROOT");
}

RecordingsItemDir::~RecordingsItemDir()
{
// dsyslog("live: REC: D: dir %s", Name().c_str());
}

/**
* Implementation of class RecordingsItemDirCollection:
*/
Expand Down Expand Up @@ -668,7 +651,7 @@ bool searchNameDesc(RecordingsItemRecPtr &RecItem, const std::vector<RecordingsI
return result;
}

bool RecordingsItemRec::matchesFilter(cSv filter) {
bool RecordingsItemRec::matchesFilter(cSv filter) const {
if (filter.empty() ) return true;
#ifdef HAVE_PCRE2
StringMatch sm(filter);
Expand Down Expand Up @@ -780,7 +763,7 @@ bool searchNameDesc(RecordingsItemRecPtr &RecItem, const std::vector<RecordingsI
}
}

int RecordingsItemRec::SD_HD()
int RecordingsItemRec::SD_HD() const
{
if (m_video_SD_HD >= -1) return m_video_SD_HD; // < -2: not checked. -1: Radio. 0 is SD, 1 is HD, >1 is UHD or better
if (m_scraperVideo) m_video_SD_HD = m_scraperVideo->getHD();
Expand Down Expand Up @@ -889,7 +872,7 @@ void AppendScraperData(cLargeString &target, cSv s_IMDB_ID, const cTvMedia &s_im
target.append("\"");
}

void RecordingsItemRec::AppendAsJSArray(cLargeString &target) {
void RecordingsItemRec::AppendAsJSArray(cLargeString &target) const {
target.append("\"");
// [0] : ID
target.append(cToSvXxHash128(IdHash()));
Expand Down Expand Up @@ -1001,11 +984,11 @@ void AppendScraperData(cLargeString &target, cSv s_IMDB_ID, const cTvMedia &s_im
}
}

bool operator< (const RecordingsItemPtr &a, const RecordingsItemPtr &b) { return *a < b; }
bool operator< (cSv a, const RecordingsItemPtr &b) { return a < b->Name(); }
bool operator< (const RecordingsItemPtr &a, cSv b) { return a->Name() < b; }
bool operator< (int a, const RecordingsItemPtr &b) { return *b > a; }
bool operator< (const RecordingsItemPtr &a, int b) { return *a < b; }
bool operator< (const RecordingsItemDirPtr &a, const RecordingsItemDirPtr &b) { return *a < b; }
bool operator< (cSv a, const RecordingsItemDirPtr &b) { return a < b->Name(); }
bool operator< (const RecordingsItemDirPtr &a, cSv b) { return a->Name() < b; }
bool operator< (int a, const RecordingsItemDirPtr &b) { return *b > a; }
bool operator< (const RecordingsItemDirPtr &a, int b) { return *a < b; }

/**
* Implementation of class RecordingsTree:
Expand All @@ -1022,8 +1005,8 @@ void AppendScraperData(cLargeString &target, cSv s_IMDB_ID, const cTvMedia &s_im
m_creation_timestamp = time(0);
cGetScraperVideo getScraperVideo;
bool scraperDataAvailable = getScraperVideo.call(LiveSetup().GetPluginScraper());
RecordingsItemPtr recPtrTvShows (new RecordingsItemDir(tr("TV shows"), 1));
RecordingsItemPtr recPtrMovieCollections (new RecordingsItemDir(tr("Movie collections"), 1));
RecordingsItemDirPtr recPtrTvShows (new RecordingsItemDir(tr("TV shows"), 1));
RecordingsItemDirPtr recPtrMovieCollections (new RecordingsItemDir(tr("Movie collections"), 1));
// create "base" folders
m_allRecordings.clear();
if (scraperDataAvailable) {
Expand All @@ -1032,7 +1015,7 @@ void AppendScraperData(cLargeString &target, cSv s_IMDB_ID, const cTvMedia &s_im
m_root->m_subdirs.push_back(recPtrTvShows);
recPtrMovieCollections->m_s_season_number = 2;
m_root->m_subdirs.push_back(recPtrMovieCollections);
RecordingsItemPtr recPtrOthers (new RecordingsItemDir(tr("File system view"), 1));
RecordingsItemDirPtr recPtrOthers (new RecordingsItemDir(tr("File system view"), 1));
recPtrOthers->m_s_season_number = 3;
m_rootFileSystem = recPtrOthers;
m_root->m_subdirs.push_back(recPtrOthers);
Expand All @@ -1045,7 +1028,7 @@ void AppendScraperData(cLargeString &target, cSv s_IMDB_ID, const cTvMedia &s_im
if (scraperDataAvailable) m_maxLevel = std::max(m_maxLevel, recording->HierarchyLevels() + 1);
else m_maxLevel = std::max(m_maxLevel, recording->HierarchyLevels() );

RecordingsItemPtr dir = m_rootFileSystem;
RecordingsItemDirPtr dir = m_rootFileSystem;
cSv name(recording->Name());

size_t index = 0;
Expand Down
Loading

0 comments on commit 9046473

Please sign in to comment.