def saveVideo(session, movie, video_type_id): #处理rating和runtime if not movie['rating']: movie['rating'] = '0' rating = re.search('\d+(\.?\d?)*', movie['rating']).group(0) video = Video(name=movie['title'].decode('unicode-escape'), rating=float(rating), location=movie['location'].decode('unicode-escape'), orig_id=int(movie['orig_id']), video_type_id=video_type_id, platform=movie['platform'].decode('unicode-escape')) session.add(video) return video
def saveVideo(session, movie, video_type_id): #处理rating和runtime if not movie['rating']: movie['rating'] = '0' rating = re.search('\d+(\.?\d?)*', movie['rating']).group(0) if not movie['year'] or not movie['year'].isdigit(): movie['year'] = 0 video = Video(name=movie['title'].decode('unicode-escape'), rating=float(rating), year=int(movie['year']), location=movie['location'].decode('unicode-escape'), orig_id=int(movie['orig_id']), video_type_id=video_type_id, is_closed=int(movie['closed'])) session.add(video) return video
def saveMovie(session, movie): #处理rating和runtime if not movie['rating']: movie['rating'] = '0' rating = re.search('\d+(\.?\d?)*', movie['rating']).group(0) if not movie['runtime']: movie['runtime'] = '000' if not movie['year']: movie['year'] = 0 video = Video(name=movie['title'].decode('unicode-escape'), rating=float(rating), director=movie['director'].decode('unicode-escape'), runtime=int(movie['runtime'].decode('unicode-escape')[:-2]), year=int(movie['year']), location=movie['location'].decode('unicode-escape'), lang=movie['lang'].decode('unicode-escape'), orig_id=int(movie['orig_id']), video_type_id=1) session.add(video) return video