diff --git a/src/dialogs.py b/src/dialogs.py index 90982c5..70834e0 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -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')