Skip to content

Commit

Permalink
10.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dream-alpha committed Nov 4, 2024
1 parent cf82515 commit 95ca40b
Show file tree
Hide file tree
Showing 28 changed files with 120 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ disable=print-statement,
dict-keys-not-iterating,
dict-values-not-iterating,

R0201, R0205,
R0201, R0205, R1725,
C0103, C0114, C0326, C0330, C0411,
W0122, W0123, W0201, W0311, W0312, W0603, W0703, W1505,
E0401, E0611, E1101
Expand Down
2 changes: 1 addition & 1 deletion CONTROL/control
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Description: TimeshiftCockpit
Maintainer: dream-alpha
Package: enigma2-plugin-extensions-timeshiftcockpit
Version: 10.4.13
Version: 10.8.2
Architecture: all
Conflicts: enigma2-plugin-extensions-permanenttimeshift
Depends: enigma2-plugin-skincomponents-cockpit, enigma2-plugin-systemplugins-powercockpit, enigma2-plugin-systemplugins-covercockpit, enigma2-plugin-systemplugins-jobcockpit
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# TimeshiftCockpit (TSC)
![Screenshot](ts1.png)

MENUE key shows a choice list of timeshift events for easy playback.
MENU key shows a choice list of timeshift events for easy playback.
![Screenshot](ts2.png)

REC key shows a choice list of timeshift events for easy recording.
Expand Down
4 changes: 2 additions & 2 deletions src/CockpitPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from .EventChoiceBox import EventChoiceBox
from .DelayTimer import DelayTimer
from .TimeshiftUtils import manageTimeshiftRecordings
from .TimeshiftsInfo import TimeshiftsInfo
from .TimeshiftOverview import TimeshiftOverview


class CockpitPlayerSummary(Screen):
Expand Down Expand Up @@ -127,7 +127,7 @@ def noOp(self):
return

def blueKey(self):
self.session.open(TimeshiftsInfo, self.infobar_instance)
self.session.open(TimeshiftOverview, self.infobar_instance)

def yellowKey(self):
manageTimeshiftRecordings(self.session, ID)
Expand Down
4 changes: 1 addition & 3 deletions src/CockpitSeek.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .Debug import logger
from .CutListUtils import secondsToPts, ptsToSeconds
from .ServiceUtils import SID_DVB
from .RecordingUtils import isRecording, isFileStreaming
from .RecordingUtils import isRecording
from .CockpitSmartSeek import CockpitSmartSeek
from .CockpitEvent import CockpitEvent

Expand Down Expand Up @@ -82,8 +82,6 @@ def getRecordingPosition(self):
if self.isRecording():
before, offset, _, _, recording_start_time = self.getEventInfo()
position = secondsToPts(int(time()) - recording_start_time - offset + before)
elif isFileStreaming():
position = self.getSeekLength()
logger.debug("recording_position: %ss (%s)", ptsToSeconds(position), position)
return position

Expand Down
6 changes: 3 additions & 3 deletions src/ConfigScreenInit.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def __init__(self, csel, session):
(_("Permanent timeshift") , config.plugins.timeshiftcockpit.permanent , self.setTimeshift , None , 0 , [] , _("Select to enable permanent timeshift.")),
(_("Fixed timeshift service #1") , config.plugins.timeshiftcockpit.fixed1 , self.restartTimeshifts , self.selectChannel , 0 , [-1] , _("Press OK to select service for fixed timeshift #1.")),
(_("Fixed timeshift service #2") , config.plugins.timeshiftcockpit.fixed2 , self.restartTimeshifts , self.selectChannel , 0 , [-2] , _("Press OK to select service for fixed timeshift #2.")),
(self.section , _("RECORDING") , None , None , 2 , [] , ""),
(_("Recording directory") , config.plugins.timeshiftcockpit.videodir , None , None , 0 , [-3] , _("Select directory for timeshift recordings.")),
(_("Cover source") , config.plugins.timeshiftcockpit.cover_source , None , None , 0 , [-1] , _("Select the cover source.")),
(self.section , _("RECORDING") , None , None , 2 , [] , ""),
(_("Recording directory") , config.plugins.timeshiftcockpit.videodir , None , None , 0 , [] , _("Select directory for timeshift recordings.")),
(_("Cover source") , config.plugins.timeshiftcockpit.cover_source , None , None , 0 , [] , _("Select the cover source.")),
(self.section , _("DEBUG") , None , None , 2 , [] , ""),
(_("Log level") , config.plugins.timeshiftcockpit.debug_log_level , self.setLogLevel , None , 2 , [] , _("Select debug log level.")),
]
Expand Down
2 changes: 1 addition & 1 deletion src/Debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

