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() self.m_providers: list[ChannelProvider] = self.get_providers()
if url: if url:
self.show_player(None, url, 0) self.show_player(None, url, 0)
elif len(self.m_providers) > 1:
self.show_provider_list(None)
else: else:
self.show_channel_list(None, 0) self.show_channel_list(None, 0)
@ -155,19 +157,34 @@ class Cast(wx.Frame):
def get_providers(self) -> list[ChannelProvider]: def get_providers(self) -> list[ChannelProvider]:
providers = list() providers = list()
channels: list = list() chandict = {
ids = [ "kanaler": {
"feed", "ch-svt1", "ch-svt2", "ch-svt24", "ch-barnkanalen", "channels": [
"ch-kunskapskanalen", "allprograms" "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(): for category in get_all_svt_categories():
ids.append(category['id']) categories.append(category['id'])
for id in ids: chandict["kategorier"] = {
channels.append(SVT.SVT(id)) "channels": categories,
svt = ChannelProvider("SVT", channels=channels) "displayname": "SVT All Categories"
}
providers.append(svt) 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 return providers
@ -176,12 +193,17 @@ class Cast(wx.Frame):
self.m_selected_provider = self.m_providers[provider_index] self.m_selected_provider = self.m_providers[provider_index]
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)
closebtn = wx.Button(self.m_panel, if len(self.m_providers) > 1:
-1, back_callback = lambda event: self.show_provider_list(
label="Close", event)
size=(WIDTH, BTN_HEIGHT)) self.add_back_button(back_callback)
closebtn.Bind(wx.EVT_BUTTON, lambda event: self.Destroy()) else:
self.m_sizer.Add(closebtn, 0, wx.ALL, 1) 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 channel_index = 0
@ -200,6 +222,30 @@ class Cast(wx.Frame):
self.m_sizer.Fit(self) self.m_sizer.Fit(self)
self.m_sizer.Layout() 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: def show_video_list(self, _, channel_index) -> None:
self.SetWindowStyle(self.m_style) self.SetWindowStyle(self.m_style)
self.m_selected_channel = self.m_selected_provider.get_channel_by_index( 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( back_callback = lambda event: self.show_channel_list(
event, self.m_selected_provider_index) event, self.m_selected_provider_index)
self.add_back_button(back_callback) self.add_back_button(back_callback)
if self.m_selected_provider.get_name( if self.m_selected_provider.get_name().startswith(
) == 'SVT' and self.m_selected_channel.get_id() not in [ 'SVT') and self.m_selected_channel.get_id() not in [
"ch-svt1", "ch-svt2", "ch-svt24", "ch-barnkanalen", "ch-svt1", "ch-svt2", "ch-svt24", "ch-barnkanalen",
"ch-kunskapskanalen" "ch-kunskapskanalen"
]: ]:
def refresh_callback(event): def refresh_callback(event):
self.m_selected_channel.refresh() self.m_selected_channel.refresh()

@ -15,7 +15,7 @@ class ChannelProvider:
self.m_id = providerid self.m_id = providerid
self.m_logo: wx.Bitmap = get_default_logo(providerid) self.m_logo: wx.Bitmap = get_default_logo(providerid)
self.m_channels: list[Channel] = channels 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, self.m_thr = threading.Thread(target=self.make_latest,
args=(), args=(),
kwargs={}) kwargs={})

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

Loading…
Cancel
Save