-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.py
84 lines (72 loc) · 2.99 KB
/
script.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
import subprocess
import os
import sys
import tidalapi
if len(sys.argv) < 2:
print("At least 1 argument needed!")
exit()
session = tidalapi.Session()
login, future = session.login_oauth()
print("Visit:", "https://" + login.verification_uri_complete, "to authenticate.")
future.result()
print()
print("Searching...")
i = 0
certainIds = open("certain_ids.txt", "w") #Clears the file everytime the script runs
uncertainIds = open("uncertain_ids.txt", "w") #Clears the file everytime the script runs
uncertainAlbums = open("uncertain_albums.txt", "w") #Clears the file everytime the script runs
notFound = open("not_found.txt", "w") #Clears the file everytime the script runs
dir = ""
if sys.argv[1][len(sys.argv[1]) - 1] != '/':
dir = sys.argv[1] + '/'
else:
dir = sys.argv[1]
for artist in os.listdir(dir):
for a in os.listdir(dir + artist):
album = a[0:a.find("[") - 1]
year = a[a.find("[") + 1:a.find("]")]
home = session.search(artist + " " + album)
if len(home["albums"]) > 0:
any = False
for element in home["albums"]:
if element.name == album and element.year == int(year) and element.artist.name == artist:
print(element.id, end = " ", file = certainIds)
i += 1
any = True
break
if not any:
home = session.search(album)
if len(home["albums"]) > 0:
any = False
for element in home["albums"]:
if element.name == album and element.year == int(year):
print(element.id, end = " ", file = uncertainIds)
print("Tidal:", element.artist.name + " - " + element.name, "\t\t\tActual:", artist + " - " + album, file = uncertainAlbums)
any = True
i += 1
break
if not any:
print(artist + " - " + album, file = notFound)
else:
print(artist + " - " + album, file = notFound)
else:
home = session.search(album)
if len(home["albums"]) > 0:
any = False
for element in home["albums"]:
if element.name == album and element.year == int(year):
print(element.id, end = " ", file = uncertainIds)
print("Tidal:", element.artist.name + " - " + element.name, "\t\t\tActual:", artist + " - " + album, file = uncertainAlbums)
any = True
i += 1
break
if not any:
print(artist + " - " + album, file = notFound)
else:
print(artist + " - " + album, file = notFound)
certainIds.close()
uncertainIds.close()
uncertainAlbums.close()
notFound.close()
print()
print("Found: ", i)