Add import from NewPipe-button
This commit is contained in:
parent
16aac8d1f9
commit
ea9379be7f
2 changed files with 28 additions and 0 deletions
|
@ -49,3 +49,6 @@ class ChannelProvider:
|
||||||
def prepend_channel(self, channel: Channel) -> int:
|
def prepend_channel(self, channel: Channel) -> int:
|
||||||
self.m_channels.insert(0, channel)
|
self.m_channels.insert(0, channel)
|
||||||
return len(self.m_channels)
|
return len(self.m_channels)
|
||||||
|
|
||||||
|
def set_channels(self, channels: list[Channel]) -> None:
|
||||||
|
self.m_channels = channels
|
||||||
|
|
25
src/main.py
25
src/main.py
|
@ -95,6 +95,25 @@ class Cast(wx.Frame):
|
||||||
|
|
||||||
return providers
|
return providers
|
||||||
|
|
||||||
|
def show_importer(self, _) -> None:
|
||||||
|
|
||||||
|
with wx.FileDialog(self, "Open Newpipe json file", wildcard="Json files (*.json)|*.json",
|
||||||
|
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as file_dialog:
|
||||||
|
|
||||||
|
if file_dialog.ShowModal() == wx.ID_CANCEL:
|
||||||
|
return # the user changed their mind
|
||||||
|
|
||||||
|
# Proceed loading the file chosen by the user
|
||||||
|
subfile = file_dialog.GetPath()
|
||||||
|
channels = list()
|
||||||
|
if os.path.isfile(subfile):
|
||||||
|
import_from_newpipe(subfile)
|
||||||
|
subscriptions = get_subscriptions()
|
||||||
|
for channel in subscriptions:
|
||||||
|
channels.append(YouTube.YouTube(channel[0], channel[1]))
|
||||||
|
self.m_providers[1].set_channels(channels)
|
||||||
|
self.show_channel_list(None,self.m_selected_provider_index)
|
||||||
|
|
||||||
def show_provider_list(self, _) -> None:
|
def show_provider_list(self, _) -> None:
|
||||||
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)
|
||||||
|
@ -130,6 +149,12 @@ class Cast(wx.Frame):
|
||||||
#self.m_sizer.AddSpacer(SPACER_HEIGHT * 4)
|
#self.m_sizer.AddSpacer(SPACER_HEIGHT * 4)
|
||||||
bck_callback = lambda event: self.show_provider_list(event)
|
bck_callback = lambda event: self.show_provider_list(event)
|
||||||
self.add_back_button(bck_callback)
|
self.add_back_button(bck_callback)
|
||||||
|
|
||||||
|
if self.m_selected_provider.get_name() == "YouTube":
|
||||||
|
importbtn = wx.Button(self.m_panel, -1, label="Import from NewPipe",size=(WIDTH, BTN_HEIGHT))
|
||||||
|
importbtn.Bind(wx.EVT_BUTTON, lambda event: self.show_importer(event))
|
||||||
|
self.m_sizer.Add(importbtn)
|
||||||
|
|
||||||
channel_index = 0
|
channel_index = 0
|
||||||
|
|
||||||
for channel in self.m_selected_provider.get_channels():
|
for channel in self.m_selected_provider.get_channels():
|
||||||
|
|
Loading…
Add table
Reference in a new issue