def cargar_datos(shows): import imdb from series.models import Serie, Genero from utils.slugify import slugify api = imdb.IMDb() for show in shows: try: try: datos = api.get_movie( show["imdb"].movieID ) except: continue s = Serie() s.titulo = datos.get("title") print s.titulo s.slug = slugify(s.titulo) try: s.productora = (",".join( [c.get("name") for c in datos.get("production companies")] ))[:255] except: pass s.director = datos.get("director") s.estado = show["status"] try: s.plot = datos.get("plot")[0] except: pass s.mini_plot = datos.get("plot outline") s.year = datos.get("year") s.cover = datos.get("full-size cover url") s.min_cover = datos.get("cover url") s.rating = datos.get("rating") if not s.rating: s.rating = 0 s.imdb_id = show["imdb"].movieID s.save() for g in datos.get("genres"): gen, created = Genero.objects.get_or_create(nombre=g) s.genero.add( gen ) except: pass