-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.py
93 lines (72 loc) · 2.81 KB
/
config.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
import ConfigParser, os, sys
import re
import random
import string
from ConfigParser import NoOptionError
class ConfigException(Exception):
def __init__(self, message):
self.message = message
def __str__(self):
return str(self.message)
class MelimanConfig:
def __init__(self):
self.config = ConfigParser.ConfigParser()
p = os.path.dirname(__file__)
self.config_files = [
'/etc/meliman.conf',
os.path.join(p, 'meliman.conf'),
]
config_exists = False
for config_file in self.config_files:
if os.path.exists(config_file):
config_exists = True
if not config_exists:
raise ConfigException('meliman.conf does not exist.' + \
'You must create this file in the application directory before running meliman.')
self.config.read(self.config_files)
def reset(self):
self.config = ConfigParser.ConfigParser()
self.config.read(self.config_files)
def getDatabaseFile(self):
return self.config.get('Database', 'file')
def getLibraryInputPath(self):
return self.config.get('Library', 'input_path')
def getLibraryMovieInputPath(self):
try:
return self.config.get('Library', 'movie_input_path')
except:
return None
def getLibraryTvPath(self):
return self.config.get('Library', 'tv_path')
def getLibraryTvGenrePath(self):
try:
return self.config.get('Library', 'tv_genre_path')
except:
return None
def getLibraryMoviePath(self):
try:
return self.config.get('Library', 'movie_path')
except:
return None
def getLibraryMovieGenrePath(self):
try:
return self.config.get('Library', 'movie_genre_path')
except:
return None
def getLibraryFormat(self):
return self.config.get('Library', 'format')
def getLibraryRecentPath(self):
return self.config.get('Library', 'recent_path')
def getLibraryRecentDurationInMinutes(self):
return self.config.get('Library', 'recent_duration_in_minutes')
def getMediaFileExtensions(self):
return self.config.get('Miscellaneous', 'media_file_extensions')
def getLockFile(self):
return self.config.get('Miscellaneous', 'lock_file')
def getTitleWordsToIgnore(self):
words_to_ignore_str = self.config.get('Miscellaneous', 'title_words_to_ignore')
return [w.strip() for w in words_to_ignore_str.split(',')]
def getTitleCharsToIgnore(self):
return self.config.get('Miscellaneous', 'title_chars_to_ignore').strip()
def getWaitFromFileCreationInMinutes(self):
return self.config.get('Miscellaneous', 'wait_after_file_creation_in_minutes').strip()