forked from rmcauley/rainwave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rw_scanner.py
executable file
·44 lines (38 loc) · 1.35 KB
/
rw_scanner.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
#!/usr/bin/python
import argparse
import backend.filemonitor
import libs.config
import libs.log
import libs.db
import libs.cache
import libs.chuser
import rainwave.playlist
import rainwave.playlist_objects.album
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Rainwave song scanning daemon.")
parser.add_argument("--config", default=None)
parser.add_argument("--full", action="store_true")
parser.add_argument("--reset", action="store_true")
parser.add_argument("--art", action="store_true")
args = parser.parse_args()
libs.config.load(args.config)
if libs.config.get("log_level") == "print" and (args.art or args.full):
libs.log.init("%s/rw_scanner.log" % libs.config.get_directory("log_dir"), "debug")
else:
libs.log.init("%s/rw_scanner.log" % libs.config.get_directory("log_dir"), libs.config.get("log_level"))
libs.db.connect()
libs.cache.connect()
for sid in libs.config.station_ids:
rainwave.playlist_objects.album.clear_updated_albums(sid)
if libs.config.get("scanner_user") and libs.config.get("scanner_group"):
libs.chuser.change_user(libs.config.get("scanner_user"), libs.config.get("scanner_group"))
try:
if args.art:
backend.filemonitor.full_art_update()
elif args.full:
backend.filemonitor.full_music_scan(args.reset)
else:
backend.filemonitor.monitor()
finally:
libs.db.close()
libs.log.close()