Add back provider splash

main
Micke Nordin 2 years ago
parent 0528d20f1d
commit 165c98175a
Signed by: micke
GPG Key ID: 0DA0A7A5708FE257

@ -61,6 +61,8 @@ class Cast(wx.Frame):
self.m_providers: list[ChannelProvider] = self.get_providers()
if url:
self.show_player(None, url, 0)
elif len(self.m_providers) > 1:
self.show_provider_list(None)
else:
self.show_channel_list(None, 0)
@ -155,19 +157,34 @@ class Cast(wx.Frame):
def get_providers(self) -> list[ChannelProvider]:
providers = list()
channels: list = list()
ids = [
"feed", "ch-svt1", "ch-svt2", "ch-svt24", "ch-barnkanalen",
"ch-kunskapskanalen", "allprograms"
]
chandict = {
"kanaler": {
"channels": [
"ch-svt1", "ch-svt2", "ch-svt24", "ch-barnkanalen",
"ch-kunskapskanalen"
],
"displayname":
"SVT Channel Streams"
}
}
chandict["program"] = {
"channels": ["feed", "allprograms"],
"displayname": "SVT Shows - Latest and A-Ö"
}
categories = list()
for category in get_all_svt_categories():
ids.append(category['id'])
for id in ids:
channels.append(SVT.SVT(id))
svt = ChannelProvider("SVT", channels=channels)
providers.append(svt)
categories.append(category['id'])
chandict["kategorier"] = {
"channels": categories,
"displayname": "SVT All Categories"
}
for provider in ["kanaler", "program", "kategorier"]:
channels = list()
for id in chandict[provider]["channels"]:
channels.append(SVT.SVT(id))
svt = ChannelProvider(chandict[provider]["displayname"], channels=channels)
providers.append(svt)
return providers
@ -176,12 +193,17 @@ class Cast(wx.Frame):
self.m_selected_provider = self.m_providers[provider_index]
self.m_sizer.Clear(delete_windows=True)
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
closebtn = wx.Button(self.m_panel,
-1,
label="Close",
size=(WIDTH, BTN_HEIGHT))
closebtn.Bind(wx.EVT_BUTTON, lambda event: self.Destroy())
self.m_sizer.Add(closebtn, 0, wx.ALL, 1)
if len(self.m_providers) > 1:
back_callback = lambda event: self.show_provider_list(
event)
self.add_back_button(back_callback)
else:
closebtn = wx.Button(self.m_panel,
-1,
label="Close",
size=(WIDTH, BTN_HEIGHT))
closebtn.Bind(wx.EVT_BUTTON, lambda event: self.Destroy())
self.m_sizer.Add(closebtn, 0, wx.ALL, 1)
channel_index = 0
@ -200,6 +222,30 @@ class Cast(wx.Frame):
self.m_sizer.Fit(self)
self.m_sizer.Layout()
def show_provider_list(self, _) -> None:
self.m_sizer.Clear(delete_windows=True)
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
closebtn = wx.Button(self.m_panel,
-1,
label="Close",
size=(WIDTH, BTN_HEIGHT))
closebtn.Bind(wx.EVT_BUTTON, lambda event: self.Destroy())
self.m_sizer.Add(closebtn, 0, wx.ALL, 1)
provider_index = 0
for provider in self.m_providers:
bitmap = provider.get_logo_as_bitmap()
callback = lambda event, pindex=provider_index: self.show_channel_list(
event, pindex)
btn_sizer: wx.BoxSizer = make_sized_button(self.m_panel, bitmap,
provider.get_name(),
callback)
self.m_sizer.Add(btn_sizer, 0, wx.ALL, 1)
provider_index += 1
self.m_panel.SetupScrolling(rate_y=SCROLL_RATE, scrollToTop=True)
self.m_panel.SetSizer(self.m_sizer)
self.m_sizer.Fit(self)
self.m_sizer.Layout()
def show_video_list(self, _, channel_index) -> None:
self.SetWindowStyle(self.m_style)
self.m_selected_channel = self.m_selected_provider.get_channel_by_index(
@ -209,11 +255,11 @@ class Cast(wx.Frame):
back_callback = lambda event: self.show_channel_list(
event, self.m_selected_provider_index)
self.add_back_button(back_callback)
if self.m_selected_provider.get_name(
) == 'SVT' and self.m_selected_channel.get_id() not in [
"ch-svt1", "ch-svt2", "ch-svt24", "ch-barnkanalen",
"ch-kunskapskanalen"
]:
if self.m_selected_provider.get_name().startswith(
'SVT') and self.m_selected_channel.get_id() not in [
"ch-svt1", "ch-svt2", "ch-svt24", "ch-barnkanalen",
"ch-kunskapskanalen"
]:
def refresh_callback(event):
self.m_selected_channel.refresh()

@ -15,7 +15,7 @@ class ChannelProvider:
self.m_id = providerid
self.m_logo: wx.Bitmap = get_default_logo(providerid)
self.m_channels: list[Channel] = channels
if len(self.m_channels) > 0 and not providerid == 'SVT':
if len(self.m_channels) > 0 and not providerid.startswith('SVT'):
self.m_thr = threading.Thread(target=self.make_latest,
args=(),
kwargs={})

@ -129,7 +129,7 @@ def get_all_svt_programs() -> list:
def get_default_logo(providerid: str = 'default',
path: str = '/usr/share/cast') -> wx.Bitmap:
if providerid == 'SVT':
if providerid.startswith('SVT'):
return wx.Bitmap('{}/assets/SVT.png'.format(path))
else:
return wx.Bitmap('{}/assets/Default.png'.format(path))

Loading…
Cancel
Save