示例#1
0
 def suspendedStateChanged(self, on):
     if on and self.auto_resume:
         KTorrent.log(
             "AutoResumeScript: torrents suspended, starting timer")
         self.startTimer()
     else:
         self.timer.stop()
示例#2
0
	def removeTracker(self,tracker):
		g = self.tracker_map[fqdn(tracker)]
		g.unref()
		if g.canBeRemoved():
			KTorrent.log("Removing group for tracker " + tracker)
			KTScriptingPlugin.removeGroup(g.url)
			del self.tracker_map[tracker]
示例#3
0
	def addTracker(self,tracker):
		g = TrackerGroup(tracker)
		g.ref()
		self.tracker_map[tracker] = g
		KTorrent.log("Adding group for tracker " + tracker)
		KTScriptingPlugin.addGroup(tracker,"network-server","/all/" + t.i18n("Trackers") + "/" + str(self.id),g)
		self.id += 1
示例#4
0
	def addTracker(self,tracker):
		g = TrackerGroup(tracker)
		g.ref()
		self.tracker_map[tracker] = g
		KTorrent.log("Adding group for tracker " + tracker)
		KTScriptingPlugin.addGroup(tracker,"network-server","/all/" + t.i18n("Trackers") + "/" + str(self.id),g)
		self.id += 1
示例#5
0
	def unload(self):
		trackers = self.tracker_map.keys()
		for tracker in trackers:
			g = self.tracker_map[tracker]
			KTorrent.log("Removing group for tracker " + tracker)
			KTScriptingPlugin.removeGroup(g.url)
			del self.tracker_map[tracker]
示例#6
0
	def removeTracker(self,tracker):
		g = self.tracker_map[fqdn(tracker)]
		g.unref()
		if g.canBeRemoved():
			KTorrent.log("Removing group for tracker " + tracker)
			KTScriptingPlugin.removeGroup(g.url)
			del self.tracker_map[tracker]
示例#7
0
 def __init__(self):
     self.command = ""
     KTorrent.connect("torrentAdded(const QString &)", self.torrentAdded)
     tors = KTorrent.torrents()
     # bind to signals for each torrent
     for t in tors:
         self.torrentAdded(t)
示例#8
0
	def unload(self):
		trackers = self.tracker_map.keys()
		for tracker in trackers:
			g = self.tracker_map[tracker]
			KTorrent.log("Removing group for tracker " + tracker)
			KTScriptingPlugin.removeGroup(g.url)
			del self.tracker_map[tracker]
示例#9
0
	def __init__(self):
		self.auto_resume = False
		self.hours = 0
		self.minutes = 5
		self.seconds = 0
		KTorrent.connect("pauseStateChanged(bool)",self.pausedStateChanged)
		self.timer = KTScriptingPlugin.createTimer(True)
		self.timer.connect('timeout()',self.timerFired)
示例#10
0
 def connectSignals(self, tor):
     KTorrent.log("connectSignals " + tor.name())
     tor.connect("finished(QObject* )", self.torrentFinished)
     tor.connect("stoppedByError(QObject* ,const QString & )",
                 self.torrentStoppedByError)
     tor.connect("seedingAutoStopped(QObject* ,const QString & )",
                 self.seedingAutoStopped)
     tor.connect("corruptedDataFound(QObject* )", self.corruptedDataFound)
示例#11
0
	def __init__(self):
		self.auto_resume = False
		self.hours = 0
		self.minutes = 5
		self.seconds = 0
		KTorrent.connect("suspendStateChanged(bool)",self.suspendedStateChanged)
		self.timer = KTScriptingPlugin.createTimer(True)
		self.timer.connect('timeout()',self.timerFired)
示例#12
0
	def __init__(self):
		self.tracker_map = {} # initialize the dictionary
		self.id = 0
		KTorrent.connect("torrentAdded(const QString &)",self.torrentAdded)
		KTorrent.connect("torrentRemoved(const QString &)",self.torrentRemoved)
		tors = KTorrent.torrents()
		# go over each torrent and collect all the trackers
		for t in tors:
			self.torrentAdded(t)
