def create_title(): uid = request.args.get('uid') title_type = request.args.get('title_type') if uid.isnumeric(): if title_type == "movie" or title_type == "tv": prefix = title_type[0:2] else: return {} elif uid[2:].isnumeric(): prefix = uid[0:2] uid = uid[2:] if prefix == "mo": title_type = "movie" elif prefix == "tv": title_type = "tv" else: return {} title = find_title(prefix + uid) if title and 'children_known' in title: return title title_data = get_titles_data([{'uid': uid, "title_type": title_type}]) t = Title(title_data[0]['uid'], title_data[0]['title'], title_data[0]['released'], title_data[0]['title_type']) actors_added = t.add_cast(title_data[0]['cast']) actors = get_actors_data(actors_added) for actor in actors: a = Actor(actor['uid'], actor['name']) a.add_titles(actor['titles']) return redirect(url_for('find_title', uid=title_data[0]['uid']))
def create_actor(): uid = request.args.get('uid') uid = uid if uid.isnumeric() else uid[2:] if not uid.isnumeric(): return {} actor = find_actor("na" + uid) if actor and 'children_known' in actor: return actor actor_data = get_actors_data([{'uid': uid}]) a = Actor(actor_data[0]['uid'], actor_data[0]['name']) titles_added = a.add_titles(actor_data[0]['titles']) casts = get_titles_data(titles_added) for cast in casts: t = Title(cast['uid'], cast['title'], cast['released'], cast['title_type']) t.add_cast(cast['cast']) return redirect(url_for('find_actor', uid=actor_data[0]['uid']))