-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxdcc_downloader.py
executable file
·57 lines (51 loc) · 1.5 KB
/
xdcc_downloader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /usr/bin/python3
import argparse
import subprocess
import os
class XDCCDownloaderC:
def __init__(self, xdcc, name):
self.m_xdcc = xdcc
self.m_filename = name
def Download(self):
if not self.m_xdcc:
return False
dlPath = os.getcwd()
# shellCommand = [
# 'xterm',
# '-e'
# ]
command = [
'weechat',
'-r',
# '"'
]
weechatCommands = [
'/set xfer.file.auto_accept_files on',
'/set xfer.file.use_nick_in_filename off',
'/set xfer.file.convert_spaces off',
'/set xfer.file.download_path {0}'.format(dlPath),
'/server add AnimeDLRizon irc.rizon.net',
'/set irc.server.AnimeDLRizon.autojoin #horriblesubs'
]
onJoinCommands = [
"/set irc.server.AnimeDLRizon.command '/msg {0} xdcc send #{1}".format(self.m_xdcc['b'], self.m_xdcc['n']),
'/wait 3s /buffer 3',
'/trigger addreplace anime_dl_xfer_ended_hook signal xfer_ended \\"\\" \\"\\" \\"/quit\\"\''
]
weechatCommands.append('\;'.join(onJoinCommands))
weechatCommands.append('/connect AnimeDLRizon')
command.append(';'.join(weechatCommands))
# command.append('"')
# shellCommand.append(' '.join(command))
subprocess.run(command)
return os.path.isfile(self.m_xdcc['f'])
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-b", "--bot" , help="Bot", dest="bot")
parser.add_argument("-n", "--nick", help="Nick", dest="nick")
args = parser.parse_args()
xdcc = {'n': args.nick, 'b': args.bot, 'f': 'name'}
dl = XDCCDownloaderC(xdcc, "")
dl.Download()
if __name__ == "__main__":
main()