-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_client_2.py
67 lines (48 loc) · 1.82 KB
/
test_client_2.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
import sys
import time
import os
from utils import (
hms_string,
)
from nbs_client import (
get_artist,
)
DEFAULT_MAX_ARTISTS = 100
DEFAULT_INITIAL_ARTIST = 1
user_token = os.environ.get('NEXT_BIG_SOUND_TOKEN')
def main(argv):
if not user_token:
print 'Missing NEXT_BIG_SOUND_TOKEN environment variable'
sys.exit(2)
max_artists = DEFAULT_MAX_ARTISTS
initial_artist = DEFAULT_INITIAL_ARTIST
try:
max_artists = int(argv[0])
initial_artist = int(argv[1])
except Exception:
pass
print('\nGenerating {} artist ids starting at {}\n'.format(max_artists, initial_artist))
start_time = time.time()
count_artist = 0
artist_without_images = 0
artist_without_genres = 0
artist_without_social_media_links = 0
for artist_id in xrange(initial_artist, initial_artist + max_artists):
artist = get_artist(id=artist_id)
if artist:
count_artist += 1
print('Artist {0}: {1} \n'.format(artist_id, artist))
if not artist['images']:
artist_without_images += 1
if not artist['genres']:
artist_without_genres += 1
if not artist['social_media_links']:
artist_without_social_media_links += 1
elapsed_time = time.time() - start_time
print('Elapsed time: {}'.format(hms_string(elapsed_time)))
print('Artists parsed begining at {}: {} from {}'.format(initial_artist, count_artist, max_artists))
print('Artists without images: {} from {}'.format(artist_without_images, count_artist))
print('Artists without genres: {} from {}'.format(artist_without_genres, count_artist))
print('Artists without social_media_links: {} from {}'.format(artist_without_social_media_links, count_artist))
if __name__ == '__main__':
main(sys.argv[1:])