11
11
from troi .content_resolver .utils import bcolors
12
12
from troi .content_resolver .py_sonic_fix import FixedConnection
13
13
14
- logger = logging .getLogger (__name__ )
14
+ logger = logging .getLogger ("troi_subsonic_scan" )
15
+
16
+ APP_LOG_LEVEL_NUM = 19
17
+ logging .addLevelName (APP_LOG_LEVEL_NUM , "NOTICE" )
18
+
19
+ def applog (message , * args , ** kwargs ):
20
+ logger ._log (APP_LOG_LEVEL_NUM , message , args , ** kwargs )
15
21
16
22
17
23
class SubsonicDatabase (Database ):
@@ -102,8 +108,9 @@ def run_sync(self):
102
108
album_mbid = album_info2 ["albumInfo" ]["musicBrainzId" ]
103
109
except KeyError :
104
110
if not self .quiet :
105
- pbar .write (bcolors .FAIL + "FAIL " + bcolors .ENDC + "subsonic album '%s' by '%s' has no MBID" %
106
- (album ["name" ], album ["artist" ]))
111
+ msg = "subsonic album '%s' by '%s' has no MBID" % (album ["name" ], album ["artist" ])
112
+ pbar .write (bcolors .FAIL + "FAIL " + bcolors .ENDC + msg )
113
+ applog ("FAIL: " + msg )
107
114
self .error += 1
108
115
continue
109
116
@@ -123,9 +130,12 @@ def run_sync(self):
123
130
artist_id_index [artist_id ] = artist ["artistInfo2" ]["musicBrainzId" ]
124
131
except KeyError :
125
132
if not self .quiet :
126
- pbar .write (bcolors .FAIL + "FAIL " + bcolors .ENDC + "recording '%s' by '%s' has no artist MBID" %
127
- (album ["name" ], album ["artist" ]))
128
- pbar .write ("Consider retagging this file with Picard! ( https://picard.musicbrainz.org )" )
133
+ msg = "recording '%s' by '%s' has no artist MBID" % (album ["name" ], album ["artist" ])
134
+ pbar .write (bcolors .FAIL + "FAIL " + bcolors .ENDC + msg )
135
+ applog ("FAIL " + msg )
136
+ msg = "Consider retagging this file with Picard! ( https://picard.musicbrainz.org )"
137
+ pbar .write (msg )
138
+ applog (msg )
129
139
self .error += 1
130
140
continue
131
141
@@ -145,8 +155,10 @@ def run_sync(self):
145
155
})
146
156
147
157
if not self .quiet :
148
- pbar .write (bcolors .OKGREEN + "OK " + bcolors .ENDC + "album %-50s %-50s" %
149
- (album ["name" ][:49 ], album ["artist" ][:49 ]))
158
+ msg = "album %-50s %-50s" % (album ["name" ][:49 ], album ["artist" ][:49 ])
159
+ pbar .write (bcolors .OKGREEN + "OK " + bcolors .ENDC + msg )
160
+ applog (msg )
161
+
150
162
self .matched += 1
151
163
self .total += 1
152
164
if not self .quiet :
0 commit comments