示例#13
0
	def __init__(self):
		self.tracker_map = {} # initialize the dictionary
		self.id = 0
		KTorrent.connect("torrentAdded(const QString &)",self.torrentAdded)
		KTorrent.connect("torrentRemoved(const QString &)",self.torrentRemoved)
		tors = KTorrent.torrents()
		# go over each torrent and collect all the trackers
		for t in tors:
			self.torrentAdded(t)
示例#14
0
    def __init__(self):
        KTorrent.connect("torrentAdded(const QString &)", self.torrentAdded)
        tors = KTorrent.torrents()
        # bind to signals for each torrent
        f = open(
            KTScriptingPlugin.scriptDir("auto_tracker_add") + "tracker.list")
        self.trackers = f.read().splitlines()

        for t in tors:
            self.torrentAdded(t)
示例#15
0
	def __init__(self):
		self.auto_resume = False
		self.remove_on_finish_downloading = False
		self.remove_on_finish_seeding = False
		self.timer = KTScriptingPlugin.createTimer(True)
		KTorrent.connect("torrentAdded(const QString &)",self.torrentAdded)
		tors = KTorrent.torrents()
		# bind to signals for each torrent
		for t in tors:
			self.torrentAdded(t)
示例#16
0
	def __init__(self):
		self.auto_resume = False
		self.remove_on_finish_downloading = False
		self.remove_on_finish_seeding = False
		self.timer = KTScriptingPlugin.createTimer(True)
		KTorrent.connect("torrentAdded(const QString &)",self.torrentAdded)
		tors = KTorrent.torrents()
		# bind to signals for each torrent
		for t in tors:
			self.torrentAdded(t)
示例#17
0
	def load(self):
		self.auto_resume = KTScriptingPlugin.readConfigEntryBool("AutoResumeScript","auto_resume",self.auto_resume)
		self.hours = KTScriptingPlugin.readConfigEntryInt("AutoResumeScript","hours",self.hours)
		self.minutes = KTScriptingPlugin.readConfigEntryInt("AutoResumeScript","minutes",self.minutes)
		self.seconds = KTScriptingPlugin.readConfigEntryInt("AutoResumeScript","seconds",self.seconds)
		if self.auto_resume and KTorrent.paused():
			self.startTimer()
示例#18
0
 def __init__(self):
     self.mail_user = "******"
     self.mail_pwd = "your_password"
     self.mail_server = "smtp.gmail.com"
     self.mail_port = 587
     self.mail_dest = "*****@*****.**"
     self.mail_add_cc = False
     self.mail_cc = ""
     self.mail_add_bcc = False
     self.mail_bcc = ""
     self.mail_use_tls = True
     KTorrent.connect("torrentAdded(const QString &)", self.torrentAdded)
     tors = KTorrent.torrents()
     # bind to signals for each torrent
     for t in tors:
         self.torrentAdded(t)
示例#19
0
	def load(self):
		self.auto_resume = KTScriptingPlugin.readConfigEntryBool("AutoResumeScript","auto_resume",self.auto_resume)
		self.hours = KTScriptingPlugin.readConfigEntryInt("AutoResumeScript","hours",self.hours)
		self.minutes = KTScriptingPlugin.readConfigEntryInt("AutoResumeScript","minutes",self.minutes)
		self.seconds = KTScriptingPlugin.readConfigEntryInt("AutoResumeScript","seconds",self.seconds)
		if self.auto_resume and KTorrent.suspended():
			self.startTimer()
	def __init__(self):
		self.mail_user = "******"
		self.mail_pwd = "your_password"
		self.mail_server = "smtp.gmail.com"
		self.mail_port = 587
		self.mail_dest = "*****@*****.**"
		self.mail_add_cc = False
		self.mail_cc = ""
		self.mail_add_bcc = False
		self.mail_bcc = ""
		self.mail_use_tls = True
		KTorrent.connect("torrentAdded(const QString &)",self.torrentAdded)
		tors = KTorrent.torrents()
		# bind to signals for each torrent
		for t in tors:
			self.torrentAdded(t)
示例#21
0
	def isMember(self,info_hash):
		if info_hash in self.cache:
			return self.cache[info_hash]
		else:
			tor = KTorrent.torrent(info_hash)
			ret = self.url in [fqdn(tracker) for tracker in tor.trackers()]
			self.cache[info_hash] = ret
			return ret
