Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeshift path fallback #460

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Timeshifting is also available IPTV streams via [inputstream.ffmpegdirect](#http
- `Disabled` - No timeshifting
- `On Pause` - Timeshifting starts when a live stream is paused. E.g. you want to continue from where you were at after pausing.
- `On Playback` - Timeshifting starts when a live stream is opened. E.g. You can go to any point in the stream since it was opened.
* **Timeshift buffer path**: The path used to store the timeshift buffer. The default is the `addon_data/pvr.vuplus` folder in userdata.
* **Timeshift buffer path**: The path used to store the timeshift buffer. The default is the `addon_data/pvr.vuplus` folder in userdata. Note that if another directory is specified and it does not exist the default will be used instead.
* **Enable timeshift disk limit**: For devices with limited disk space a limit in Gigabytes can be set whereby timeshift will be switched off and playback will return to the live stream. Note that for timeshift on playback it will not be possible to timeshift again until a stream is restarted once this limit is reached.
* **Timeshift disk limit**: The disk space limit to use for the timeshift buffer in Gigabytes.
* **Enable timeshift for IPTV streams**: Enable the timeshift feature for HTTP IPTV streams using `inputstream.ffmpegdirect`. Note that this feature only works `On playback` and will ignore the timeshift mode used for regular channel playback.
Expand Down
2 changes: 1 addition & 1 deletion pvr.vuplus/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.vuplus"
version="21.1.2"
version="21.2.0"
name="Enigma2 Client"
provider-name="Joerg Dembski and Ross Nicholson">
<requires>@ADDON_DEPENDS@
Expand Down
4 changes: 4 additions & 0 deletions pvr.vuplus/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v21.2.0
- If a custom timeshift buffer path does not exist use the default instead
- Fix special regex characters causing a crash for auto timers

v21.1.2
- Translations updates from Weblate
- ast_es, be_by, ca_es, cs_cz, da_dk, de_de, es_es, es_mx, et_ee, fi_fi, fr_fr, hr_hr, id_id, it_it, ja_jp, ko_kr, lt_lt, pl_pl, pt_br, ro_ro, ru_ru, sk_sk, sv_se, uk_ua, zh_cn, zh_tw
Expand Down
2 changes: 1 addition & 1 deletion pvr.vuplus/resources/instance-settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@
<default>false</default>
<control type="toggle" />
</setting>
<setting id="timeshiftdisklimit" type="number" label="30154" help="30628">
<setting id="timeshiftdisklimit" type="number" label="30154" help="30728">
<level>0</level>
<default>4.0</default>
<constraints>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ msgstr ""

#. help: Timeshift - timeshiftbufferpath
msgctxt "#30722"
msgid "The path used to store the timeshift buffer. The default is the `addon_data/pvr.vuplus` folder in userdata."
msgid "The path used to store the timeshift buffer. The default is the `addon_data/pvr.vuplus` folder in userdata. Note that if another directory is specified and it does not exist the default will be used instead."
msgstr ""

#. help: Timeshift - timeshiftEnabled
Expand Down
2 changes: 1 addition & 1 deletion src/enigma2/InstanceSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ ADDON_STATUS InstanceSettings::SetSetting(const std::string& settingName, const

bool InstanceSettings::IsTimeshiftBufferPathValid() const
{
return kodi::vfs::DirectoryExists(m_timeshiftBufferPath);
return kodi::vfs::DirectoryExists(m_timeshiftBufferPath) || kodi::vfs::DirectoryExists(ADDON_DATA_BASE_DIR);
}

bool InstanceSettings::LoadCustomChannelGroupFile(std::string& xmlFile, std::vector<std::string>& channelGroupNameList)
Expand Down
3 changes: 2 additions & 1 deletion src/enigma2/Timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ void Timers::GenerateChildManualRepeatingTimers(std::vector<Timer>* timers, Time

std::string Timers::ConvertToAutoTimerTag(std::string tag)
{
static const std::regex regex(" ");
// Replace spaces and any special regex characters with underscores
static const std::regex regex(" |\\*|\\?|\\+|\\{");
std::string replaceWith = "_";

return std::regex_replace(tag, regex, replaceWith);
Expand Down
16 changes: 10 additions & 6 deletions src/enigma2/TimeshiftBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ using namespace enigma2::utilities;

TimeshiftBuffer::TimeshiftBuffer(IStreamReader* streamReader, std::shared_ptr<InstanceSettings>& settings) : m_streamReader(streamReader)
{
m_bufferPath = settings->GetTimeshiftBufferPath() + "/tsbuffer.ts";
if (kodi::vfs::DirectoryExists(settings->GetTimeshiftBufferPath()))
m_bufferFile = settings->GetTimeshiftBufferPath() + "/tsbuffer.ts";
else
m_bufferFile = ADDON_DATA_BASE_DIR + "/tsbuffer.ts";

unsigned int readTimeout = settings->GetReadTimeoutSecs();
m_readTimeout = (readTimeout) ? readTimeout : DEFAULT_READ_TIMEOUT;
if (settings->EnableTimeshiftDiskLimit())
m_timeshiftBufferByteLimit = settings->GetTimeshiftDiskLimitBytes();

m_filebufferWriteHandle.OpenFileForWrite(m_bufferPath, true);
m_filebufferWriteHandle.OpenFileForWrite(m_bufferFile, true);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
m_filebufferReadHandle.OpenFile(m_bufferPath, ADDON_READ_NO_CACHE);
m_filebufferReadHandle.OpenFile(m_bufferFile, ADDON_READ_NO_CACHE);
}

TimeshiftBuffer::~TimeshiftBuffer()
Expand All @@ -38,14 +42,14 @@ TimeshiftBuffer::~TimeshiftBuffer()
// XBMC->TruncateFile doesn't work for unknown reasons
m_filebufferWriteHandle.Close();
kodi::vfs::CFile tmp;
if (tmp.OpenFileForWrite(m_bufferPath, true))
if (tmp.OpenFileForWrite(m_bufferFile, true))
tmp.Close();
}
if (m_filebufferReadHandle.IsOpen())
m_filebufferReadHandle.Close();

if (!kodi::vfs::DeleteFile(m_bufferPath))
Logger::Log(LEVEL_ERROR, "%s Unable to delete file when timeshift buffer is deleted: %s", __func__, m_bufferPath.c_str());
if (!kodi::vfs::DeleteFile(m_bufferFile))
Logger::Log(LEVEL_ERROR, "%s Unable to delete file when timeshift buffer is deleted: %s", __func__, m_bufferFile.c_str());

Logger::Log(LEVEL_DEBUG, "%s Timeshift: Stopped", __func__);
}
Expand Down
2 changes: 1 addition & 1 deletion src/enigma2/TimeshiftBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace enigma2
static const int DEFAULT_READ_TIMEOUT = 10;
static const int READ_WAITTIME = 50;

std::string m_bufferPath;
std::string m_bufferFile;
IStreamReader* m_streamReader;
kodi::vfs::CFile m_filebufferReadHandle;
kodi::vfs::CFile m_filebufferWriteHandle;
Expand Down