Skip to content

Commit

Permalink
10.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dream-alpha committed Sep 2, 2024
1 parent e49976f commit d2f35b1
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 128 deletions.
2 changes: 1 addition & 1 deletion CONTROL/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Description: TimeshiftCockpit
Maintainer: dream-alpha
Package: enigma2-plugin-extensions-timeshiftcockpit
Version: 10.1.14
Version: 10.2.1
Architecture: all
Depends: enigma2-plugin-skincomponents-cockpit, enigma2-plugin-systemplugins-powercockpit, enigma2-plugin-systemplugins-covercockpit
62 changes: 0 additions & 62 deletions src/PartialCopy.py

This file was deleted.

59 changes: 59 additions & 0 deletions src/Shell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/python
# coding=utf-8
#
# Copyright (C) 2018-2024 by dream-alpha
#
# In case of reuse of this source code please do not remove this copyright.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For more information on the GNU General Public License see:
# <http://www.gnu.org/licenses/>.


from pipes import quote
from enigma import eConsoleAppContainer
from .Debug import logger
from .TimeshiftUtils import ERROR_NONE, ERROR_ABORT


class Shell():

def __init__(self):
logger.info("...")
self.container = eConsoleAppContainer()
self.container_appClosed_conn = self.container.appClosed.connect(self.finished)

def partialCopyCallback(self, _path, _target_path, _error):
logger.error("should be overridden in child class")

def execShell(self, scripts, path, target_path):
logger.info("scripts: %s", scripts)
self.path = path
self.target_path = target_path
self.__abort = False
script = '; '.join(scripts)
logger.debug("script: %s", script)
self.container.execute("sh -c " + quote(script))

def finished(self, retval=None):
logger.info("retval = %s, __abort: %s", retval, self.__abort)
error = ERROR_ABORT if self.__abort else ERROR_NONE
self.partialCopyCallback(self.path, self.target_path, error)

def abortShell(self):
logger.info("...")
self.__abort = True
if self.container is not None and self.container.running():
self.container.sendCtrlC()
else:
logger.error("aborting before container has started execution...")
self.partialCopyCallback(self.path, self.target_path, ERROR_ABORT)
45 changes: 0 additions & 45 deletions src/TSRecording.py

This file was deleted.

28 changes: 18 additions & 10 deletions src/TSRecordingJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,26 @@ class TSRecordingJob():

def __init__(self, infobar_instance):
self.infobar_instance = infobar_instance
self.job = None

def addJob(self, service_ref, path, timeshift_start_time, event_data, done_callback):
def onTimeshiftRecordingChange(self):
for function in self.infobar_instance.on_timeshift_recording_change:
function()

def startTSRecording(self, service_ref, event_data):
logger.info("event_data: %s", event_data)
logger.debug("timeshift recording starts...")
self.addJob(service_ref, self.timeshift_file_path, self.timeshift_start_time, event_data)
self.onTimeshiftRecordingChange()

def addJob(self, service_ref, path, timeshift_start_time, event_data):
logger.info("path: %s, event_data: %s", path, event_data)
self.job = Job("%s - %s" % (_("TS recording"), event_data[2]))
self.job.id = ID
self.job.target_path = calcFilename(event_data[0], service_ref, event_data[2], config.plugins.timeshiftcockpit.videodir.value)
self.job.service_str = service_ref.toString()
self.job.done_callback = done_callback
TSRecordingTask(self.job, self.infobar_instance, service_ref, path, self.job.target_path, timeshift_start_time, event_data, self.addJobCallback)
job_manager.AddJob(self.job)
job = Job("%s - %s" % (_("TS recording"), event_data[2]))
job.id = ID
job.target_path = calcFilename(event_data[0], service_ref, event_data[2], config.plugins.timeshiftcockpit.videodir.value)
job.service_str = service_ref.toString()
TSRecordingTask(job, self.infobar_instance, service_ref, path, job.target_path, timeshift_start_time, event_data, self.addJobCallback)
job_manager.AddJob(job)

def addJobCallback(self, error):
logger.info("error: %s", error)
self.job.done_callback(error)
self.onTimeshiftRecordingChange()
19 changes: 14 additions & 5 deletions src/TSRecordingTaskExecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@
from Plugins.SystemPlugins.CacheCockpit.FileManager import FileManager
except Exception:
FileManager = None
from .PartialCopy import PartialCopy
from .Debug import logger
from .TimeshiftUtils import calcRecordingTimes, calcRecordingCopyData, createTXTFile, createMetaFile, createXMetaFile, createEitFile, downloadCover, ERROR_ABORT
from .FileUtils import deleteFiles
from .Shell import Shell


POLL_TIMEOUT = 1000 * 60


class TSRecordingTaskExecution(PartialCopy):
class TSRecordingTaskExecution(Shell):

def __init__(self, _service_ref, path, target_path, timeshift_start_time, event_data):
logger.info("...")
PartialCopy.__init__(self)
Shell.__init__(self)
self.path = path
self.timeshift_start_time = timeshift_start_time
self.event_start_time = event_data[0]
Expand All @@ -61,8 +61,7 @@ def __init__(self, _service_ref, path, target_path, timeshift_start_time, event_
def abortTSRecording(self):
logger.info("...")
self.poll_timer.stop()
self.abortPartialCopy()
self.partialCopyCallback(self.path, self.target_path, ERROR_ABORT)
self.abortShell()

def execTSRecording(self, service_ref, event_data):
logger.info("event_data: %s", event_data)
Expand Down Expand Up @@ -99,6 +98,16 @@ def stopTSRecording(self):
logger.debug("timeshift recording still in progress...")
self.poll_timer.start(POLL_TIMEOUT, True)

def partialCopy(self, src, dst, timeshift_start_time, begin_time, end_time):
duration = end_time - begin_time
begin = begin_time - timeshift_start_time
cmds = []
cmds.append("ffmpeg -ss %s -i %s -t %s -map 0 -y -c copy %s -ignore_unknown" % (begin, quote(src), duration, quote(dst)))
createapscfiles = "/usr/lib/enigma2/python/Plugins/Extensions/TimeshiftCockpit/createapscfiles"
cmds.append("%s %s" % (createapscfiles, quote(dst)))
logger.debug("cmds: %s", cmds)
self.execShell(cmds, src, dst)

def partialCopyCallback(self, path, target_path, error): # pylint: disable=W0221
logger.info("...")
if error == ERROR_ABORT:
Expand Down
8 changes: 4 additions & 4 deletions src/Timeshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@


import os
from time import time, localtime
from time import time
import NavigationInstance
from Components.config import config
from enigma import eEPGCache
from .Debug import logger
from .Playback import Playback
from .FileUtils import deleteFiles
from .TSRecording import TSRecording
from .TSRecordingJob import TSRecordingJob
from .TimeshiftUtils import calcFilename, formatTime


class Timeshift(Playback, TSRecording):
class Timeshift(Playback, TSRecordingJob):

def __init__(self, session, service_ref, infobar_instance):
logger.info("service_ref: %s", service_ref.toString())
Playback.__init__(self, session, infobar_instance, service_ref)
TSRecording.__init__(self, infobar_instance)
TSRecordingJob.__init__(self, infobar_instance)
self.events_info = []
self.service_ref = service_ref
self.record_service = None
Expand Down
2 changes: 1 addition & 1 deletion src/Version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@

ID = "TSC"
PLUGIN = "TimeshiftCockpit"
VERSION = "10.1.14"
VERSION = "10.2.1"
COPYRIGHT = "2018-2024 by dream-alpha"
LICENSE = "This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version."

0 comments on commit d2f35b1

Please sign in to comment.