示例#22
0
	def isMember(self,info_hash):
		if info_hash in self.cache:
			return self.cache[info_hash]
		else:
			tor = KTorrent.torrent(info_hash)
			ret = self.url in [fqdn(tracker) for tracker in tor.trackers()]
			self.cache[info_hash] = ret
			return ret
示例#23
0
 def torrentAdded(self, info_hash):
     tor = KTorrent.torrent(info_hash)
     trackers = tor.trackers()
     for tracker in trackers:
         if not tracker in self.tracker_map:
             self.addTracker(tracker)
         else:
             self.tracker_map[tracker].ref()
示例#24
0
	def torrentAdded(self,info_hash):
		tor = KTorrent.torrent(info_hash)
		trackers = tor.trackers()
		for tracker in trackers:
			hostname = fqdn(tracker)
			if not hostname in self.tracker_map:
				self.addTracker(hostname)
			else:
				self.tracker_map[hostname].ref()
示例#25
0
	def torrentAdded(self,info_hash):
		tor = KTorrent.torrent(info_hash)
		trackers = tor.trackers()
		for tracker in trackers:
			hostname = fqdn(tracker)
			if not hostname in self.tracker_map:
				self.addTracker(hostname)
			else:
				self.tracker_map[hostname].ref()
示例#26
0
	def configure(self):
		forms = Kross.module("forms")
		dialog = forms.createDialog(t.i18n("Auto Resume Settings"))
		dialog.setButtons("Ok|Cancel")
		page = dialog.addPage(t.i18n("Auto Resume"),t.i18n("Auto Resume"),"kt-bandwidth-scheduler")
		widget = forms.createWidgetFromUIFile(page,KTScriptingPlugin.scriptDir("auto_resume") + "auto_resume.ui")
		widget["auto_resume"].checked = self.auto_resume
		widget["hours"].value = self.hours
		widget["minutes"].value = self.minutes
		widget["seconds"].value = self.seconds
		widget["hours"].enabled = self.auto_resume
		widget["minutes"].enabled = self.auto_resume
		widget["seconds"].enabled = self.auto_resume
		if dialog.exec_loop():
			self.auto_resume = widget["auto_resume"].checked
			self.hours = widget["hours"].value
			self.minutes = widget["minutes"].value
			self.seconds = widget["seconds"].value
			self.save()
			if self.auto_resume and KTorrent.suspended():
				self.startTimer()
示例#27
0
	def configure(self):
		forms = Kross.module("forms")
		dialog = forms.createDialog(t.i18n("Auto Resume Settings"))
		dialog.setButtons("Ok|Cancel")
		page = dialog.addPage(t.i18n("Auto Resume"),t.i18n("Auto Resume"),"kt-bandwidth-scheduler")
		widget = forms.createWidgetFromUIFile(page,KTScriptingPlugin.scriptDir("auto_resume") + "auto_resume.ui")
		widget["auto_resume"].checked = self.auto_resume
		widget["hours"].value = self.hours
		widget["minutes"].value = self.minutes
		widget["seconds"].value = self.seconds
		widget["hours"].enabled = self.auto_resume
		widget["minutes"].enabled = self.auto_resume
		widget["seconds"].enabled = self.auto_resume
		if dialog.exec_loop():
			self.auto_resume = widget["auto_resume"].checked
			self.hours = widget["hours"].value
			self.minutes = widget["minutes"].value
			self.seconds = widget["seconds"].value
			self.save()
			if self.auto_resume and KTorrent.paused():
				self.startTimer()
	def torrentAdded(self,ih):
		tor = KTorrent.torrent(ih)
		self.connectSignals(tor)
示例#29
0
 def timerFired(self):
     if KTorrent.suspended():
         KTorrent.log("AutoResumeScript: resuming suspended torrents")
         KTorrent.setSuspended(False)
示例#30
0
 def torrentAdded(self, ih):
     tor = KTorrent.torrent(ih)
     KTorrent.log("Torrent added %s" % tor.name())
     for tk in self.trackers:
         tor.addTracker(tk)
