2022-07-20 23:57:51 +00:00
|
|
|
import time
|
|
|
|
import requests
|
|
|
|
import json
|
2022-09-12 03:07:45 +00:00
|
|
|
import math
|
2022-07-20 23:57:51 +00:00
|
|
|
|
2022-09-12 00:52:17 +00:00
|
|
|
# queued categories: 'terror', 'wrath', 'zombie', 'artifact']
|
2022-07-20 23:57:51 +00:00
|
|
|
# add category name here
|
2022-09-12 00:52:17 +00:00
|
|
|
allCategories = ['counterspell', 'beast', 'burn', 'commander']
|
2022-09-16 06:09:19 +00:00
|
|
|
specialCategories = ['set', 'basic', 'watermark']
|
2022-09-12 03:31:49 +00:00
|
|
|
artist_denylist = '-a%3A"jason+felix"+-a%3A“Harold+McNeill”+-a%3A"Terese+Nielsen"+-a%3A“Noah+Bradley”'
|
2022-09-16 03:47:50 +00:00
|
|
|
artist_allowlist = {'David Martin', 'V\u00e9ronique Meignaud', 'Christopher Rush', 'Rebecca Guay', 'DiTerlizzi',
|
2022-09-16 04:44:32 +00:00
|
|
|
'Anthony Francisco', 'Wylie Beckert', 'Rovina Cai', 'Dominik Mayer', 'Omar Rayyan', 'Thomas M. Baxa'}
|
2022-07-20 23:57:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
def generate_initial_query(category):
|
|
|
|
string_query = 'https://api.scryfall.com/cards/search?q='
|
|
|
|
if category == 'counterspell':
|
2022-09-09 20:25:04 +00:00
|
|
|
string_query += 'otag%3Acounterspell+t%3Ainstant+not%3Aadventure+not%3Adfc'
|
2022-07-20 23:57:51 +00:00
|
|
|
elif category == 'beast':
|
2022-09-09 20:25:04 +00:00
|
|
|
string_query += '-type%3Alegendary+type%3Abeast+-type%3Atoken+not%3Adfc'
|
2022-08-05 04:46:39 +00:00
|
|
|
# elif category == 'terror':
|
|
|
|
# string_query += 'otag%3Acreature-removal+o%3A%2Fdestroy+target.%2A+%28creature%7Cpermanent%29%2F+%28t' \
|
|
|
|
# '%3Ainstant+or+t%3Asorcery%29+o%3Atarget+not%3Aadventure'
|
|
|
|
# elif category == 'wrath':
|
2022-09-12 04:07:18 +00:00
|
|
|
# string_query += 'otag%3Asweeper-creature+%28t%3Ainstant+or+t%3Asorcery%29+not%3Aadventure+not%3Adfc'
|
2022-07-20 23:57:51 +00:00
|
|
|
elif category == 'burn':
|
|
|
|
string_query += '%28c>%3Dr+or+mana>%3Dr%29+%28o%3A%2Fdamage+to+them%2F+or+%28o%3Adeals+o%3Adamage+o%3A' \
|
|
|
|
'%2Fcontroller%28%5C.%7C+%29%2F%29+or+o%3A%2F~+deals+%28.%7C..%29+damage+to+%28any+target%7C' \
|
|
|
|
'.*player%28%5C.%7C+or+planeswalker%29%7C.*opponent%28%5C.%7C+or+planeswalker%29%29%2F%29' \
|
2022-09-09 20:25:04 +00:00
|
|
|
'+%28type%3Ainstant+or+type%3Asorcery%29+not%3Aadventure+not%3Adfc'
|
2022-09-08 23:18:52 +00:00
|
|
|
elif category == 'commander':
|
2022-09-11 12:42:49 +00:00
|
|
|
string_query += 'is%3Acommander+%28not%3Adigital+-banned%3Acommander+or+is%3Adigital+legal%3Ahistoricbrawl' \
|
|
|
|
'+or+legal%3Acommander+or+legal%3Abrawl%29'
|
2022-09-09 20:25:04 +00:00
|
|
|
# elif category == 'zombie':
|
2022-09-12 04:07:18 +00:00
|
|
|
# string_query += '-type%3Alegendary+type%3Azombie+-type%3Atoken+not%3Adfc'
|
2022-09-09 20:25:04 +00:00
|
|
|
# elif category == 'artifact':
|
2022-09-12 04:07:18 +00:00
|
|
|
# string_query += 't%3Aartifact+not%3Adatestamped+not%3Adfc&order=released&dir=asc&unique=prints&page='
|
2022-08-15 23:55:39 +00:00
|
|
|
# add category string query here
|
2022-09-12 00:52:17 +00:00
|
|
|
string_query += '+-%28set%3Asld+%28cn>%3D231+cn<%3D233+or+cn>%3D436+cn<%3D440+or+cn>%3D321+cn<%3D324+or' \
|
|
|
|
'+cn>%3D185+cn<%3D189+or+cn>%3D138+cn<%3D142+or+cn>%3D364+cn<%3D368+or+cn%3A669+or+cn%3A670%29%29+' \
|
2022-09-12 04:07:18 +00:00
|
|
|
'-%28set%3Asta+cn>%3D64+cn<%3D126%29+-set%3Acmb2+-set%3Acmb1+not%3Asplit'
|
|
|
|
string_query += '+-st%3Amemorabilia+-set%3Aplist+-name%3A%2F%5EA-%2F&order=released&dir=asc&unique=prints&page='
|
2022-08-15 23:55:39 +00:00
|
|
|
print(string_query)
|
|
|
|
return string_query
|
|
|
|
|
2022-09-09 22:54:14 +00:00
|
|
|
|
2022-08-15 23:55:39 +00:00
|
|
|
def generate_initial_special_query(category):
|
|
|
|
string_query = 'https://api.scryfall.com/cards/search?q='
|
|
|
|
if category == 'set':
|
|
|
|
return 'https://api.scryfall.com/sets'
|
2022-08-05 04:46:39 +00:00
|
|
|
elif category == 'basic':
|
|
|
|
string_query += 't%3Abasic&order=released&dir=asc&unique=prints&page='
|
2022-09-16 06:09:19 +00:00
|
|
|
elif category == 'watermark':
|
|
|
|
string_query += 'has%3Awatermark+-t%3Atoken+-st%3Amemorabilia+-set%3Aplist+-name%3A%2F%5EA-%2F&order=released&dir=asc&unique=prints&page='
|
2022-07-20 23:57:51 +00:00
|
|
|
# add category string query here
|
|
|
|
print(string_query)
|
|
|
|
return string_query
|
|
|
|
|
2022-09-12 00:52:17 +00:00
|
|
|
|
|
|
|
def generate_initial_artist_query():
|
2022-09-12 03:31:49 +00:00
|
|
|
string_query = 'https://api.scryfall.com/cards/search?q=' + artist_denylist + \
|
2022-09-16 03:47:50 +00:00
|
|
|
'-atag%3Auniverses-beyond+-art%3Aartist-signature+artists%3D1+-st%3Afunny+not%3Aextra+not%3Adigital+-st%3Atoken+-t%3Avanguard+-st%3Amemorabilia+-t%3Ascheme+-t%3Aplane+-t%3APhenomenon&unique=art&as=grid&order=artist&page='
|
2022-09-12 00:52:17 +00:00
|
|
|
print("artistList")
|
|
|
|
print(string_query)
|
|
|
|
return string_query
|
|
|
|
|
|
|
|
|
|
|
|
def generate_individual_artist_query(artists, artist_list):
|
2022-09-12 03:07:45 +00:00
|
|
|
string_query = 'https://api.scryfall.com/cards/search?q=%28'
|
2022-09-12 00:52:17 +00:00
|
|
|
for artist in artists:
|
|
|
|
artist_split = artist_list[artist][0].split()
|
2022-09-12 03:07:45 +00:00
|
|
|
string_query += 'a%3A“' + '+'.join(artist_split) + '”+or+'
|
2022-09-12 00:52:17 +00:00
|
|
|
string_query = string_query[:-4]
|
2022-09-15 23:35:50 +00:00
|
|
|
string_query += '%29+-set%3Aplist-art%3Aartist-signature+artists%3D1+-name%3A%2F%5EA-%2F&order=released&dir=asc&unique=prints&page='
|
2022-09-12 00:52:17 +00:00
|
|
|
return string_query
|
2022-09-11 12:42:49 +00:00
|
|
|
|
2022-07-20 23:57:51 +00:00
|
|
|
|
|
|
|
def fetch_and_write_all(category, query):
|
|
|
|
count = 1
|
|
|
|
will_repeat = True
|
2022-09-09 22:54:14 +00:00
|
|
|
all_cards = {'data': []}
|
2022-09-09 22:36:12 +00:00
|
|
|
art_names = dict()
|
2022-07-20 23:57:51 +00:00
|
|
|
while will_repeat:
|
2022-08-05 04:46:39 +00:00
|
|
|
response = fetch(query, count)
|
|
|
|
will_repeat = response['has_more']
|
2022-09-09 22:54:14 +00:00
|
|
|
count += 1
|
2022-09-13 03:25:18 +00:00
|
|
|
to_compact_write_form(all_cards, art_names, response)
|
2022-09-09 22:54:14 +00:00
|
|
|
|
2022-08-05 04:46:39 +00:00
|
|
|
with open('jsons/' + category + '.json', 'w') as f:
|
|
|
|
json.dump(all_cards, f)
|
2022-08-15 23:55:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
def fetch_and_write_all_special(category, query):
|
|
|
|
count = 1
|
|
|
|
will_repeat = True
|
2022-09-09 22:54:14 +00:00
|
|
|
all_cards = {'data': []}
|
2022-09-09 22:36:12 +00:00
|
|
|
art_names = dict()
|
2022-08-15 23:55:39 +00:00
|
|
|
while will_repeat:
|
|
|
|
if category == 'set':
|
|
|
|
response = fetch_special(query)
|
|
|
|
else:
|
|
|
|
response = fetch(query, count)
|
|
|
|
will_repeat = response['has_more']
|
2022-09-09 22:54:14 +00:00
|
|
|
count += 1
|
2022-09-13 03:25:18 +00:00
|
|
|
to_compact_write_form_special(
|
|
|
|
all_cards, art_names, response, category, {})
|
2022-09-09 22:54:14 +00:00
|
|
|
|
2022-08-15 23:55:39 +00:00
|
|
|
with open('jsons/' + category + '.json', 'w') as f:
|
|
|
|
json.dump(all_cards, f)
|
2022-07-20 23:57:51 +00:00
|
|
|
|
|
|
|
|
2022-09-12 00:52:17 +00:00
|
|
|
def fetch_and_write_all_artist():
|
|
|
|
all_cards = {'data': []}
|
|
|
|
will_repeat = True
|
|
|
|
count = 1
|
2022-09-15 23:35:50 +00:00
|
|
|
total_artists = 0
|
2022-09-12 00:52:17 +00:00
|
|
|
artists = json.load(open('jsons/artistList.json'))
|
|
|
|
artist_ids = list(artists.keys())
|
2022-09-12 03:07:45 +00:00
|
|
|
print(math.ceil(len(artist_ids)/37.0))
|
|
|
|
for i in range(math.ceil(len(artist_ids)/37.0)):
|
|
|
|
queried_artists_pre = artist_ids[i*37:min((i+1)*37, len(artist_ids))]
|
|
|
|
queried_artists = []
|
|
|
|
for j in range(len(queried_artists_pre)):
|
2022-09-16 02:01:00 +00:00
|
|
|
if artists[queried_artists_pre[j]][1] >= 50 or artists[queried_artists_pre[j]][0] in artist_allowlist:
|
2022-09-12 03:07:45 +00:00
|
|
|
queried_artists.append(queried_artists_pre[j])
|
2022-09-12 00:52:17 +00:00
|
|
|
print(queried_artists)
|
2022-09-12 03:07:45 +00:00
|
|
|
print(i)
|
|
|
|
if len(queried_artists) == 0:
|
|
|
|
continue
|
2022-09-12 00:52:17 +00:00
|
|
|
count = 1
|
|
|
|
will_repeat = True
|
|
|
|
art_names = dict()
|
|
|
|
query = generate_individual_artist_query(
|
|
|
|
queried_artists, artists)
|
|
|
|
print(query)
|
2022-09-15 23:35:50 +00:00
|
|
|
total_artists += len(queried_artists)
|
|
|
|
print(total_artists)
|
2022-09-12 00:52:17 +00:00
|
|
|
while will_repeat:
|
|
|
|
response = fetch(query, count)
|
|
|
|
will_repeat = response['has_more']
|
|
|
|
count += 1
|
2022-09-13 03:25:18 +00:00
|
|
|
to_compact_write_form_special(
|
|
|
|
all_cards, art_names, response, 'artist', artists)
|
|
|
|
print(len(art_names))
|
2022-09-12 00:52:17 +00:00
|
|
|
|
|
|
|
with open('jsons/artist.json', 'w') as f:
|
|
|
|
json.dump(all_cards, f)
|
|
|
|
|
|
|
|
|
|
|
|
def fetch_and_write_initial_artist_query():
|
|
|
|
prev_artist = "dummy_artist"
|
|
|
|
artists = {"dummy_artist": [1, 1]}
|
|
|
|
all_artists_query = generate_initial_artist_query()
|
|
|
|
will_repeat = True
|
|
|
|
count = 1
|
|
|
|
while will_repeat:
|
|
|
|
print("artist fetching: "+str(count))
|
|
|
|
response = fetch(all_artists_query, count)
|
|
|
|
will_repeat = response['has_more']
|
|
|
|
count += 1
|
|
|
|
prev_artist = write_to_artist_list(response, artists, prev_artist)
|
|
|
|
with open('jsons/artistList.json', 'w') as f:
|
|
|
|
json.dump(artists, f)
|
|
|
|
|
|
|
|
|
2022-08-05 04:46:39 +00:00
|
|
|
def fetch(query, count):
|
2022-07-20 23:57:51 +00:00
|
|
|
query += str(count)
|
|
|
|
response = requests.get(f"{query}").json()
|
|
|
|
time.sleep(0.1)
|
2022-08-05 04:46:39 +00:00
|
|
|
return response
|
2022-07-20 23:57:51 +00:00
|
|
|
|
2022-09-09 22:54:14 +00:00
|
|
|
|
2022-08-15 23:55:39 +00:00
|
|
|
def fetch_special(query):
|
|
|
|
response = requests.get(f"{query}").json()
|
|
|
|
time.sleep(0.1)
|
|
|
|
return response
|
|
|
|
|
2022-09-09 22:54:14 +00:00
|
|
|
|
2022-09-12 04:07:18 +00:00
|
|
|
def write_art(art_names, id, index, card):
|
2022-09-16 06:09:19 +00:00
|
|
|
if card['digital'] or card['set_type'] == 'promo' or card['promo'] or card['lang'] != 'en':
|
2022-09-09 22:36:12 +00:00
|
|
|
art_names[id] = index
|
|
|
|
else:
|
|
|
|
art_names[id] = -1
|
|
|
|
|
2022-07-20 23:57:51 +00:00
|
|
|
|
2022-09-13 03:25:18 +00:00
|
|
|
def to_compact_write_form(smallJson, art_names, response):
|
2022-09-09 22:54:14 +00:00
|
|
|
fieldsInCard = ['name', 'image_uris', 'flavor_name',
|
2022-09-16 03:28:56 +00:00
|
|
|
'reprint', 'frame_effects', 'digital', 'set_type', 'security_stamp']
|
2022-09-09 23:26:46 +00:00
|
|
|
data = smallJson['data']
|
2022-07-20 23:57:51 +00:00
|
|
|
# write all fields needed in card
|
|
|
|
for card in response['data']:
|
2022-09-13 03:25:18 +00:00
|
|
|
digital_holder = filter_card(card, art_names, data)
|
|
|
|
if digital_holder == False:
|
2022-09-09 01:04:08 +00:00
|
|
|
continue
|
2022-07-20 23:57:51 +00:00
|
|
|
write_card = dict()
|
2022-08-15 23:55:39 +00:00
|
|
|
for field in fieldsInCard:
|
2022-09-09 20:25:04 +00:00
|
|
|
# if field == 'name' and category == 'artifact':
|
|
|
|
# write_card['name'] = card['released_at'].split('-')[0]
|
2022-09-13 03:25:18 +00:00
|
|
|
if field == 'name' and 'card_faces' in card:
|
2022-08-15 23:55:39 +00:00
|
|
|
write_card['name'] = card['card_faces'][0]['name']
|
|
|
|
elif field == 'image_uris':
|
2022-09-09 20:25:04 +00:00
|
|
|
if 'card_faces' in card and 'image_uris' in card['card_faces'][0]:
|
2022-09-09 22:54:14 +00:00
|
|
|
write_card['image_uris'] = write_image_uris(
|
|
|
|
card['card_faces'][0]['image_uris'])
|
2022-09-09 20:25:04 +00:00
|
|
|
else:
|
2022-09-09 22:54:14 +00:00
|
|
|
write_card['image_uris'] = write_image_uris(
|
|
|
|
card['image_uris'])
|
2022-08-15 23:55:39 +00:00
|
|
|
elif field in card:
|
|
|
|
write_card[field] = card[field]
|
2022-09-09 22:54:14 +00:00
|
|
|
if digital_holder != -1:
|
|
|
|
data[digital_holder] = write_card
|
|
|
|
else:
|
|
|
|
data.append(write_card)
|
2022-08-15 23:55:39 +00:00
|
|
|
|
2022-09-09 22:54:14 +00:00
|
|
|
|
2022-09-13 03:25:18 +00:00
|
|
|
def to_compact_write_form_special(smallJson, art_names, response, category, artists):
|
2022-09-16 03:28:56 +00:00
|
|
|
fieldsInBasic = ['image_uris', 'set',
|
|
|
|
'set_type', 'digital', 'security_stamp']
|
|
|
|
fieldsInArtist = ['image_uris', 'digital',
|
|
|
|
'set_type', 'artist_ids', 'security_stamp']
|
2022-09-16 06:09:19 +00:00
|
|
|
fieldsInWatermark = ['image_uris', 'watermark',
|
|
|
|
'set_type', 'digital', 'security_stamp', 'promo', 'set']
|
2022-09-09 23:26:46 +00:00
|
|
|
data = smallJson['data']
|
2022-08-15 23:55:39 +00:00
|
|
|
# write all fields needed in card
|
|
|
|
for card in response['data']:
|
2022-08-05 04:46:39 +00:00
|
|
|
if category == 'basic':
|
2022-08-15 23:55:39 +00:00
|
|
|
# do not repeat art
|
2022-09-13 03:25:18 +00:00
|
|
|
digital_holder = filter_card(card, art_names, data)
|
|
|
|
if digital_holder == False:
|
2022-08-15 23:55:39 +00:00
|
|
|
continue
|
2022-09-13 03:25:18 +00:00
|
|
|
write_card = dict()
|
2022-08-05 04:46:39 +00:00
|
|
|
for field in fieldsInBasic:
|
|
|
|
if field == 'image_uris':
|
2022-09-09 22:54:14 +00:00
|
|
|
write_card['image_uris'] = write_image_uris(
|
|
|
|
card['image_uris'])
|
2022-08-15 23:55:39 +00:00
|
|
|
elif field == 'set':
|
|
|
|
write_card['name'] = card['set']
|
2022-08-05 04:46:39 +00:00
|
|
|
elif field in card:
|
|
|
|
write_card[field] = card[field]
|
2022-09-09 22:54:14 +00:00
|
|
|
if digital_holder != -1:
|
|
|
|
data[digital_holder] = write_card
|
|
|
|
else:
|
|
|
|
data.append(write_card)
|
2022-09-13 03:25:18 +00:00
|
|
|
elif category == 'artist':
|
|
|
|
# do not repeat art
|
|
|
|
digital_holder = filter_card(card, art_names, data)
|
|
|
|
if digital_holder == False:
|
|
|
|
continue
|
|
|
|
write_card = dict()
|
|
|
|
for field in fieldsInArtist:
|
2022-09-16 06:09:19 +00:00
|
|
|
if field == 'artist_ids':
|
2022-09-13 03:25:18 +00:00
|
|
|
write_card['name'] = artists[card['artist_ids'][0]][0]
|
|
|
|
elif field == 'image_uris':
|
|
|
|
if 'card_faces' in card and 'image_uris' in card['card_faces'][0]:
|
|
|
|
write_card['image_uris'] = write_image_uris(
|
|
|
|
card['card_faces'][0]['image_uris'])
|
|
|
|
else:
|
|
|
|
write_card['image_uris'] = write_image_uris(
|
|
|
|
card['image_uris'])
|
|
|
|
elif field in card:
|
|
|
|
write_card[field] = card[field]
|
|
|
|
if digital_holder != -1:
|
|
|
|
data[digital_holder] = write_card
|
|
|
|
else:
|
|
|
|
data.append(write_card)
|
2022-09-16 06:09:19 +00:00
|
|
|
elif category == 'watermark':
|
|
|
|
# do not repeat art
|
|
|
|
digital_holder = filter_card(card, art_names, data)
|
|
|
|
if digital_holder == False:
|
|
|
|
continue
|
|
|
|
if 'card_faces' in card and 'watermark' in card['card_faces'][0] and 'watermark' in card['card_faces'][1] and card['card_faces'][1]['watermark'] != card['card_faces'][0]['watermark']:
|
|
|
|
# print(card['name'])
|
|
|
|
continue
|
|
|
|
write_card = dict()
|
|
|
|
for field in fieldsInWatermark:
|
|
|
|
if field == 'watermark':
|
|
|
|
# print(card['name'])
|
|
|
|
if 'card_faces' in card:
|
|
|
|
write_card['name'] = card['card_faces'][0]['watermark'].capitalize(
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
write_card['name'] = card['watermark'].capitalize()
|
|
|
|
elif field == 'image_uris':
|
|
|
|
if 'card_faces' in card and 'image_uris' in card['card_faces'][0]:
|
|
|
|
write_card['image_uris'] = write_image_uris(
|
|
|
|
card['card_faces'][0]['image_uris'])
|
|
|
|
else:
|
|
|
|
write_card['image_uris'] = write_image_uris(
|
|
|
|
card['image_uris'])
|
|
|
|
elif field in card:
|
|
|
|
write_card[field] = card[field]
|
|
|
|
if digital_holder != -1:
|
|
|
|
data[digital_holder] = write_card
|
|
|
|
else:
|
|
|
|
data.append(write_card)
|
2022-08-05 04:46:39 +00:00
|
|
|
else:
|
2022-09-13 03:25:18 +00:00
|
|
|
# print(card['name'])
|
|
|
|
# print(category)
|
2022-08-15 23:55:39 +00:00
|
|
|
if card['set_type'] != 'token':
|
2022-09-09 22:54:14 +00:00
|
|
|
smallJson[card['code']] = [card['name'], card['icon_svg_uri']]
|
|
|
|
|
2022-07-20 23:57:51 +00:00
|
|
|
|
2022-09-13 03:25:18 +00:00
|
|
|
def filter_card(card, art_names, data):
|
|
|
|
# do not include racist cards
|
|
|
|
if 'content_warning' in card and card['content_warning'] == True:
|
|
|
|
return False
|
|
|
|
# do not repeat art
|
|
|
|
digital_holder = -1
|
|
|
|
if 'card_faces' in card:
|
|
|
|
card_face = card['card_faces'][0]
|
|
|
|
if 'illustration_id' not in card_face or card_face['illustration_id'] in art_names and (art_names[card_face['illustration_id']] < 0 or card['digital']):
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
ind = len(data)
|
|
|
|
if (card_face['illustration_id'] in art_names):
|
|
|
|
digital_holder = art_names[card['illustration_id']]
|
|
|
|
ind = -1
|
|
|
|
write_art(
|
|
|
|
art_names, card_face['illustration_id'], ind, card)
|
|
|
|
elif 'illustration_id' not in card or card['illustration_id'] in art_names and (art_names[card['illustration_id']] < 0 or card['digital']):
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
ind = len(data)
|
|
|
|
if (card['illustration_id'] in art_names):
|
|
|
|
digital_holder = art_names[card['illustration_id']]
|
|
|
|
ind = -1
|
|
|
|
write_art(art_names, card['illustration_id'], ind, card)
|
|
|
|
return digital_holder
|
|
|
|
|
|
|
|
|
2022-09-12 00:52:17 +00:00
|
|
|
def write_to_artist_list(response, artists, prev_artist):
|
|
|
|
for card in response['data']:
|
|
|
|
artist_id = card['artist_ids'][0]
|
|
|
|
artist = card['artist']
|
|
|
|
if artist_id not in artists:
|
2022-09-16 04:32:03 +00:00
|
|
|
if artists[prev_artist][1] < 10:
|
2022-09-12 00:52:17 +00:00
|
|
|
del artists[prev_artist]
|
|
|
|
prev_artist = artist_id
|
|
|
|
print(artist)
|
|
|
|
artists[artist_id] = [artist, 1]
|
|
|
|
else:
|
|
|
|
if len(artist) < len(artists[artist_id][0]):
|
|
|
|
artists[artist_id][0] = artist
|
|
|
|
artists[artist_id][1] += 1
|
|
|
|
return prev_artist
|
|
|
|
|
|
|
|
|
2022-07-20 23:57:51 +00:00
|
|
|
# only write images needed
|
|
|
|
def write_image_uris(card_image_uris):
|
|
|
|
image_uris = dict()
|
|
|
|
if 'normal' in card_image_uris:
|
|
|
|
image_uris['normal'] = card_image_uris['normal']
|
|
|
|
elif 'large' in card_image_uris:
|
|
|
|
image_uris['normal'] = card_image_uris['large']
|
|
|
|
elif 'small' in card_image_uris:
|
|
|
|
image_uris['normal'] = card_image_uris['small']
|
|
|
|
if card_image_uris:
|
|
|
|
image_uris['art_crop'] = card_image_uris['art_crop']
|
|
|
|
return image_uris
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2022-09-16 06:09:19 +00:00
|
|
|
# for category in allCategories:
|
|
|
|
# print(category)
|
|
|
|
# fetch_and_write_all(category, generate_initial_query(category))
|
2022-09-16 06:44:11 +00:00
|
|
|
# for category in specialCategories:
|
|
|
|
# print(category)
|
|
|
|
# fetch_and_write_all_special(
|
|
|
|
# category, generate_initial_special_query(category))
|
2022-09-12 03:07:45 +00:00
|
|
|
# uncomment this once in a while, but it's expensive to run
|
2022-09-16 03:47:50 +00:00
|
|
|
# fetch_and_write_initial_artist_query()
|
2022-09-16 06:44:11 +00:00
|
|
|
fetch_and_write_all_artist()
|