Fixed YouTube integration
This commit is contained in:
parent
9d740a7db9
commit
3ceb25ccc6
@ -7,6 +7,7 @@ import logging, requests, threading
|
||||
from pytube import YouTube
|
||||
from html2text import html2text
|
||||
from gi.repository import Adw, Gtk
|
||||
from .internal import cache_dir
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
# CLEAR CHAT | WORKS
|
||||
@ -337,9 +338,9 @@ def youtube_caption_response(self, dialog, task, video_url, caption_drop_down):
|
||||
selected_caption = caption_drop_down.get_selected_item().get_string()
|
||||
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]})')
|
||||
if not os.path.exists(os.path.join(cache_dir, 'tmp/youtube')):
|
||||
os.makedirs(os.path.join(cache_dir, 'tmp/youtube'))
|
||||
file_path = os.path.join(os.path.join(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')
|
||||
|
@ -718,6 +718,7 @@ Generate a title following these rules:
|
||||
def cb_text_received(self, clipboard, result):
|
||||
try:
|
||||
text = clipboard.read_text_finish(result)
|
||||
print(text)
|
||||
#Check if text is a Youtube URL
|
||||
youtube_regex = re.compile(
|
||||
r'(https?://)?(www\.)?(youtube|youtu|youtube-nocookie)\.(com|be)/'
|
||||
@ -871,7 +872,7 @@ Generate a title following these rules:
|
||||
for action_name, data in universal_actions.items():
|
||||
self.get_application().create_action(action_name, data[0], data[1] if len(data) > 1 else None)
|
||||
|
||||
self.message_text_view.connect("paste-clipboard", self.on_clipboard_paste)
|
||||
#self.message_text_view.connect("paste-clipboard", self.on_clipboard_paste)
|
||||
self.file_preview_remove_button.connect('clicked', lambda button : dialogs.remove_attached_file(self, button.get_name()))
|
||||
self.attachment_button.connect("clicked", lambda button, file_filter=self.file_filter_attachments: dialogs.attach_file(self, file_filter))
|
||||
self.create_model_name.get_delegate().connect("insert-text", lambda *_: self.check_alphanumeric(*_, ['-', '.', '_']))
|
||||
|
Loading…
x
Reference in New Issue
Block a user