コード例 #1
0
	def record(self):
		if self.event and self.service:
			event = self.event
			ref = self.service
			if event is None:
				return
			eventid = event.getEventId()
			eref = eServiceReference(str(ref))
			refstr = eref.toString()
			for timer in self.session.nav.RecordTimer.timer_list:
				if timer.eit == eventid and timer.service_ref.ref.toString() == refstr:
					cb_func = lambda ret : not ret or self.removeTimer(timer)
					self.session.openWithCallback(cb_func, MessageBox, _("Do you really want to delete %s?") % event.getEventName())
					break
			else:
				#newEntry = RecordTimerEntry(ServiceReference(ref), checkOldTimers = True, dirname = preferredTimerPath(), *parseEvent(self.event))
				begin, end, name, description, eit = parseEvent(self.event)
				
				from SeriesPlugin import refactorTitle, refactorDescription
				if self.data:
					name = refactorTitle(name, self.data)
					description = refactorDescription(description, self.data)
				
				#newEntry = RecordTimerEntry(ServiceReference(refstr), begin, end, name, description, eit, dirname = preferredTimerPath())
				newEntry = RecordTimerEntry(ServiceReference(str(ref)), begin, end, name, description, eit, dirname = preferredTimerPath())
				#newEntry = RecordTimerEntry(refstr, begin, end, name, description, eit, dirname = preferredTimerPath())
				self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
コード例 #2
0
	def keyRecord(self):
		log.debug("keyRecord")
		if self.event and self.service:
			event = self.event
			ref = self.service
			if event is None:
				return
			eventid = event.getEventId()
			eref = eServiceReference(str(ref))
			refstr = eref.toString()
			for timer in self.session.nav.RecordTimer.timer_list:
				if timer.eit == eventid and timer.service_ref.ref.toString() == refstr:
					cb_func = lambda ret : not ret or self.removeTimer(timer)
					self.session.openWithCallback(cb_func, MessageBox, _("Do you really want to delete %s?") % event.getEventName())
					break
			else:
				#newEntry = RecordTimerEntry(ServiceReference(ref), checkOldTimers = True, dirname = preferredTimerPath(), *parseEvent(self.event))
				begin, end, name, description, eit = parseEvent(self.event)
				
				from SeriesPlugin import refactorTitle, refactorDescription
				if self.data:
					name = refactorTitle(name, self.data)
					description = refactorDescription(description, self.data)
				
				#newEntry = RecordTimerEntry(ServiceReference(refstr), begin, end, name, description, eit, dirname = preferredTimerPath())
				newEntry = RecordTimerEntry(ServiceReference(str(ref)), begin, end, name, description, eit, dirname = preferredTimerPath())
				#newEntry = RecordTimerEntry(refstr, begin, end, name, description, eit, dirname = preferredTimerPath())
				self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
コード例 #3
0
def bareGetSeasonEpisode(service_ref, name, begin, end, description, path, future=True, today=False, elapsed=False):
	result = _("SeriesPlugin is deactivated")
	if config.plugins.seriesplugin.enabled.value:
		
		startLog()
		
		logInfo("Bare:", service_ref, name, begin, end, description, path, future, today, elapsed)
		
		from SeriesPlugin import getInstance, refactorTitle, refactorDescription, refactorDirectory
		seriesPlugin = getInstance()
		data = seriesPlugin.getEpisodeBlocking(
			name, begin, end, service_ref, future, today, elapsed
		)
		
		global loop_counter
		loop_counter += 1
		
		if data and isinstance(data, dict):
			name = str(refactorTitle(name, data))
			description = str(refactorDescription(description, data))
			path = refactorDirectory(path, data)
			logInfo("Bare: Success", name, description, path)
			return (name, description, path, getLog())
		elif data:
			global loop_data
			loop_data.append( str(data) )
		
		logInfo("Bare: Failed", str(data))
		return str(data)
	
	return result
