forked from jamesmeneghello/pynab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
105 lines (93 loc) · 3.7 KB
/
install.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import sys
import json
if __name__ == '__main__':
print('Welcome to Pynab.')
print('-----------------')
print()
print('Please ensure that you have copied and renamed config.sample.py to config.py before proceeding.')
print(
'You need to put in your details, too. If you are migrating from Newznab, check out scripts/convert_from_newznab.py first.')
print()
print('This script is destructive. Ensure that the database credentials and settings are correct.')
print('The supplied database really should be empty, but it\'ll just drop anything it wants to overwrite.')
print()
input('To continue, press enter. To exit, press ctrl-c.')
try:
import config
from pynab.db import db
import pynab.util
import scripts.ensure_indexes
except ImportError:
print('Could not load config.py.')
sys.exit(0)
print('Copying users into Mongo...')
with open('db/initial/users.json', encoding='utf-8', errors='ignore') as f:
data = json.load(f)
try:
db.users.drop()
db.users.insert(data)
except:
print('Problem inserting data into MongoDB.')
sys.exit(0)
print('Copying groups into Mongo...')
with open('db/initial/groups.json', encoding='utf-8', errors='ignore') as f:
data = json.load(f)
try:
db.groups.drop()
db.groups.insert(data)
except:
print('Problem inserting data into MongoDB.')
sys.exit(0)
print('Copying categories into Mongo...')
with open('db/initial/categories.json', encoding='utf-8', errors='ignore') as f:
data = json.load(f)
try:
db.categories.drop()
db.categories.insert(data)
except:
print('Problem inserting data into MongoDB.')
sys.exit(0)
print('Copying tvrage into Mongo...')
with open('db/initial/tvrage.json', encoding='utf-8', errors='ignore') as f:
data = json.load(f)
try:
db.tvrage.drop()
db.tvrage.insert(data)
except:
print('Problem inserting data into MongoDB.')
sys.exit(0)
print('Copying imdb into Mongo...')
with open('db/initial/imdb.json', encoding='utf-8', errors='ignore') as f:
data = json.load(f)
try:
db.imdb.drop()
db.imdb.insert(data)
except:
print('Problem inserting data into MongoDB.')
sys.exit(0)
print('Copying tvdb into Mongo...')
with open('db/initial/tvdb.json', encoding='utf-8', errors='ignore') as f:
data = json.load(f)
try:
db.tvdb.drop()
db.tvdb.insert(data)
except:
print('Problem inserting data into MongoDB.')
sys.exit(0)
if config.site['regex_url']:
print('Updating regex...')
pynab.util.update_regex()
else:
print('Could not update regex - no update url/key in config.py.')
print('If you don\'t have one, buy a Newznab+ license or find your own regexes.')
print('You won\'t be able to build releases without appropriate regexes.')
if config.site['blacklist_url']:
print('Updating binary blacklist...')
pynab.util.update_blacklist()
else:
print(
'Could not update blacklist. Try the URL in config.py manually - if it doesn\'t work, post an issue on Github.')
print('Creating indexes on collections...')
scripts.ensure_indexes.create_indexes()
print('Install theoretically completed - the rest of the collections will be made as they\'re needed.')
print('Now: activate some groups, activate desired blacklists, and run start.py with python3.')