forked from teticio/Deej-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_tracks.py
51 lines (42 loc) · 1.24 KB
/
search_tracks.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
import argparse
import pandas as pd
pd.set_option("max_colwidth", 0)
pd.set_option("display.max_rows", 1000)
if __name__ == "__main__":
"""
Entry point for the search_tracks script.
Searches for tracks on Spotify.
Args:
--search (str): Search string. Default is None (interactive mode).
--tracks_file (str): Path to the tracks CSV file. Default is "data/tracks_dedup.csv".
Returns:
None
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"--search",
type=str,
default=None,
help="Search string",
)
parser.add_argument(
"--tracks_file",
type=str,
default="data/tracks_dedup.csv",
help="Tracks CSV file",
)
args = parser.parse_args()
tracks_df = pd.read_csv(
args.tracks_file,
header=None,
index_col=0,
names=["artist", "title", "url", "count"],
).fillna("")
tracks_df["name"] = tracks_df["artist"] + " - " + tracks_df["title"]
interactive = args.search is None
while interactive:
if interactive:
args.search = input("Search: ")
print(
tracks_df[tracks_df["name"].str.contains(args.search, case=False)][["name"]]
)