コード例 #4
0
def bareGetSeasonEpisode(service_ref, name, begin, end, description, path, future=True, today=False, elapsed=False):
	result = None
	if config.plugins.seriesplugin.enabled.value:
		
		startLog()
		
		logInfo("Bare:", service_ref, name, begin, end, description, path, future, today, elapsed)
		
		from SeriesPlugin import getInstance, refactorTitle, refactorDescription, refactorDirectory
		seriesPlugin = getInstance()
		data = seriesPlugin.getEpisodeBlocking(
			name, begin, end, service_ref, future, today, elapsed
		)
		
		global loop_counter
		loop_counter += 1
		
		if data and len(data) == 4:
			name = str(refactorTitle(name, data))
			description = str(refactorDescription(description, data))
			path = refactorDirectory(path, data)
			logInfo("Bare: Success", name, description, path)
			return (name, description, path, getLog())
		elif data:
			global loop_data
			loop_data.append( str(data) )
		
		logInfo("Bare: Failed", str(data))
		return str(data)
	
	return result
コード例 #5
0
	def timerCallback(self, timer, data=None):
		log.debug("timerCallback", data)
		
		if data and isinstance(data, dict) and timer:
			
			# Episode data available, refactor name and description
			timer.name = str(refactorTitle(timer.name, data))
			timer.description = str(refactorDescription(timer.description, data))
			
			timer.dirname = str(refactorDirectory(timer.dirname or config.usage.default_path.value, data))
			timer.calculateFilename()
			
			msg = _("Success: %s" % (timer.name))
			log.debug(msg)
			timer.log(610, "[SeriesPlugin]" + " " + msg)
			
			if config.plugins.seriesplugin.timer_add_tag.value:
				timer.tags.append(TAG)
		
		elif data:
			msg = _("Failed: %s." % ( str( data ) ))
			log.debug(msg)
			timer.log(611, "[SeriesPlugin]" + " " + msg)
			SeriesPluginTimer.data.append(
				str(timer.name) + ": " + msg
			)
		
		else:
			msg = _("No data available")
			log.debug(msg)
			timer.log(612, "[SeriesPlugin]" + " " + msg)
			SeriesPluginTimer.data.append(
				str(timer.name) + ": " + msg
			)
		
		timer.sp_in_queue = False
		
		SeriesPluginTimer.counter = SeriesPluginTimer.counter +1
		
		# Maybe there is a better way to avoid multiple Popups
		from SeriesPlugin import getInstance
		
		instance = getInstance()
		
		if instance.thread.empty() and instance.thread.finished():
		
			if SeriesPluginTimer.data:
				msg = "SeriesPlugin:\n" + _("Timer rename has been finished with %d errors:\n") % (len(SeriesPluginTimer.data)) +"\n" +"\n".join(SeriesPluginTimer.data)
				log.warning(msg)
				
			else:
				if SeriesPluginTimer.counter > 0:
					msg = "SeriesPlugin:\n" + _("%d timer renamed successfully") % (SeriesPluginTimer.counter)
					log.success(msg)
				
			SeriesPluginTimer.data = []
			SeriesPluginTimer.counter = 0
		
		return timer
