Last active
October 22, 2016 18:06
-
-
Save Fedjmike/da0cb4296a7462055ba2c9b014858b7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from model import Model, NotFound | |
from tools import get_wikipedia_summary | |
def safe_print(*args): | |
try: | |
print(*args) | |
except: | |
pass | |
def fix_artist(artist_id): | |
title = model.get_link(artist_id, "wikipedia") | |
if not title: | |
safe_print("No wp:", model.get_artist(artist_id).name) | |
return | |
if model.get_link(artist_id, "image"): | |
pass #return | |
try: | |
safe_print(model.get_artist(artist_id).name) | |
description = get_wikipedia_summary(title) | |
model.set_description(artist_id, description) | |
except (KeyError, TypeError): | |
pass | |
with Model() as model: | |
for (artist_id,) in model.query("select id from artists"): | |
fix_artist(artist_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment