def search_subtitles(self): search = [] for video_file_details in self.moviefiles.itervalues(): video_file_details['sublanguageid'] = self.lang search.append(video_file_details) results = self._query_opensubs(search) subtitles = self.clean_results(results) for (hash, found_matches) in subtitles.iteritems(): subtitles[hash] = utils.multikeysort(found_matches, ['overlap', 'user_rank', '-rating', '-downcount'])[0] for (hash, filedetails) in self.moviefiles.iteritems(): if not self.stopping: if subtitles.get(hash): utils.communicator.updategui.emit('Saving subtitles for %s'%filedetails['file_name'], 'success') subtitle = \ self.download_subtitles([subtitles[hash]['subid' ]]) utils.communicator.downloaded_sub.emit() utils.save_subs(subtitle, filedetails['save_subs_to'], subtitles[hash]) else: utils.communicator.no_sub_found.emit(filedetails['file_name']) else: return
def update_que(self): self.tracks = multikeysort(self.tracks, ['-vote_rating', 'added']) self.updated = datetime.utcnow() super(Playlist, self).save()