diff --git a/live/css/styles.css b/live/css/styles.css index a980053..f9afada 100644 --- a/live/css/styles.css +++ b/live/css/styles.css @@ -31,14 +31,14 @@ form { padding: 0; } -input { +input, textarea { border: 1px solid #6D96A9; font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif; background: #FEFEFE; margin: 0; } -input.width99 { +input.width99, textarea.width99 { width: 99%; } diff --git a/pages/edit_recording.ecpp b/pages/edit_recording.ecpp index a5e5f87..76cec83 100644 --- a/pages/edit_recording.ecpp +++ b/pages/edit_recording.ecpp @@ -1,6 +1,5 @@ <%pre> -#include #include #include #include @@ -20,6 +19,9 @@ using namespace vdrlive; std::string name = ""; std::string directory = ""; std::string newdir = ""; + std::string title = ""; + std::string shorttext = ""; + std::string description = ""; std::string delresume = ""; std::string delmarks = ""; std::string copy = ""; @@ -63,8 +65,7 @@ const cRecording* recording; if (delmarks == "delmarks") LiveRecordingsManager()->DeleteMarks(recording); if (copy == "copy") copy_only = true; if (newdir != ".") directory = newdir; - std::string filename = directory.empty() ? name : StringReplace(directory, "/", "~") + "~" + name; - if (LiveRecordingsManager()->MoveRecording(recording, FileSystemExchangeChars(filename, true), copy_only)) + if (LiveRecordingsManager()->UpdateRecording(recording, directory, name, copy_only, title, shorttext, description)) returnToReferer = true; else message = tr("Cannot copy, rename or move the recording."); @@ -83,17 +84,12 @@ const cRecording* recording; } else { if (recording) { - std::string path = recording->Name(); - size_t found = path.find_last_of("~"); - - if (found != std::string::npos) { - directory = StringReplace(path.substr(0, found), "~", "/"); - name = path.substr(found + 1); - } - else { - directory = ""; - name = path; - } + cRecordingInfo *info = recording->Info(); + name = recording->BaseName(); + directory = StringReplace(*recording->Folder(), "~", "/"); + title = cSv(info->Title()); + shorttext = cSv(info->ShortText()); + description = cSv(info->Description()); } <& pageelems.doc_type &> @@ -140,7 +136,7 @@ const cRecording* recording;
<$ tr("Name") $>:
- +
<$ tr("Directory") $>:
@@ -155,8 +151,8 @@ const cRecording* recording; } - " title="<$tr("Create new directory")$>" onclick="new_dir()" style="vertical-align: middle"> - + " title="<$tr("Create new directory")$>" onclick="new_dir()" style="vertical-align: middle"> + @@ -171,24 +167,20 @@ const cRecording* recording;
<$ tr("Copy only") $>:
-<%cpp> -if (recording && recording->Info()->ShortText()) { - + +
<$ tr("Title") $>:
+ +
<$ tr("Short description") $>:
- <$ recording->Info()->ShortText() $> + -<%cpp> -} -if (recording && recording->Info()->Description()) { -
<$ tr("Description") $>:
- <$ recording->Info()->Description() $> + <%cpp> -} if (recording && recording->Info()->Aux()) { std::string aux_data; cGetAutoTimerReason getAutoTimerReason; diff --git a/recman.cpp b/recman.cpp index cf2991a..2617c64 100644 --- a/recman.cpp +++ b/recman.cpp @@ -102,24 +102,26 @@ template void StringAppendFrameParams>(cToSvConcat<255> &s, con return 0; } - bool RecordingsManager::MoveRecording(cRecording const * recording, cSv name, bool copy) const + bool RecordingsManager::UpdateRecording(cRecording const * recording, cSv directory, cSv name, bool copy, cSv title, cSv shorttext, cSv description) const { if (!recording) return false; -// Check for injections that try to escape from the video dir. - if (name.compare(0, 3, "../") == 0 || name.find("/..") != std::string::npos) { - esyslog("live: renaming failed: new name invalid \"%.*s\"", (int)name.length(), name.data()); - return false; - } - std::string oldname = recording->FileName(); size_t found = oldname.find_last_of("/"); if (found == std::string::npos) return false; - std::string newname = concat(cVideoDirectory::Name(), "/", name, cSv(oldname).substr(found)); + std::string filename = FileSystemExchangeChars(directory.empty() ? name : (StringReplace(directory, "/", "~") + "~").append(name), true); + + // Check for injections that try to escape from the video dir. + if (filename.compare(0, 3, "..~") == 0 || filename.find("~..") != std::string::npos) { + esyslog("live: renaming failed: new name invalid \"%.*s\"", (int)filename.length(), filename.data()); + return false; + } + + std::string newname = concat(cVideoDirectory::Name(), "/", filename, cSv(oldname).substr(found)); if (!MoveDirectory(oldname, newname, copy)) { esyslog("live: renaming failed from '%.*s' to '%s'", (int)oldname.length(), oldname.data(), newname.c_str()); @@ -132,6 +134,18 @@ template void StringAppendFrameParams>(cToSvConcat<255> &s, con Recordings->AddByName(newname.c_str()); cRecordingUserCommand::InvokeCommand(*cString::sprintf("rename \"%s\"", *strescape(oldname.c_str(), "\\\"$'")), newname.c_str()); + // update texts + // need null terminated strings for VDR API + std::string desc(description); + desc.erase(std::remove(desc.begin(), desc.end(), '\r'), desc.end()); // remove \r from HTML + + cRecordingInfo* info = recording->Info(); + if (title != cSv(info->Title()) || shorttext != cSv(info->ShortText()) || desc != cSv(info->Description())) + { + info->SetData(title.empty() ? nullptr : std::string(title).c_str(), shorttext.empty() ? nullptr : std::string(shorttext).c_str(), desc.empty() ? nullptr : desc.c_str()); + info->Write(); + } + return true; } diff --git a/recman.h b/recman.h index 661c110..8d7eaa8 100644 --- a/recman.h +++ b/recman.h @@ -79,8 +79,14 @@ template /** * Move a recording with the given hash according to * VDRs recording mechanisms. + * @param directory new name of the sub folder this recording is stored in. + * @param name new recording folder name. + * @param copy create a copy of the original recording rather than moving it. + * @param title new title of the recording. + * @param shorttext new short text of the recording. + * @param description new description of the recording. */ - bool MoveRecording(cRecording const * recording, cSv name, bool copy = false) const; + bool UpdateRecording(cRecording const * recording, cSv directory, cSv name, bool copy, cSv title, cSv shorttext, cSv description) const; /** * Delete recording resume with the given hash according to