|
|
|
@ -14,7 +14,6 @@ ChannelProvider = NewType('ChannelProvider', ChannelProvider)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Cast(wx.Frame):
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
|
"""__init__.
|
|
|
|
|
:param args:
|
|
|
|
@ -34,17 +33,51 @@ class Cast(wx.Frame):
|
|
|
|
|
self.m_control = None
|
|
|
|
|
self.m_panel.SetupScrolling()
|
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
|
self.m_channels: list[ChannelProvider] = [YouTube.YouTube('UCu6mSoMNzHQiBIOCkHUa2Aw')]#,SVT.SVT()]
|
|
|
|
|
self.show_list(None)
|
|
|
|
|
self.m_providers: list[ChannelProvider] = [
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
for channel in self.m_channels:
|
|
|
|
|
:param _ [TODO:type]: [TODO:description]
|
|
|
|
|
:rtype None: [TODO:description]
|
|
|
|
|
"""
|
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
|
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
|
|
|
|
|
|
channel = self.m_providers[index]
|
|
|
|
|
if channel.wait():
|
|
|
|
|
with wx.BusyInfo("Please wait, working..."):
|
|
|
|
|
index = 0
|
|
|
|
@ -52,21 +85,22 @@ class Cast(wx.Frame):
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
wx.GetApp().Yield()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backbtn = wx.Button(self.m_panel, -1, label="Go back", size=(480, 40))
|
|
|
|
|
backbtn.Bind(wx.EVT_BUTTON, lambda event: self.show_splash(event))
|
|
|
|
|
self.m_sizer.Add(backbtn, wx.ALIGN_CENTER_VERTICAL)
|
|
|
|
|
self.m_sizer.AddSpacer(10)
|
|
|
|
|
for item in channel.get_items():
|
|
|
|
|
title = wx.StaticText(self.m_panel, -1)
|
|
|
|
|
title.SetLabelMarkup("<span weight='bold' >{}</span>".format(item['title']))
|
|
|
|
|
description = wx.StaticText(self.m_panel, -1,
|
|
|
|
|
item['description'])
|
|
|
|
|
title.SetLabelMarkup("<span weight='bold' >{}</span>".format(
|
|
|
|
|
item['title']))
|
|
|
|
|
description = wx.StaticText(self.m_panel, -1, item['description'])
|
|
|
|
|
|
|
|
|
|
description.Wrap(478)
|
|
|
|
|
bitmap = item['thumbnail']
|
|
|
|
|
btn = wx.BitmapButton(self.m_panel,
|
|
|
|
|
id=self.m_index,
|
|
|
|
|
bitmap=bitmap)
|
|
|
|
|
btn = wx.BitmapButton(self.m_panel, id=self.m_index, bitmap=bitmap)
|
|
|
|
|
btn.Bind(wx.EVT_BUTTON,
|
|
|
|
|
lambda event, link=item['link']: self.show_player(
|
|
|
|
|
event, link))
|
|
|
|
|
lambda event, link=item['link'], provider_index=index:
|
|
|
|
|
self.show_player(event, link, provider_index))
|
|
|
|
|
self.m_sizer.Add(title)
|
|
|
|
|
self.m_sizer.Add(btn)
|
|
|
|
|
self.m_sizer.Add(description)
|
|
|
|
@ -76,7 +110,13 @@ class Cast(wx.Frame):
|
|
|
|
|
self.m_sizer.Fit(self)
|
|
|
|
|
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 = wx.GridBagSizer()
|
|
|
|
|
self.m_control = wx.media.MediaCtrl(
|
|
|
|
@ -89,7 +129,9 @@ class Cast(wx.Frame):
|
|
|
|
|
pause_button = wx.Button(self.m_panel, -1, "Pause")
|
|
|
|
|
|
|
|
|
|
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.SetItemSpan(0, (0, 6))
|
|
|
|
@ -97,7 +139,8 @@ class Cast(wx.Frame):
|
|
|
|
|
self.m_sizer.Add(pause_button, (1, 2))
|
|
|
|
|
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.Bind(
|
|
|
|
|
wx.EVT_BUTTON,
|
|
|
|
@ -127,7 +170,10 @@ class Cast(wx.Frame):
|
|
|
|
|
|
|
|
|
|
for cast in self.m_chromecasts:
|
|
|
|
|
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,
|
|
|
|
|
lambda event, chromecast=cast, muri=uri: self.
|
|
|
|
|
set_chromecast(event, chromecast, muri))
|
|
|
|
|