示例#31
0
#!/usr/bin/python
import KTorrent
import Kross

def torrentAdded(ih):
	tor = KTorrent.torrent(ih)
	KTorrent.log("torrentAdded=%s" % tor.name())

def torrentRemoved(ih):
	tor = KTorrent.torrent(ih)
	KTorrent.log("torrentRemoved=%s" % tor.name())

 
KTorrent.connect("torrentAdded(const QString &)",torrentAdded)
KTorrent.connect("torrentRemoved(const QString &)",torrentRemoved)

tors = KTorrent.torrents()

KTorrent.log("Num torrents : %i" % len(tors))
for t in tors:
	tor = KTorrent.torrent(t)
	KTorrent.log("Torrent %s = %s" % (t, tor.name()))
	for i in range(0,tor.numFiles()):
		KTorrent.log("File %i = %s" % (i,tor.filePath(i)))
示例#32
0
def torrentRemoved(ih):
	tor = KTorrent.torrent(ih)
	KTorrent.log("torrentRemoved=%s" % tor.name())
示例#33
0
	def timerFired(self):
		if KTorrent.suspended():
			KTorrent.log("AutoResumeScript: resuming suspended torrents")
			KTorrent.setSuspended(False)
	def connectSignals(self,tor):
		KTorrent.log("connectSignals " + tor.name())
		tor.connect("finished(QObject* )",self.torrentFinished)
		tor.connect("stoppedByError(QObject* ,const QString & )",self.torrentStoppedByError)
		tor.connect("seedingAutoStopped(QObject* ,const QString & )",self.seedingAutoStopped)
		tor.connect("corruptedDataFound(QObject* )",self.corruptedDataFound)
示例#35
0
	def suspendedStateChanged(self,on):
		if on and self.auto_resume:
			KTorrent.log("AutoResumeScript: torrents suspended, starting timer")
			self.startTimer()
		else:
			self.timer.stop()
	def mail(self,subject, text):
		msg = MIMEMultipart()
		
		msg['From'] = self.mail_user
		msg['To'] = self.mail_dest
		msg['Subject'] = subject
		if self.mail_add_cc:
			msg['CC'] = self.mail_cc
		if self.mail_add_bcc:
			msg['BCC'] = self.mail_bcc
		
		msg.attach(MIMEText(text))
		KTorrent.log("Sending mail : " + subject)
		
		try:
			mailServer = smtplib.SMTP(self.mail_server, self.mail_port)
			mailServer.ehlo()
			if self.mail_use_tls:
				mailServer.starttls()
				mailServer.ehlo()
				
			mailServer.login(self.mail_user, self.mail_pwd)
			mailServer.sendmail(self.mail_user, self.mail_dest, msg.as_string())
			mailServer.quit()
		except smtplib.SMTPRecipientsRefused:
			KTorrent.log("Failed to send e-mail notification: recipients refushed")
		except smtplib.SMTPHeloError:
			KTorrent.log("Failed to send e-mail notification: helo error")
		except smtplib.SMTPSenderRefused:
			KTorrent.log("Failed to send e-mail notification: sender refused")
		except smtplib.SMTPDataError:
			KTorrent.log("Failed to send e-mail notification: something went wrong sending data")
		except smtplib.SMTPAuthenticationError:
			KTorrent.log("Failed to send e-mail notification: authentication failed")
		except smtplib.SMTPException:
			KTorrent.log("Failed to send e-mail notification")
		except socket.error, err:
			KTorrent.log("Failed to send e-mail notification: %s " % err)
