def __create_thumbnail(self, episode, file_path): time = '00:00:01.000' video_manager.create_episode_thumbnail(episode, file_path, time) thumbnail_path = '{0}/thumbnails/{1}.png'.format(str(episode.bangumi_id), episode.episode_no) thumbnail_file_path = '{0}/{1}'.format(self.base_path, thumbnail_path) color = get_dominant_color(thumbnail_file_path) width, height = get_dimension(thumbnail_file_path) episode.thumbnail_image = Image(file_path=thumbnail_path, dominant_color=color, width=width, height=height) episode.thumbnail_color = color
def update_thumbnail(self, episode_id, time): try: session = SessionManager.Session() episode = session.query(Episode).\ filter(Episode.delete_mark == None).\ filter(Episode.id == episode_id).one() if episode.status != Episode.STATUS_DOWNLOADED: raise ClientError('Episode not downloaded', 412) torrent_file = session.query(TorrentFile).filter(TorrentFile.episode_id == episode_id).all()[0] video_manager.create_episode_thumbnail(episode, torrent_file.file_path, time) return json_resp({'msg': 'ok'}) except NoResultFound: raise ClientError(ClientError.NOT_FOUND, 404) finally: SessionManager.Session.remove()
def create_thumbnail(episode, file_path): time = '00:00:01.000' video_manager.create_episode_thumbnail(episode, file_path, time)