Fixed YouTube integration
This commit is contained in:
		
							parent
							
								
									bb7a8b659a
								
							
						
					
					
						commit
						da97a7c6ee
					
				| @ -331,11 +331,11 @@ def youtube_caption_response(self, dialog, task, video_url, caption_drop_down): | ||||
|         yt = YouTube(video_url) | ||||
|         text = "{}\n{}\n{}\n\n".format(yt.title, yt.author, yt.watch_url) | ||||
|         selected_caption = caption_drop_down.get_selected_item().get_string() | ||||
|         for event in yt.captions[selected_caption.split('(')[1][:-1]].json_captions['events']: | ||||
|         for event in yt.captions[selected_caption.split('(')[-1][:-1]].json_captions['events']: | ||||
|             text += "{}\n".format(event['segs'][0]['utf8'].replace('\n', '\\n')) | ||||
|         if not os.path.exists(os.path.join(self.cache_dir, 'tmp/youtube')): | ||||
|             os.makedirs(os.path.join(self.cache_dir, 'tmp/youtube')) | ||||
|         file_path = os.path.join(os.path.join(self.cache_dir, 'tmp/youtube'), f'{yt.title} ({selected_caption.split(" | ")[0]})') | ||||
|         file_path = os.path.join(os.path.join(self.cache_dir, 'tmp/youtube'), f'{yt.title} ({selected_caption.split(" (")[0]})') | ||||
|         with open(file_path, 'w+', encoding="utf-8") as f: | ||||
|             f.write(text) | ||||
|         self.attach_file(file_path, 'youtube') | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user