During the Olympic Games there is a channel with official broadcast of the event and for Smart TV they have four livestreams to create the Mosaic Mode:
https://www.youtube.com/live/y6hH0cyJd3g
But I want to use these lives to create a Mosaic Mode on the computer, so I tried:
import tkinter as tk
import vlc
import pafy
class YouTubeMosaic:
def __init__(self, root):
self.root = root
self.root.title("YouTube Mosaic")
self.videos = []
self.instances = []
self.create_widgets()
def create_widgets(self):
self.entry_frame = tk.Frame(self.root)
self.entry_frame.pack(side=tk.TOP)
self.entries = []
for i in range(4):
entry = tk.Entry(self.entry_frame, width=50)
entry.pack(side=tk.LEFT)
self.entries.append(entry)
self.play_button = tk.Button(self.entry_frame, text="Play", command=self.play_videos)
self.play_button.pack(side=tk.LEFT)
self.video_frame = tk.Frame(self.root)
self.video_frame.pack(fill=tk.BOTH, expand=True)
self.video_frames = []
for i in range(2):
for j in range(2):
frame = tk.Frame(self.video_frame, width=400, height=300, bg='black')
frame.grid(row=i, column=j, padx=5, pady=5)
self.video_frames.append(frame)
def play_videos(self):
for i in range(4):
url = self.entries[i].get()
if url:
self.play_video(url, self.video_frames[i])
def play_video(self, url, frame):
video = pafy.new(url)
best = video.getbest()
play_url = best.url
instance = vlc.Instance()
player = instance.media_player_new()
media = instance.media_new(play_url)
media.get_mrl()
player.set_media(media)
player.set_hwnd(frame.winfo_id())
player.play()
self.videos.append(player)
self.instances.append(instance)
if __name__ == "__main__":
root = tk.Tk()
app = YouTubeMosaic(root)
root.mainloop()
I’ve tried everything I can imagine, I’ve followed all the instructions and ideas I could find to give a basis for the idea, but in the end, I always end up getting this same error that I don’t know how to solve:
ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagesyoutube_dlYoutubeDL.py", line 815, in wrapper
return func(self, *args, **kwargs)
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagesyoutube_dlYoutubeDL.py", line 836, in __extract_info
ie_result = ie.extract(url)
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagesyoutube_dlextractorcommon.py", line 534, in extract
ie_result = self._real_extract(url)
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagesyoutube_dlextractoryoutube.py", line 1794, in _real_extract
'uploader_id': self._search_regex(r'/(?:channel|user)/([^/?&#]+)', owner_profile_url, 'uploader id') if owner_profile_url else None,
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagesyoutube_dlextractorcommon.py", line 1012, in _search_regex
raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagespafybackend_youtube_dl.py", line 40, in _fetch_basic
self._ydl_info = ydl.extract_info(self.videoid, download=False)
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagesyoutube_dlYoutubeDL.py", line 808, in extract_info
return self.__extract_info(url, ie, download, extra_info, process)
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagesyoutube_dlYoutubeDL.py", line 824, in wrapper
self.report_error(compat_str(e), e.format_traceback())
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagesyoutube_dlYoutubeDL.py", line 628, in report_error
self.trouble(error_message, tb)
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagesyoutube_dlYoutubeDL.py", line 598, in trouble
raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libtkinter__init__.py", line 1921, in __call__
return self.func(*args)
File "c:UsersComputadorDesktopTestes VSCODEmosaico_youtube.py", line 40, in play_videos
self.play_video(url, self.video_frames[i])
File "c:UsersComputadorDesktopTestes VSCODEmosaico_youtube.py", line 43, in play_video
video = pafy.new(url)
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagespafypafy.py", line 124, in new
return Pafy(url, basic, gdata, size, callback, ydl_opts=ydl_opts)
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagespafybackend_youtube_dl.py", line 31, in __init__
super(YtdlPafy, self).__init__(*args, **kwargs)
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagespafybackend_shared.py", line 97, in __init__
self._fetch_basic()
File "C:UsersComputadorAppDataLocalProgramsPythonPython310libsite-packagespafybackend_youtube_dl.py", line 43, in _fetch_basic
raise IOError(str(e).replace('YouTube said', 'Youtube says'))
OSError: ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.