示例#37
0
    def mail(self, subject, text):
        msg = MIMEMultipart()

        msg['From'] = self.mail_user
        msg['To'] = self.mail_dest
        msg['Subject'] = subject
        if self.mail_add_cc:
            msg['CC'] = self.mail_cc
        if self.mail_add_bcc:
            msg['BCC'] = self.mail_bcc

        msg.attach(MIMEText(text))
        KTorrent.log("Sending mail : " + subject)

        try:
            mailServer = smtplib.SMTP(self.mail_server, self.mail_port)
            mailServer.ehlo()
            if self.mail_use_tls:
                mailServer.starttls()
                mailServer.ehlo()

            mailServer.login(self.mail_user, self.mail_pwd)
            mailServer.sendmail(self.mail_user, self.mail_dest,
                                msg.as_string())
            mailServer.quit()
        except smtplib.SMTPRecipientsRefused:
            KTorrent.log(
                "Failed to send e-mail notification: recipients refushed")
        except smtplib.SMTPHeloError:
            KTorrent.log("Failed to send e-mail notification: helo error")
        except smtplib.SMTPSenderRefused:
            KTorrent.log("Failed to send e-mail notification: sender refused")
        except smtplib.SMTPDataError:
            KTorrent.log(
                "Failed to send e-mail notification: something went wrong sending data"
            )
        except smtplib.SMTPAuthenticationError:
            KTorrent.log(
                "Failed to send e-mail notification: authentication failed")
        except smtplib.SMTPException:
            KTorrent.log("Failed to send e-mail notification")
        except socket.error, err:
            KTorrent.log("Failed to send e-mail notification: %s " % err)
示例#38
0
 def torrentAdded(self, ih):
     tor = KTorrent.torrent(ih)
     self.connectSignals(tor)
示例#39
0
#!/usr/bin/python
import KTorrent
import Kross

def torrentAdded(ih):
	tor = KTorrent.torrent(ih)
	KTorrent.log("torrentAdded=%s" % tor.name())

def torrentRemoved(ih):
	tor = KTorrent.torrent(ih)
	KTorrent.log("torrentRemoved=%s" % tor.name())

 
KTorrent.connect("torrentAdded(const QString &)",torrentAdded)
KTorrent.connect("torrentRemoved(const QString &)",torrentRemoved)

tors = KTorrent.torrents()

KTorrent.log("Num torrents : %i" % len(tors))
for t in tors:
	tor = KTorrent.torrent(t)
	KTorrent.log("Torrent %s = %s" % (t, tor.name()))
	for i in range(0,tor.numFiles()):
		KTorrent.log("File %i = %s" % (i,tor.filePath(i)))
示例#40
0
	def timerFired(self):
		if KTorrent.paused():
			KTorrent.log("AutoResumeScript: resuming paused torrents")
			KTorrent.setPaused(False)
示例#41
0
	def torrentFinished(self,tor):
		KTorrent.log("Torrent finished %s" % tor.name())
		if self.remove_on_finish_downloading:
			KTorrent.log("Removing %s" % tor.name())
			KTorrent.removeDelayed(tor.infoHash(),False)
示例#42
0
def torrentRemoved(ih):
	tor = KTorrent.torrent(ih)
	KTorrent.log("torrentRemoved=%s" % tor.name())
示例#43
0
	def seedingAutoStopped(self,tor,reason):
		KTorrent.log("Torrent finished seeding %s" % tor.name())
		if self.remove_on_finish_seeding:
			KTorrent.log("Removing %s" % tor.name())
			KTorrent.removeDelayed(tor.infoHash(),False)
示例#44
0
	def torrentRemoved(self,info_hash):
		tor = KTorrent.torrent(info_hash)
		trackers = tor.trackers()
		for tracker in trackers:
			if tracker in self.tracker_map:
				self.removeTracker(tracker)
示例#45
0
	def torrentRemoved(self,info_hash):
		tor = KTorrent.torrent(info_hash)
		trackers = tor.trackers()
		for tracker in trackers:
			if tracker in self.tracker_map:
				self.removeTracker(tracker)