logger = None
streamer = None
format_string = (ID + ": " + "%(levelname)s: %(filename)s: %(funcName)s: %(message)s")
format_string = ID + ": " + "%(levelname)s: %(filename)s: %(funcName)s: %(message)s"
log_levels = {"ERROR": logging.ERROR, "INFO": logging.INFO, "DEBUG": logging.DEBUG}
plugin = PLUGIN.lower()
exec("config.plugins." + plugin + " = ConfigSubsection()") # noqa: F401, pylint: disable=W0122
Expand Down
12 changes: 8 additions & 4 deletions src/InfoBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from time import time
from Screens.InfoBar import InfoBar as InfoBarOrg
from Screens.MessageBox import MessageBox
from Screens.Standby import inStandby
from Components.config import config
from Components.ServiceEventTracker import ServiceEventTracker
from Tools import Notifications
Expand Down Expand Up @@ -139,13 +140,16 @@ def removeTimeshift(self, service_str=None):
def startTSRecording(self, service_ref, event_data):
logger.info("...")
service_str = service_ref.toString()
self.timeshifts[service_str].startTSRecording(service_ref, event_data)
self.timeshifts[service_str].startTSRecording(event_data)

def stopTSRecording(self, service_str):
logger.info("service_str: %s", service_str)
if service_str not in self.fixed_services and self.service_str != service_str:
logger.info("service_str: %s, self.service_str: %s", service_str, self.service_str)
if not inStandby:
if service_str not in self.fixed_services and self.service_str != service_str:
self.removeTimeshift(service_str)
self.addTimeshift(self.service_str)
else:
self.removeTimeshift(service_str)
self.addTimeshift(self.service_str)

def getEventsInfo(self):
logger.info("service_str: %s", self.service_str)
Expand Down
6 changes: 1 addition & 5 deletions src/Playback.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@

class Playback():

def __init__(self, session, infobar_instance, service_ref):
def __init__(self):
logger.info("...")
self.session = session
self.infobar_instance = infobar_instance
self.service_ref = service_ref
self.timeshift_start_time = 0
self.service = None

def startPlayer(self):
Expand Down
55 changes: 29 additions & 26 deletions src/RecordingUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,37 @@
# <http://www.gnu.org/licenses/>.


from time import time
import os
import re
from time import time, strftime, localtime
from RecordTimer import AFTEREVENT
from ServiceReference import ServiceReference
import NavigationInstance
from Screens.InfoBar import InfoBar
from Plugins.SystemPlugins.JobCockpit.JobCockpit import JobCockpit
try:
from Plugins.SystemPlugins.SocketCockpit.SocketCockpit import SocketCockpit
except ImportError:
class SocketCockpit():
def __init__(self):
return

@staticmethod
def getInstance():
return None
from .Debug import logger
from .JobUtils import getPendingJobs


def getRecordings():
return getLiveRecordings() + getTimeshiftRecordings()


def getLiveRecordings():
logger.debug("...")
recordings_list = []
recordings = []
for timer in NavigationInstance.instance.RecordTimer.timer_list:
if timer.isRunning() and not timer.justplay:
recordings_list.append(timer.Filename)
return recordings_list
recordings.append(timer.Filename)
return recordings


def getTimeshiftRecordings():
logger.debug("...")
recordings_list = []
recordings = []
if hasattr(InfoBar.instance, "getTimeshiftRecordings"):
recordings_list = InfoBar.instance.getTimeshiftRecordings()
return recordings_list
recordings = InfoBar.instance.getTimeshiftRecordings()
return recordings


def isRecording(path=""):
Expand Down Expand Up @@ -93,15 +90,6 @@ def isTimeshiftRecording(path=""):
return is_timeshift_recording


def isFileStreaming():
is_file_streaming = False
socket_cockpit = SocketCockpit.getInstance()
if socket_cockpit:
is_file_streaming = socket_cockpit.isFileStreaming()
logger.debug("is_file_streaming: %s", is_file_streaming)
return is_file_streaming


def stopRecording(path, force=True):
logger.info("path: %s, force: %s", path, force)
logger.debug("is_timeshift_recording: %s", isTimeshiftRecording(path))
Expand Down Expand Up @@ -142,3 +130,18 @@ def startTimeshift():
logger.info("...")
if hasattr(InfoBar.instance, "addTimeshift"):
InfoBar.instance.addTimeshift()


def calcRecordingFilename(begin, service, event_title, dirname):
if isinstance(service, str):
service_name = service
else:
service_name = ServiceReference(service).getServiceName()
logger.info("begin: %s, service_name: %s, event_title: %s, dirname: %s", begin, service_name, event_title, dirname)
begin_date_time = strftime("%Y%m%d %H%M", localtime(begin))
filename = "%s - %s - %s" % (begin_date_time, service_name, event_title)
filename = filename.replace('\xc2\x86', '').replace('\xc2\x87', '')
filename = re.sub(r'[<>:"/\\|?*\0]', '_', filename)
filename = os.path.join(dirname, filename)
logger.debug("filename: %s", filename)
return filename
22 changes: 8 additions & 14 deletions src/TSRecordingJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,30 @@
from Plugins.SystemPlugins.JobCockpit.JobSupervisor import JobSupervisor
from .Debug import logger
from .TSRecordingTask import TSRecordingTask
from .TimeshiftUtils import calcFilename
from .RecordingUtils import calcRecordingFilename
from .Version import ID
from .__init__ import _


