|
|
@ -14,7 +14,6 @@ ChannelProvider = NewType('ChannelProvider', ChannelProvider)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Cast(wx.Frame):
|
|
|
|
class Cast(wx.Frame):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
"""__init__.
|
|
|
|
"""__init__.
|
|
|
|
:param args:
|
|
|
|
:param args:
|
|
|
@ -22,7 +21,7 @@ class Cast(wx.Frame):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
super().__init__(*args, **kw)
|
|
|
|
super().__init__(*args, **kw)
|
|
|
|
self.m_selected_chromecast = None
|
|
|
|
self.m_selected_chromecast = None
|
|
|
|
self.SetSizeHints(480,480,maxW=480)
|
|
|
|
self.SetSizeHints(480, 480, maxW=480)
|
|
|
|
self.m_index = 0
|
|
|
|
self.m_index = 0
|
|
|
|
self.m_chromecast_thr = threading.Thread(target=self.get_chromecasts,
|
|
|
|
self.m_chromecast_thr = threading.Thread(target=self.get_chromecasts,
|
|
|
|
args=(),
|
|
|
|
args=(),
|
|
|
@ -34,49 +33,90 @@ class Cast(wx.Frame):
|
|
|
|
self.m_control = None
|
|
|
|
self.m_control = None
|
|
|
|
self.m_panel.SetupScrolling()
|
|
|
|
self.m_panel.SetupScrolling()
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
self.m_channels: list[ChannelProvider] = [YouTube.YouTube('UCu6mSoMNzHQiBIOCkHUa2Aw')]#,SVT.SVT()]
|
|
|
|
self.m_providers: list[ChannelProvider] = [
|
|
|
|
self.show_list(None)
|
|
|
|
YouTube.YouTube('UCu6mSoMNzHQiBIOCkHUa2Aw'),
|
|
|
|
|
|
|
|
SVT.SVT()
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
self.m_selected_channel = None
|
|
|
|
|
|
|
|
self.show_splash(None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_chromecasts(self) -> None:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
[TODO:description]
|
|
|
|
|
|
|
|
|
|
|
|
def get_chromecasts(self):
|
|
|
|
:rtype None: [TODO:description]
|
|
|
|
|
|
|
|
"""
|
|
|
|
self.m_chromecasts, self.m_browser = pychromecast.get_chromecasts()
|
|
|
|
self.m_chromecasts, self.m_browser = pychromecast.get_chromecasts()
|
|
|
|
|
|
|
|
|
|
|
|
def show_list(self, _):
|
|
|
|
def show_splash(self, _) -> None:
|
|
|
|
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
|
|
|
|
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
|
|
|
|
channel_index = 0
|
|
|
|
|
|
|
|
for provider in self.m_providers:
|
|
|
|
|
|
|
|
bitmap = provider.get_logo_as_bitmap()
|
|
|
|
|
|
|
|
btn = wx.BitmapButton(self.m_panel,
|
|
|
|
|
|
|
|
id=channel_index,
|
|
|
|
|
|
|
|
bitmap=bitmap)
|
|
|
|
|
|
|
|
btn.Bind(wx.EVT_BUTTON,
|
|
|
|
|
|
|
|
lambda event, index=channel_index: self.show_list(
|
|
|
|
|
|
|
|
event, index))
|
|
|
|
|
|
|
|
self.m_sizer.Add(btn)
|
|
|
|
|
|
|
|
channel_index += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
|
|
|
|
self.m_sizer.Fit(self)
|
|
|
|
|
|
|
|
self.m_panel.Layout()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_list(self, _, index=0) -> None:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Shows a list of videos
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param _ [TODO:type]: [TODO:description]
|
|
|
|
|
|
|
|
:rtype None: [TODO:description]
|
|
|
|
|
|
|
|
"""
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
|
|
|
|
|
|
|
|
for channel in self.m_channels:
|
|
|
|
channel = self.m_providers[index]
|
|
|
|
if channel.wait():
|
|
|
|
if channel.wait():
|
|
|
|
with wx.BusyInfo("Please wait, working..."):
|
|
|
|
with wx.BusyInfo("Please wait, working..."):
|
|
|
|
index = 0
|
|
|
|
index = 0
|
|
|
|
while channel.wait():
|
|
|
|
while channel.wait():
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|
wx.GetApp().Yield()
|
|
|
|
wx.GetApp().Yield()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backbtn = wx.Button(self.m_panel, -1, label="Go back", size=(480, 40))
|
|
|
|
for item in channel.get_items():
|
|
|
|
backbtn.Bind(wx.EVT_BUTTON, lambda event: self.show_splash(event))
|
|
|
|
title = wx.StaticText(self.m_panel, -1)
|
|
|
|
self.m_sizer.Add(backbtn, wx.ALIGN_CENTER_VERTICAL)
|
|
|
|
title.SetLabelMarkup("<span weight='bold' >{}</span>".format(item['title']))
|
|
|
|
self.m_sizer.AddSpacer(10)
|
|
|
|
description = wx.StaticText(self.m_panel, -1,
|
|
|
|
for item in channel.get_items():
|
|
|
|
item['description'])
|
|
|
|
title = wx.StaticText(self.m_panel, -1)
|
|
|
|
|
|
|
|
title.SetLabelMarkup("<span weight='bold' >{}</span>".format(
|
|
|
|
description.Wrap(478)
|
|
|
|
item['title']))
|
|
|
|
bitmap = item['thumbnail']
|
|
|
|
description = wx.StaticText(self.m_panel, -1, item['description'])
|
|
|
|
btn = wx.BitmapButton(self.m_panel,
|
|
|
|
|
|
|
|
id=self.m_index,
|
|
|
|
description.Wrap(478)
|
|
|
|
bitmap=bitmap)
|
|
|
|
bitmap = item['thumbnail']
|
|
|
|
btn.Bind(wx.EVT_BUTTON,
|
|
|
|
btn = wx.BitmapButton(self.m_panel, id=self.m_index, bitmap=bitmap)
|
|
|
|
lambda event, link=item['link']: self.show_player(
|
|
|
|
btn.Bind(wx.EVT_BUTTON,
|
|
|
|
event, link))
|
|
|
|
lambda event, link=item['link'], provider_index=index:
|
|
|
|
self.m_sizer.Add(title)
|
|
|
|
self.show_player(event, link, provider_index))
|
|
|
|
self.m_sizer.Add(btn)
|
|
|
|
self.m_sizer.Add(title)
|
|
|
|
self.m_sizer.Add(description)
|
|
|
|
self.m_sizer.Add(btn)
|
|
|
|
self.m_sizer.AddSpacer(10)
|
|
|
|
self.m_sizer.Add(description)
|
|
|
|
self.m_index = self.m_index + 1
|
|
|
|
self.m_sizer.AddSpacer(10)
|
|
|
|
|
|
|
|
self.m_index = self.m_index + 1
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
self.m_sizer.Fit(self)
|
|
|
|
self.m_sizer.Fit(self)
|
|
|
|
self.m_panel.Layout()
|
|
|
|
self.m_panel.Layout()
|
|
|
|
|
|
|
|
|
|
|
|
def show_player(self, _, uri):
|
|
|
|
def show_player(self, _, uri, provider_index: int):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Show the video player
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param _ event: unused
|
|
|
|
|
|
|
|
:param uri str: the link to the video stream
|
|
|
|
|
|
|
|
"""
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
self.m_sizer = wx.GridBagSizer()
|
|
|
|
self.m_sizer = wx.GridBagSizer()
|
|
|
|
self.m_control = wx.media.MediaCtrl(
|
|
|
|
self.m_control = wx.media.MediaCtrl(
|
|
|
@ -89,7 +129,9 @@ class Cast(wx.Frame):
|
|
|
|
pause_button = wx.Button(self.m_panel, -1, "Pause")
|
|
|
|
pause_button = wx.Button(self.m_panel, -1, "Pause")
|
|
|
|
|
|
|
|
|
|
|
|
back_button = wx.Button(self.m_panel, -1, "Back")
|
|
|
|
back_button = wx.Button(self.m_panel, -1, "Back")
|
|
|
|
back_button.Bind(wx.EVT_BUTTON, self.show_list)
|
|
|
|
back_button.Bind(
|
|
|
|
|
|
|
|
wx.EVT_BUTTON,
|
|
|
|
|
|
|
|
lambda event, index=provider_index: self.show_list(event, index))
|
|
|
|
|
|
|
|
|
|
|
|
self.m_sizer.Add(self.m_control, (0, 0))
|
|
|
|
self.m_sizer.Add(self.m_control, (0, 0))
|
|
|
|
self.m_sizer.SetItemSpan(0, (0, 6))
|
|
|
|
self.m_sizer.SetItemSpan(0, (0, 6))
|
|
|
@ -97,7 +139,8 @@ class Cast(wx.Frame):
|
|
|
|
self.m_sizer.Add(pause_button, (1, 2))
|
|
|
|
self.m_sizer.Add(pause_button, (1, 2))
|
|
|
|
self.m_sizer.Add(back_button, (1, 3))
|
|
|
|
self.m_sizer.Add(back_button, (1, 3))
|
|
|
|
|
|
|
|
|
|
|
|
if not self.m_chromecast_thr.is_alive() and not self.m_selected_chromecast:
|
|
|
|
if not self.m_chromecast_thr.is_alive(
|
|
|
|
|
|
|
|
) and not self.m_selected_chromecast:
|
|
|
|
chromecast_button = wx.Button(self.m_panel, -1, "Cast")
|
|
|
|
chromecast_button = wx.Button(self.m_panel, -1, "Cast")
|
|
|
|
chromecast_button.Bind(
|
|
|
|
chromecast_button.Bind(
|
|
|
|
wx.EVT_BUTTON,
|
|
|
|
wx.EVT_BUTTON,
|
|
|
@ -127,7 +170,10 @@ class Cast(wx.Frame):
|
|
|
|
|
|
|
|
|
|
|
|
for cast in self.m_chromecasts:
|
|
|
|
for cast in self.m_chromecasts:
|
|
|
|
friendly_name = cast.cast_info.friendly_name
|
|
|
|
friendly_name = cast.cast_info.friendly_name
|
|
|
|
btn = wx.Button(self.m_panel, id=-1, label=friendly_name, size=(480,40))
|
|
|
|
btn = wx.Button(self.m_panel,
|
|
|
|
|
|
|
|
id=-1,
|
|
|
|
|
|
|
|
label=friendly_name,
|
|
|
|
|
|
|
|
size=(480, 40))
|
|
|
|
btn.Bind(wx.EVT_BUTTON,
|
|
|
|
btn.Bind(wx.EVT_BUTTON,
|
|
|
|
lambda event, chromecast=cast, muri=uri: self.
|
|
|
|
lambda event, chromecast=cast, muri=uri: self.
|
|
|
|
set_chromecast(event, chromecast, muri))
|
|
|
|
set_chromecast(event, chromecast, muri))
|
|
|
|