-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmissinglink.py
More file actions
61 lines (57 loc) · 2.1 KB
/
missinglink.py
File metadata and controls
61 lines (57 loc) · 2.1 KB
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
58
59
60
61
#!/usr/bin/env python
#
# missinglink.py
#
#
# Copyright (C) 2009 detcader <>
#
# 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 2 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
import os, sys
from mainwindow import MainWindow
def valid_aurl(a): #TODO: replace with regex
"""Checks validity of tracker URLs """
return a.startswith('http://') and \
a.endswith('/announce') and a.count('/') == 4
def main():
if not os.path.exists('announce'):
print 'ERROR: missing announce url file'
print 'creating one... please edit with your announce URL on the first line'
announcefile = open('announce', 'w')
return 0
f = open('announce')
lines = f.readlines()
a = lines[0]
f.close()
if not a:
print 'ERROR: announce file empty'
elif not valid_aurl(a.strip()):
print 'ERROR: invalid announe url: ' + a
else:
un = None
pw = None
excludes = None
if len(lines) == 3: # gets user/pass if present
un = lines[1].strip()
pw = lines[2].strip()
if len(lines) == 4:
un = lines[1].strip()
pw = lines[2].strip()
excludes = [e.strip() for e in lines[3].split(',')]
print 'starting with trasnfer-excluded filetypes: ' + str(excludes)
newwindow = MainWindow(a, un, pw, excludes)
return 0
if __name__ == '__main__': main()