コード例 #6
0
	def timerCallback(self, timer, data=None):
		splog("SPT: timerCallback", data)
		splog(data)
		
		if data and len(data) == 4 and timer:
			
			# Episode data available, refactor name and description
			#from SeriesPluginRenamer import newLegacyEncode
			timer.name = str(refactorTitle(timer.name, data))
			#timer.name = newLegacyEncode(refactorTitle(timer.name, data))
			timer.description = str(refactorDescription(timer.description, data))
			
			timer.log(610, "[SeriesPlugin] Success: Changed name: %s." % (timer.name))
		
		elif data:
			timer.log(611, "[SeriesPlugin] Failed: %s." % ( str( data ) ))
			SeriesPluginTimer.data.append(
				str(timer.name) + " " + str( data )
			)
		
		else:
			timer.log(612, "[SeriesPlugin] Failed." )
			SeriesPluginTimer.data.append(
				str(timer.name) + " " + _("No data available")
			)
		
		timer.sp_in_queue = False
		
		if config.plugins.seriesplugin.timer_popups.value or config.plugins.seriesplugin.timer_popups_success.value:
			
			SeriesPluginTimer.counter = SeriesPluginTimer.counter +1
			
			if SeriesPluginTimer.data or config.plugins.seriesplugin.timer_popups_success.value:
				
				# Maybe there is a better way to avoid multiple Popups
				from SeriesPlugin import getInstance
				
				instance = getInstance()
				
				if instance.thread.empty() and instance.thread.finished():
				
					if SeriesPluginTimer.data:
						AddPopup(
							"SeriesPlugin:\n" + _("Timer rename has been finished with %d errors:\n") % (len(SeriesPluginTimer.data)) +"\n" +"\n".join(SeriesPluginTimer.data),
							MessageBox.TYPE_ERROR,
							int(config.plugins.seriesplugin.timer_popups_timeout.value),
							'SP_PopUp_ID_TimerFinished'
						)
					else:
						AddPopup(
							"SeriesPlugin:\n" + _("%d timer renamed successfully") % (SeriesPluginTimer.counter),
							MessageBox.TYPE_INFO,
							int(config.plugins.seriesplugin.timer_popups_timeout.value),
							'SP_PopUp_ID_TimerFinished'
						)
					SeriesPluginTimer.data = []
					SeriesPluginTimer.counter = 0
		
		return timer
コード例 #7
0
	def timerCallback(self, timer, data=None):
		log.debug("timerCallback", data)
		
		if data and isinstance(data, dict) and timer:
			
			# Episode data available, refactor name and description
			timer.name = str(refactorTitle(timer.name, data))
			timer.description = str(refactorDescription(timer.description, data))
			
			timer.dirname = str(refactorDirectory(timer.dirname or config.usage.default_path.value, data))
			timer.calculateFilename()
			
			msg = _("Success: %s" % (timer.name))
			log.debug(msg)
			timer.log(610, "[SeriesPlugin]" + " " + msg)
			
			if config.plugins.seriesplugin.timer_add_tag.value:
				timer.tags.append(TAG)
		
		elif data:
			msg = _("Failed: %s." % ( str( data ) ))
			log.debug(msg)
			timer.log(611, "[SeriesPlugin]" + " " + msg)
			SeriesPluginTimer.data.append(
				str(timer.name) + ": " + msg
			)
		
		else:
			msg = _("No data available")
			log.debug(msg)
			timer.log(612, "[SeriesPlugin]" + " " + msg)
			SeriesPluginTimer.data.append(
				str(timer.name) + ": " + msg
			)
		
		timer.sp_in_queue = False
		
		SeriesPluginTimer.counter = SeriesPluginTimer.counter +1
		
		# Maybe there is a better way to avoid multiple Popups
		from SeriesPlugin import getInstance
		
		instance = getInstance()
		
		if instance.thread.empty() and instance.thread.finished():
		
			if SeriesPluginTimer.data:
				msg = "SeriesPlugin:\n" + _("Timer rename has been finished with %d errors:\n") % (len(SeriesPluginTimer.data)) +"\n" +"\n".join(SeriesPluginTimer.data)
				log.warning(msg)
				
			else:
				if SeriesPluginTimer.counter > 0:
					msg = "SeriesPlugin:\n" + _("%d timer renamed successfully") % (SeriesPluginTimer.counter)
					log.success(msg)
				
			SeriesPluginTimer.data = []
			SeriesPluginTimer.counter = 0
		
		return timer