示例#46
0
 def torrentAdded(self, ih):
     tor = KTorrent.torrent(ih)
     KTorrent.log("Torrent added %s" % tor.name())
     tor.connect("finished(QObject* )", self.torrentFinished)
		except smtplib.SMTPRecipientsRefused:
			KTorrent.log("Failed to send e-mail notification: recipients refushed")
		except smtplib.SMTPHeloError:
			KTorrent.log("Failed to send e-mail notification: helo error")
		except smtplib.SMTPSenderRefused:
			KTorrent.log("Failed to send e-mail notification: sender refused")
		except smtplib.SMTPDataError:
			KTorrent.log("Failed to send e-mail notification: something went wrong sending data")
		except smtplib.SMTPAuthenticationError:
			KTorrent.log("Failed to send e-mail notification: authentication failed")
		except smtplib.SMTPException:
			KTorrent.log("Failed to send e-mail notification")
		except socket.error, err:
			KTorrent.log("Failed to send e-mail notification: %s " % err)
		except:
			KTorrent.log("Failed to send e-mail notification")
		else:
			KTorrent.log("Successfully sent e-mail notification")

	def save(self):
		KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript","username",self.mail_user)
		KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript","password",self.mail_pwd)
		KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript","server",self.mail_server)
		KTScriptingPlugin.writeConfigEntryInt("EMailNotificationsScript","port",self.mail_port)
		KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript","dest",self.mail_dest)
		KTScriptingPlugin.writeConfigEntryBool("EMailNotificationsScript","add_cc",self.mail_add_cc)
		KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript","cc",self.mail_cc)
		KTScriptingPlugin.writeConfigEntryBool("EMailNotificationsScript","add_bcc",self.mail_add_bcc)
		KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript","bcc",self.mail_bcc)
		KTScriptingPlugin.writeConfigEntryBool("EMailNotificationsScript","use_tls",self.mail_use_tls)
		KTScriptingPlugin.syncConfig("EMailNotificationsScript")
示例#48
0
	def torrentAdded(self,ih):
		tor = KTorrent.torrent(ih)
		KTorrent.log("Torrent added %s" % tor.name())
		tor.connect("finished(QObject* )",self.torrentFinished)
		tor.connect("seedingAutoStopped(QObject* ,const QString & )",self.seedingAutoStopped)
示例#49
0
	def torrentFinished(self,tor):
		KTorrent.log("Torrent finished %s" % tor.name())
		if self.remove_on_finish_downloading:
			KTorrent.log("Removing %s" % tor.name())
			KTorrent.removeDelayed(tor.infoHash(),False)
示例#50
0
	def seedingAutoStopped(self,tor,reason):
		KTorrent.log("Torrent finished seeding %s" % tor.name())
		if self.remove_on_finish_seeding:
			KTorrent.log("Removing %s" % tor.name())
			KTorrent.removeDelayed(tor.infoHash(),False)
示例#51
0
	def torrentAdded(self,ih):
		tor = KTorrent.torrent(ih)
		KTorrent.log("Torrent added %s" % tor.name())
		tor.connect("finished(QObject* )",self.torrentFinished)
		tor.connect("seedingAutoStopped(QObject* ,const QString & )",self.seedingAutoStopped)
示例#52
0
            KTorrent.log("Failed to send e-mail notification: helo error")
        except smtplib.SMTPSenderRefused:
            KTorrent.log("Failed to send e-mail notification: sender refused")
        except smtplib.SMTPDataError:
            KTorrent.log(
                "Failed to send e-mail notification: something went wrong sending data"
            )
        except smtplib.SMTPAuthenticationError:
            KTorrent.log(
                "Failed to send e-mail notification: authentication failed")
        except smtplib.SMTPException:
            KTorrent.log("Failed to send e-mail notification")
        except socket.error, err:
            KTorrent.log("Failed to send e-mail notification: %s " % err)
        except:
            KTorrent.log("Failed to send e-mail notification")
        else:
            KTorrent.log("Successfully sent e-mail notification")

    def save(self):
        KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript",
                                           "username", self.mail_user)
        KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript",
                                           "password", self.mail_pwd)
        KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript",
                                           "server", self.mail_server)
        KTScriptingPlugin.writeConfigEntryInt("EMailNotificationsScript",
                                              "port", self.mail_port)
        KTScriptingPlugin.writeConfigEntry("EMailNotificationsScript", "dest",
                                           self.mail_dest)
        KTScriptingPlugin.writeConfigEntryBool("EMailNotificationsScript",
示例#53
0
 def torrentFinished(self, tor):
     KTorrent.log("Torrent finished %s" % tor.name())
     if self.command != "":
         KTorrent.log("Executing command: %s" % self.command)
         KTorrent.log("For torrent: %s" % tor.name())
         call([self.command, tor.infoHash(), tor.name(), tor.pathOnDisk()])