-
Notifications
You must be signed in to change notification settings - Fork 5
/
runScansNow.py
58 lines (52 loc) · 1.58 KB
/
runScansNow.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
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : runScans.py
@Time : 2023/10/24
@Author : Jacob Roy
@Version : 1.0
@Contact : [email protected]
@Desc :
'''
import multiprocessing
from time import gmtime, strftime
from tidalrr.database import getSettings
from tidalrr.workers import print_elapsed_time, tidalrrStart
from tidalrr.workers.scanQueuedArtists import scanQueuedArtists
from tidalrr.workers.scanQueuedAlbums import scanQueuedAlbums
from tidalrr.workers.scanQueuedPlaylists import scanQueuedPlaylists
from tidalrr.workers.scanUserPlaylists import scanUserPlaylists
@print_elapsed_time
def startScans():
settings = getSettings()
print(strftime("%Y-%m-%d %H:%M:%S", gmtime())+" startScans")
tidalrrStart()
print('tidalrrStart')
scanQueuedArtists()
print('Done scanning artists')
scanQueuedAlbums()
print('Done scanning albums')
#scanQueuedTracks()
#print('scanQueuedTracks')
if settings.scanUserPlaylists:
scanUserPlaylists()
print('scanUserPlaylist')
scanQueuedPlaylists()
print('scanQueuedPlaylists')
def forkScans():
# Start foo as a process
print(strftime("%Y-%m-%d %H:%M:%S", gmtime())+" Starting scans")
p = multiprocessing.Process(target=startScans)
p.start()
p.join()
# If thread is active
if p.is_alive():
print(strftime("%Y-%m-%d %H:%M:%S", gmtime())+" Scans are running... let's kill it...")
# Terminate foo
p.terminate()
# Cleanup
p.join()
if __name__ == '__main__':
forkScans()
#main()
#mainSchedule()