def selectedTargetDir(self, file_op, selection_list, target_dir): logger.debug("file_op: %s, target_dir: %s", file_op, target_dir) if target_dir: if not MountCockpit.getInstance().getMountPoint(ID, target_dir): self.session.open(MessageBox, target_dir + " " + _("is not mounted"), MessageBox.TYPE_ERROR) else: active_recordings_list = [] file_ops_list = [] for path in selection_list: if not path.endswith("trashcan") and not path.endswith( ".."): if not isRecording(path): file_ops_list.append( (file_op, path, os.path.normpath(target_dir))) else: active_recordings_list.append(path) self.execFileManagerOps(file_ops_list) if active_recordings_list: file_names = self.createMovieList(active_recordings_list) msg = _( "Can't move recordings" ) + "\n" + file_names if file_op == FILE_OP_MOVE else _( "Can't copy recordings") + "\n" + file_names self.session.open(MessageBox, msg, MessageBox.TYPE_INFO)
def getRecordingPosition(self): position = 0 path = self.service.getPath() recording = isRecording(path) if recording: position = secondsToPts(time() - self.recording_start_time) else: position = self.getPosition() return position
def doEofInternal(self, playing): logger.info("playing: %s, self.execing: %s", playing, self.execing) if self.execing: if isRecording(self.service.getPath()): self.session.nav.playService(self.service) self.doSeekRelative(secondsToPts(-1)) else: self.is_closing = True if self.leave_on_eof: self.leavePlayer()
def stopRecordings(self): logger.info("...") self.file_ops_list = [] self.file_delete_list = [] self.recordings_to_stop = [] selection_list = self.movie_list.getSelectionList() for path in selection_list: if isRecording(path): self.recordings_to_stop.append(path) if self.recordings_to_stop: self.stopRecordingsQuery()
def doStep2(self): logger.info("...") self.selectAll() self.recordings = self.movie_list.getSelectionList() self.recordings_to_stop = [] for path in self.recordings: if isRecording(path): self.recordings_to_stop.append(path) self.recordings = self.recordings_to_stop[:] if len(self.recordings_to_stop) == 1: self.stopRecordingsResponse(True) else: logger.debug("danger: more than one recording active!") self.doStep3()
def deleteMovies(self): logger.info("...") self.file_ops_list = [] self.file_delete_list = [] self.recordings_to_stop = [] selection_list = self.movie_list.getSelectionList() for path in selection_list: logger.debug("path: %s", path) if not path.endswith("trashcan") and not path.endswith(".."): afile = self.movie_list.getFile(path) if not config.plugins.moviecockpit.trashcan_enable.value or "/trashcan" in path: if afile[FILE_IDX_TYPE] == FILE_TYPE_DIR: all_dirs = MountCockpit.getInstance().getVirtualDirs( ID, [path]) for adir in all_dirs: self.file_ops_list.append( (FILE_OP_DELETE, adir, None)) else: self.file_ops_list.append((FILE_OP_DELETE, path, None)) self.file_delete_list.append(path) else: bookmark = MountCockpit.getInstance().getBookmark(ID, path) sub_path = path[len(bookmark) + 1:] if afile[FILE_IDX_TYPE] == FILE_TYPE_DIR: all_dirs = MountCockpit.getInstance().getVirtualDirs( ID, [path]) for adir in all_dirs: bookmark = MountCockpit.getInstance().getBookmark( ID, adir) trashcan_path = os.path.dirname( os.path.join(bookmark, "trashcan", sub_path)) self.file_ops_list.append( (FILE_OP_MOVE, adir, trashcan_path)) else: trashcan_path = os.path.dirname( os.path.join(bookmark, "trashcan", sub_path)) self.file_ops_list.append( (FILE_OP_MOVE, path, trashcan_path)) if isRecording(path): self.recordings_to_stop.append(path) if self.recordings_to_stop: self.stopRecordingsQuery() else: self.deleteMoviesQuery()
def restoreMovies(self): logger.info("...") file_ops_list = [] selection_list = self.movie_list.getSelectionList() for path in selection_list: if not path.endswith("..") and not isRecording(path): afile = self.movie_list.getFile(path) if afile[FILE_IDX_TYPE] == FILE_TYPE_DIR: all_dirs = MountCockpit.getInstance().getVirtualDirs( ID, [path]) for adir in all_dirs: movie_dir = os.path.dirname( adir.replace("/trashcan", "", 1)) file_ops_list.append((FILE_OP_MOVE, adir, movie_dir)) else: movie_dir = os.path.dirname( path.replace("/trashcan", "", 1)) file_ops_list.append((FILE_OP_MOVE, path, movie_dir)) self.execFileManagerOps(file_ops_list)
def buildMovieListEntry(self, _directory, file_type, path, _file_name, _ext, name, event_start_time, _recording_start_time, _recording_stop_time, length, description, _extended_description, service_reference, _size, cuts, tags): def isCutting(path): logger.debug("isCutting: path: %s", path) file_name = os.path.splitext(path)[0] return file_name.endswith("_") and not os.path.exists(file_name + ".eit") def getPicon(service_reference): pos = service_reference.rfind(':') if pos != -1: service_reference = service_reference[:pos].rstrip( ':').replace(':', '_') picon_path = os.path.join( config.usage.configselection_piconspath.value, service_reference + '.png') logger.debug("picon_path: %s", picon_path) return loadPNG(picon_path) def getDateText(path, file_type, date): logger.debug("path: %s, file_type: %s, date: %s", path, file_type, date) count = 0 date_text = "" if path in self.lock_list: file_op = self.lock_list[path] if file_op == FILE_OP_COPY: date_text = _("COPYING") elif file_op == FILE_OP_MOVE: date_text = _("MOVING") elif file_op == FILE_OP_DELETE: date_text = _("DELETING") else: if file_type == FILE_TYPE_FILE: if config.plugins.moviecockpit.list_show_mount_points.value: words = path.split("/") if len(words) > 3 and words[1] == "media": date_text = words[2] else: date_text = datetime.fromtimestamp(date).strftime( config.plugins.moviecockpit.movie_date_format.value ) else: if os.path.basename(path) == "trashcan": info_value = config.plugins.moviecockpit.trashcan_info.value else: info_value = config.plugins.moviecockpit.directories_info.value if os.path.basename(path) == "..": date_text = _("up") else: if info_value == "D": if os.path.basename(path) == "trashcan": date_text = _("trashcan") else: date_text = _("directory") else: count, size = FileManager.getInstance( ).getCountSize(path) counttext = "%d" % count size /= (1024 * 1024 * 1024) # GB sizetext = "%.0f GB" % size if size >= 1024: sizetext = "%.1f TB" % (size / 1024) if info_value == "C": date_text = "(%s)" % counttext elif info_value == "S": date_text = "(%s)" % sizetext elif info_value == "CS": date_text = "(%s/%s)" % (counttext, sizetext) logger.debug("count: %s, date_text: %s", count, date_text) return date_text def getProgress(recording, path, event_start_time, length, cuts): logger.debug("path: %s", path) if recording: last = time() - event_start_time else: # get last position from cut file cut_list = unpackCutList(cuts) logger.debug("cut_list: %s", cut_list) last = ptsToSeconds(getCutListLast(cut_list)) logger.debug("last: %s", last) progress = 0 if length > 0 and last > 0: last = min(last, length) progress = int(round(float(last) / float(length), 2) * 100) logger.debug("progress: %s, path: %s, length: %s, recording: %s", progress, path, length, recording) return progress def getFileIcon(path, file_type, progress, recording, cutting): pixmap = None if file_type == FILE_TYPE_FILE: pixmap = self.pic_movie_default if recording: pixmap = self.pic_movie_rec elif cutting: pixmap = self.pic_movie_cut else: if progress >= int(config.plugins.moviecockpit. movie_finished_percent.value): pixmap = self.pic_movie_finished elif progress >= int(config.plugins.moviecockpit. movie_watching_percent.value): pixmap = self.pic_movie_watching elif file_type == FILE_TYPE_LINK: pixmap = self.pic_link elif file_type == FILE_TYPE_DIR: pixmap = self.pic_directory if os.path.basename(path) == "trashcan": pixmap = self.pic_trashcan elif os.path.basename(path) == "..": pixmap = self.pic_back return pixmap def getColor(path, file_type, recording, cutting): if path in self.selection_list or path in self.lock_list: color = self.selection_color color_sel = self.selection_color_sel else: if file_type == FILE_TYPE_FILE: if recording or cutting: color = self.recording_color color_sel = self.recording_color_sel else: color = self.color color_sel = self.color_sel else: color = self.color_sel color_sel = self.color_sel return color, color_sel logger.debug("list_style: %s", self.list_styles[self.list_style][0]) service = ServiceReference(service_reference) service_name = service.getServiceName() if service is not None else "" recording = isRecording(path) cutting = isCutting(path) color, color_sel = getColor(path, file_type, recording, cutting) progress = getProgress(recording, path, event_start_time, length, cuts) if file_type == FILE_TYPE_FILE else -1 progress_string = str(progress) + "%" if progress >= 0 else "" progress_bar = self.pic_rec_progress_bar if recording else self.pic_progress_bar length_string = str(length / 60) + " " + _( "min") if file_type == FILE_TYPE_FILE else "" picon = getPicon( service_reference) if file_type == FILE_TYPE_FILE else None name = _(name) if name == "trashcan" else name date_text = getDateText(path, file_type, event_start_time) file_icon = getFileIcon(path, file_type, progress, recording, cutting) res = [ None, name, # 1: name tags, # 2: tags service_name, # 3: service name description, # 4: short description date_text, # 5: event start time length_string, # 6: length color, # 7: color color_sel, # 8: color_sel progress, # 9: progress percent (-1 = don't show) progress_string, # 10: progress (xx%) progress_bar, # 11: progress bar png file_icon, # 12: status icon png picon, # 13: picon png ] #logger.debug("self.res: %s", res) return res