-
Notifications
You must be signed in to change notification settings - Fork 6
/
beatporter.py
47 lines (38 loc) · 1.29 KB
/
beatporter.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
import sys
import json
import spotify
import beatport
import argparse
from datetime import datetime
def dump_tracks(tracks):
i = 1
for track in tracks:
print(
"{}: {} ({}) - {} ({})".format(
i,
track["name"],
track["mix"],
", ".join(track["artists"]),
track["duration"],
)
)
i += 1
if __name__ == "__main__":
start_time = datetime.now()
parser = argparse.ArgumentParser(description="Beatporter")
parser.add_argument("--genres", action="store_true")
args = parser.parse_args()
if args.genres:
print(json.dumps(beatport.get_genres(), indent=4))
sys.exit()
print("[!] Starting @ {}\n".format(start_time))
top_100_charts = dict()
for genre, genre_bp_url_code in beatport.genres.items():
top_100_charts[genre] = beatport.get_top_100_tracks(genre)
for genre in top_100_charts:
print("\n***** {} *****".format(genre))
dump_tracks(top_100_charts[genre])
print("\n\n")
spotify.add_new_tracks_to_playlist(genre, top_100_charts[genre])
end_time = datetime.now()
print("\n[!] Done @ {}\n (Ran for: {})".format(end_time, end_time - start_time))