コード例 #8
0
def bareGetEpisode(service_ref,
                   name,
                   begin,
                   end,
                   description,
                   path,
                   future=True,
                   today=False,
                   elapsed=False):
    result = _("SeriesPlugin is deactivated")
    if config.plugins.seriesplugin.enabled.value:

        log.start()

        log.info("Bare:", service_ref, name, begin, end, description, path,
                 future, today, elapsed)

        from SeriesPlugin import getInstance, refactorTitle, refactorDescription, refactorDirectory
        seriesPlugin = getInstance()
        data = seriesPlugin.getEpisode(None,
                                       name,
                                       begin,
                                       end,
                                       service_ref,
                                       future,
                                       today,
                                       elapsed,
                                       block=True)

        global loop_counter
        loop_counter += 1

        if data and isinstance(data, dict):
            name = str(refactorTitle(name, data))
            description = str(refactorDescription(description, data))
            path = refactorDirectory(path, data)
            log.info("Bare: Success", name, description, path)
            return (name, description, path, log.get())

        elif data and isinstance(data, basestring):
            global loop_data
            msg = _("Failed: %s." % (str(data)))
            log.debug(msg)
            loop_data.append(name + ": " + msg)

        else:
            global loop_data
            msg = _("No data available")
            log.debug(msg)
            loop_data.append(name + ": " + msg)

        log.info("Bare: Failed", str(data))
        return str(data)

    return result
コード例 #9
0
def rewriteMeta(servicepath, name, data):
    #TODO Use MetaSupport EitSupport classes from EMC ?
    if servicepath.endswith(".ts"):
        meta_file = servicepath + ".meta"
    else:
        meta_file = servicepath + ".ts.meta"

    # Create new meta for ts files
    if not os.path.exists(meta_file):
        if os.path.isfile(servicepath):
            _title = os.path.basename(os.path.splitext(servicepath)[0])
        else:
            _title = name
        _sid = ""
        _descr = ""
        _time = ""
        _tags = ""
        metafile = open(meta_file, "w")
        metafile.write("%s\n%s\n%s\n%s\n%s" %
                       (_sid, _title, _descr, _time, _tags))
        metafile.close()

    if os.path.exists(meta_file):
        metafile = open(meta_file, "r")
        sid = metafile.readline()
        oldtitle = metafile.readline().rstrip()
        olddescr = metafile.readline().rstrip()
        rest = metafile.read()
        metafile.close()

        if config.plugins.seriesplugin.pattern_title.value and not config.plugins.seriesplugin.pattern_title.value == "Off":
            title = refactorTitle(oldtitle, data)
        else:
            title = oldtitle
        log.debug("title", title)
        if config.plugins.seriesplugin.pattern_description.value and not config.plugins.seriesplugin.pattern_description.value == "Off":
            descr = refactorDescription(olddescr, data)
        else:
            descr = olddescr
        log.debug("descr", descr)

        metafile = open(meta_file, "w")
        metafile.write("%s%s\n%s\n%s" % (sid, title, descr, rest))
        metafile.close()
    return True
コード例 #10
0
def renameMeta(servicepath, name, data):
	#TODO Use MetaSupport EitSupport classes from EMC ?
	if servicepath.endswith(".ts"):
		meta_file = servicepath + ".meta"
	else:
		meta_file = servicepath + ".ts.meta"
	
	# Create new meta for ts files
	if not os.path.exists(meta_file):
		if os.path.isfile(servicepath):
			_title = os.path.basename(os.path.splitext(servicepath)[0])
		else:
			_title = name
		_sid = ""
		_descr = ""
		_time = ""
		_tags = ""
		metafile = open(meta_file, "w")
		metafile.write("%s\n%s\n%s\n%s\n%s" % (_sid, _title, _descr, _time, _tags))
		metafile.close()
	
	if os.path.exists(meta_file):
		metafile = open(meta_file, "r")
		sid = metafile.readline()
		oldtitle = metafile.readline().rstrip()
		olddescr = metafile.readline().rstrip()
		rest = metafile.read()
		metafile.close()
		
		if config.plugins.seriesplugin.pattern_title.value and not config.plugins.seriesplugin.pattern_title.value == "Off":
			title = refactorTitle(oldtitle, data)
		else:
			title = oldtitle
		logDebug("SPR: title",title)
		if config.plugins.seriesplugin.pattern_description.value and not config.plugins.seriesplugin.pattern_description.value == "Off":
			descr = refactorDescription(olddescr, data)
		else:
			descr = olddescr
		logDebug("SPR: descr",descr)
		
		metafile = open(meta_file, "w")
		metafile.write("%s%s\n%s\n%s" % (sid, title, descr, rest))
		metafile.close()
	return True