class TSRecordingJob():

def __init__(self, infobar_instance):
self.service_str = ""
self.infobar_instance = infobar_instance
def __init__(self):
self.job_manager = JobSupervisor.getInstance().getJobManager(ID)

def onTimeshiftRecordingChange(self):
for function in self.infobar_instance.on_timeshift_recording_change:
function()

def startTSRecording(self, service_ref, event_data):
def startTSRecording(self, 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)
job = Job("%s - %s" % (_("TS recording"), event_data[2]))
job.target_path = calcFilename(event_data[0], service_ref, event_data[2], config.plugins.timeshiftcockpit.videodir.value)
job.service_str = service_ref.toString()
job.keep_successfull_jobs = True
TSRecordingTask(job, self.infobar_instance, service_ref, path, job.target_path, timeshift_start_time, event_data, self.addJobCallback)
job.target_path = calcRecordingFilename(event_data[0], self.service_ref, event_data[2], config.plugins.timeshiftcockpit.videodir.value) + ".ts"
job.service_str = self.service_str
job.keep = True
TSRecordingTask(job, self.infobar_instance, self.service_ref, self.timeshift_file_path, job.target_path, self.timeshift_start_time, event_data, self.addJobCallback)
self.job_manager.AddJob(job)
self.onTimeshiftRecordingChange()

def addJobCallback(self, error):
logger.info("error: %s", error)
Expand Down
31 changes: 19 additions & 12 deletions src/TSRecordingTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,28 @@

import os
from Components.Task import Task
from enigma import eTimer
try:
from Plugins.SystemPlugins.CacheCockpit.FileManager import FileManager
except Exception:
FileManager = None
from .Debug import logger
from .TSRecordingTaskExecution import TSRecordingTaskExecution
from .TimeshiftUtils import ERROR_NONE, ERROR
from .__init__ import _
from .FileUtils import deleteFiles


ACTIVITY_TIMER_DELAY = 1000
from .DelayTimer import DelayTimer


class TSRecordingTask(Task, TSRecordingTaskExecution):

def __init__(self, job, infobar_instance, service_ref, path, target_path, timeshift_start_time, event_data, job_callback):
logger.info("path = %s", path)
Task.__init__(self, job, _("Timeshift recording"))
TSRecordingTaskExecution.__init__(self)
self.job = job
self.job_callback = job_callback
self.infobar_instance = infobar_instance
self.service_ref = service_ref
self.service_str = service_ref.toString()
self.event_data = event_data
self.event_start_time = event_data[0]
self.event_duration = event_data[1]
Expand All @@ -55,8 +56,7 @@ def __init__(self, job, infobar_instance, service_ref, path, target_path, timesh
self.service_ref = service_ref
self.timeshift_start_time = timeshift_start_time
self.error = ERROR_NONE
self.progress_timer = eTimer()
self.progress_timer_conn = self.progress_timer.timeout.connect(self.updateProgress)
TSRecordingTaskExecution.__init__(self)

def abort(self, *args):
logger.info("args: %s", args)
Expand All @@ -74,9 +74,7 @@ def run(self, callback):
deleteFiles(os.path.splitext(self.target_path)[0] + ".*")

self.callback = callback
self.progress_timer.start(ACTIVITY_TIMER_DELAY)
if os.path.exists(self.path):
self.updateProgress()
self.execTSRecording()
else:
logger.error("timeshift file %s does not exist", self.path)
Expand All @@ -85,9 +83,18 @@ def run(self, callback):
def execTSRecordingCallback(self, error):
logger.info("path: %s, target_path: %s, error: %s", self.path, self.target_path, error)
self.error = error
self.progress_timer.stop()
logger.debug("job.progress: %s", self.job.getProgress())
self.finish()

def afterRun(self):
service_str = self.service_ref.toString()
logger.info("service_str: %s", service_str)
logger.info("service_str: %s", self.service_str)
logger.debug("job.progress: %s", self.job.getProgress())
DelayTimer(50, self.completeJob)

def completeJob(self):
logger.info("service_str: %s", self.service_str)
if self.error == ERROR_NONE:
if FileManager:
FileManager.getInstance("MVC").loadDatabaseFile(self.job.target_path)
self.infobar_instance.stopTSRecording(self.service_str)
self.job_callback(self.error)
Loading

0 comments on commit 95ca40b

Please sign in to comment.