summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/Xdcc.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/Xdcc.py')
-rw-r--r--module/plugins/hoster/Xdcc.py69
1 files changed, 26 insertions, 43 deletions
diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py
index 53f61836b..a26e239ad 100644
--- a/module/plugins/hoster/Xdcc.py
+++ b/module/plugins/hoster/Xdcc.py
@@ -1,48 +1,33 @@
# -*- coding: utf-8 -*-
-"""
- 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.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>.
-
- @author: jeix
-"""
-
-from os.path import join
-from os.path import exists
-from os import makedirs
import re
-import sys
-import time
import socket
import struct
+import sys
+import time
+
+from os import makedirs
+from os.path import exists, join
from select import select
-from module.utils import save_join
from module.plugins.Hoster import Hoster
+from module.utils import save_join
class Xdcc(Hoster):
__name__ = "Xdcc"
- __version__ = "0.32"
- __pattern__ = r'xdcc://([^/]*?)(/#?.*?)?/.*?/#?\d+/?' # xdcc://irc.Abjects.net/#channel/[XDCC]|Shit/#0004/
__type__ = "hoster"
+ __version__ = "0.32"
+
__config__ = [("nick", "str", "Nickname", "pyload"),
("ident", "str", "Ident", "pyloadident"),
("realname", "str", "Realname", "pyloadreal")]
+
__description__ = """Download from IRC XDCC bot"""
__author_name__ = "jeix"
__author_mail__ = "jeix@hasnomail.com"
+
def setup(self):
self.debug = 0 # 0,1,2
self.timeout = 30
@@ -64,7 +49,7 @@ class Xdcc(Hoster):
else:
errno = e.args[0]
- if errno in (10054,):
+ if errno == 10054:
self.logDebug("XDCC: Server blocked our ip, retry in 5 min")
self.setWait(300)
self.wait()
@@ -77,11 +62,6 @@ class Xdcc(Hoster):
def doDownload(self, url):
self.pyfile.setStatus("waiting") # real link
- download_folder = self.config['general']['download_folder']
- location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding()))
- if not exists(location):
- makedirs(location)
-
m = re.match(r'xdcc://(.*?)/#?(.*?)/(.*?)/#?(\d+)/?', url)
server = m.group(1)
chan = m.group(2)
@@ -168,31 +148,31 @@ class Xdcc(Hoster):
"text": msg[3][1:]
}
- if nick == msg["target"][0:len(nick)] and "PRIVMSG" == msg["action"]:
- if msg["text"] == "\x01VERSION\x01":
+ if nick == msg['target'][0:len(nick)] and "PRIVMSG" == msg['action']:
+ if msg['text'] == "\x01VERSION\x01":
self.logDebug("XDCC: Sending CTCP VERSION.")
sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface"))
- elif msg["text"] == "\x01TIME\x01":
+ elif msg['text'] == "\x01TIME\x01":
self.logDebug("Sending CTCP TIME.")
sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time()))
- elif msg["text"] == "\x01LAG\x01":
+ elif msg['text'] == "\x01LAG\x01":
pass # don't know how to answer
- if not (bot == msg["origin"][0:len(bot)]
- and nick == msg["target"][0:len(nick)]
- and msg["action"] in ("PRIVMSG", "NOTICE")):
+ if not (bot == msg['origin'][0:len(bot)]
+ and nick == msg['target'][0:len(nick)]
+ and msg['action'] in ("PRIVMSG", "NOTICE")):
continue
if self.debug is 1:
- print "%s: %s" % (msg["origin"], msg["text"])
+ print "%s: %s" % (msg['origin'], msg['text'])
- if "You already requested that pack" in msg["text"]:
+ if "You already requested that pack" in msg['text']:
retry = time.time() + 300
- if "you must be on a known channel to request a pack" in msg["text"]:
+ if "you must be on a known channel to request a pack" in msg['text']:
self.fail("Wrong channel")
- m = re.match('\x01DCC SEND (.*?) (\d+) (\d+)(?: (\d+))?\x01', msg["text"])
+ m = re.match('\x01DCC SEND (.*?) (\d+) (\d+)(?: (\d+))?\x01', msg['text'])
if m:
done = True
@@ -205,7 +185,10 @@ class Xdcc(Hoster):
self.req.filesize = int(m.group(4))
self.pyfile.name = packname
- filename = save_join(location, packname)
+
+ download_folder = self.config['general']['download_folder']
+ filename = save_join(download_folder, packname)
+
self.logInfo("XDCC: Downloading %s from %s:%d" % (packname, ip, port))
self.pyfile.setStatus("downloading")