コード例 #11
0
def bareGetEpisode(service_ref, name, begin, end, description, path, future=True, today=False, elapsed=False, returnData=False):
	result = _("SeriesPlugin is deactivated")
	if config.plugins.seriesplugin.enabled.value:
		
		log.start()
		
		log.info("Bare:", service_ref, name, begin, end, description, path, future, today, elapsed)
		
		from SeriesPlugin import getInstance, refactorTitle, refactorDescription, refactorDirectory
		seriesPlugin = getInstance()
		data = seriesPlugin.getEpisode(
			None, 
			name, begin, end, service_ref, future, today, elapsed, block=True
		)
		
		global loop_counter
		loop_counter += 1
		
		if data and isinstance(data, dict):
			name = str(refactorTitle(name, data))
			description = str(refactorDescription(description, data))
			path = refactorDirectory(path, data)
			log.info("Bare: Success", name, description, path)
			if returnData:
				return (name, description, path, log.get(), data)
			else:
				return (name, description, path, log.get())
		
		elif data and isinstance(data, basestring):
			global loop_data
			msg = _("Failed: %s." % ( str( data ) ))
			log.debug(msg)
			loop_data.append( name + ": " + msg )
		
		else:
			global loop_data
			msg = _("No data available")
			log.debug(msg)
			loop_data.append( name + ": " + msg )
		
		log.info("Bare: Failed", str(data))
		return str(data)
	
	return result
コード例 #12
0
    def timerCallback(self, timer, data=None):
        splog("SPT: timerCallback", data)
        splog(data)

        if data and len(data) == 4 and timer:

            # Episode data available, refactor name and description
            #from SeriesPluginRenamer import newLegacyEncode
            timer.name = str(refactorTitle(timer.name, data))
            #timer.name = newLegacyEncode(refactorTitle(timer.name, data))
            timer.description = str(
                refactorDescription(timer.description, data))

            timer.log(
                610,
                "[SeriesPlugin] Success: Changed name: %s." % (timer.name))

        elif data:
            timer.log(611, "[SeriesPlugin] Failed: %s." % (str(data)))
            SeriesPluginTimer.data.append(str(timer.name) + " " + str(data))

        else:
            timer.log(612, "[SeriesPlugin] Failed.")
            SeriesPluginTimer.data.append(
                str(timer.name) + " " + _("No data available"))

        timer.sp_in_queue = False

        if config.plugins.seriesplugin.timer_popups.value or config.plugins.seriesplugin.timer_popups_success.value:

            SeriesPluginTimer.counter = SeriesPluginTimer.counter + 1

            if SeriesPluginTimer.data or config.plugins.seriesplugin.timer_popups_success.value:

                # Maybe there is a better way to avoid multiple Popups
                from SeriesPlugin import getInstance

                instance = getInstance()

                if instance.thread.empty() and instance.thread.finished():

                    if SeriesPluginTimer.data:
                        AddPopup(
                            "SeriesPlugin:\n" +
                            _("Timer rename has been finished with %d errors:\n"
                              ) % (len(SeriesPluginTimer.data)) + "\n" +
                            "\n".join(SeriesPluginTimer.data),
                            MessageBox.TYPE_ERROR,
                            int(config.plugins.seriesplugin.
                                timer_popups_timeout.value),
                            'SP_PopUp_ID_TimerFinished')
                    else:
                        AddPopup(
                            "SeriesPlugin:\n" +
                            _("%d timer renamed successfully") %
                            (SeriesPluginTimer.counter), MessageBox.TYPE_INFO,
                            int(config.plugins.seriesplugin.
                                timer_popups_timeout.value),
                            'SP_PopUp_ID_TimerFinished')
                    SeriesPluginTimer.data = []
                    SeriesPluginTimer.counter = 0

        return timer