From e97330ca0948f926e29e1faf6de27df7bcc896c6 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Sat, 8 Jan 2022 21:31:11 +0100 Subject: [PATCH] Fixes for SVT Store SVT videos in db and only parse the feed when needed Also: dont show latest videos for SVT --- src/Channel/SVT/__init__.py | 22 +++++++++++++--------- src/ChannelProvider/__init__.py | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Channel/SVT/__init__.py b/src/Channel/SVT/__init__.py index 7dd2996..081ccab 100644 --- a/src/Channel/SVT/__init__.py +++ b/src/Channel/SVT/__init__.py @@ -27,6 +27,7 @@ class SVT(Channel): self.m_thr = threading.Thread(target=self.parse_feed, args=[svt_id], kwargs={}) + self.refresh() def refresh(self) -> None: self.m_thr.start() @@ -36,8 +37,6 @@ class SVT(Channel): def parse_feed(self, *args, **kwargs) -> None: svt_id = args[0] - feed = feedparser.parse(self.get_feed()) - entries = feed['entries'] self.m_items: list[Item] = list() resolved_link = str() description = str() @@ -48,10 +47,12 @@ class SVT(Channel): video_id = str() if svt_id == 'feed': + feed = feedparser.parse(self.get_feed()) + entries = feed['entries'] for entry in entries: video_id = hash_string(entry['id']) if video_exists(video_id, svt_id): - pass + break for link in entry['links']: if str(link['type']).startswith('image/'): thumbnail_link = str(link['href']) @@ -74,6 +75,11 @@ class SVT(Channel): if resolved_link and thumbnail_link: thumbnail = make_bitmap_from_url( thumbnail_link, wx.Size(self.m_screen_width, 150)) + item = Item(description, resolved_link, self.m_provider_name, + published_parsed, thumbnail, title) + self.m_items.append(item) + add_video(video_id, svt_id, self.m_provider_name, description, + resolved_link, published_parsed, thumbnail, title, 0) else: chan_dict = resolve_svt_channel(svt_id) @@ -83,12 +89,10 @@ class SVT(Channel): description = "Live channel stream" thumbnail = chan_dict['thumbnail'] - if resolved_link: - item = Item(description, resolved_link, self.m_provider_name, - published_parsed, thumbnail, title) - self.m_items.append(item) - add_video(video_id, svt_id, self.m_provider_name, description, - resolved_link, published_parsed, thumbnail, title, 0) + if resolved_link: + item = Item(description, resolved_link, self.m_provider_name, + published_parsed, thumbnail, title) + self.m_items.append(item) def resolve_link(svt_id: str) -> str: diff --git a/src/ChannelProvider/__init__.py b/src/ChannelProvider/__init__.py index e17567c..6eeebea 100644 --- a/src/ChannelProvider/__init__.py +++ b/src/ChannelProvider/__init__.py @@ -16,7 +16,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: + if len(self.m_channels) > 0 and not providerid == 'SVT': self.m_thr = threading.Thread(target=self.make_latest, args=(), kwargs={})