def update_summary_details(self, tvdb_series): '''Update a part of the attributes based on tvdb object (summary obtained through TheTVDB.get_matching_shows())''' self.name = sane_text(tvdb_series.name, length=200) self.tvdb_id = tvdb_series.id self.language = sane_text(tvdb_series.language, length=200) self.overview = sane_text(tvdb_series.overview, length=1000) self.first_aired = tvdb_series.first_aired self.imdb_id = sane_text(tvdb_series.imdb_id, length=50) self.banner_url = sane_text(tvdb_series.banner_url, length=200)
def update_extended_details(self, tvdb_series): '''Update a part of the attributes based on tvdb object (all details not obtained through TheTVDB.get_matching_shows())''' self.rating = tvdb_series.rating self.airing_status = sane_text(tvdb_series.status, length=50) self.poster_url = sane_text(tvdb_series.poster_url, length=200) self.fanart_url = sane_text(tvdb_series.fanart_url, length=200) self.tvcom_id = tvdb_series.tvcom_id self.zap2it_id = sane_text(tvdb_series.zap2it_id, length=200) self.tvdb_last_updated = tvdb_series.last_updated
def update_from_torrent(self, torrent): '''Update status by copying attribute from another torrent Does not update the status or last_status_change.''' log.debug("Updating torrent %s from torrent %s", self, torrent) self.has_metadata = torrent.has_metadata self.name = sane_text(torrent.name, length=200) self.progress = torrent.progress self.download_speed = sane_text(torrent.download_speed, length=20) self.upload_speed = sane_text(torrent.upload_speed, length=20) self.eta = torrent.eta self.active_time = sane_text(torrent.active_time, length=20) self.seeds = torrent.seeds self.peers = torrent.peers self.file_list = sane_text(torrent.file_list) self.save()
def find_video(self, episode): """Locates the video object of an episode within the package""" video = Video() # If the torrent is a single file, that's the one we want if os.path.isfile(self.full_path): if self.path: video.original_path = sane_text(os.path.join(self.torrent.name, self.path), length=490) else: video.original_path = sane_text(self.torrent.name, length=490) # If the torrent is a directory, look inside elif os.path.isdir(self.full_path): # First, extract files from archives in this directory to be able to find those files too self.extract_archives() # Get all video files video_filename_list = self.get_video_list() if len(video_filename_list) == 0: return Video.objects.get_not_found_video() # Select the biggest video max_filename = None max_size = 0 for video_filename in video_filename_list: video_size = os.stat(os.path.join(self.full_path, video_filename)).st_size if video_size > max_size: max_filename = video_filename max_size = video_size # Check if there was any video at all if max_filename is not None: video.original_path = sane_text(os.path.join(self.torrent.name, self.path, max_filename), 490) else: video = Video.objects.get_not_found_video() else: video = Video.objects.get_not_found_video() # Save video.save() return video
def update_details(self, tvdb_episode): '''Update attributes based on a tvdb object''' self.tvdb_id = tvdb_episode.id self.name = sane_text(tvdb_episode.name, length=200) self.overview = sane_text(tvdb_episode.overview, length=1000) self.director = sane_text(tvdb_episode.director, length=255) self.guest_stars = sane_text(tvdb_episode.guest_stars, length=255) self.language = sane_text(tvdb_episode.language, length=50) self.rating = tvdb_episode.rating self.writer = sane_text(tvdb_episode.writer, length=255) self.first_aired = tvdb_episode.first_aired self.image_url = sane_text(tvdb_episode.image, length=200) self.imdb_id = sane_text(tvdb_episode.imdb_id, length=50) self.tvdb_last_updated = tvdb_episode.last_updated