Fixes for SVT

Store SVT videos in db and only parse the feed when needed

Also: dont show latest videos for SVT
main
Micke Nordin 3 years ago
parent 8fe7f45f62
commit e97330ca09
Signed by: micke
GPG Key ID: 014B273D614BE877

@ -27,6 +27,7 @@ class SVT(Channel):
self.m_thr = threading.Thread(target=self.parse_feed, self.m_thr = threading.Thread(target=self.parse_feed,
args=[svt_id], args=[svt_id],
kwargs={}) kwargs={})
self.refresh()
def refresh(self) -> None: def refresh(self) -> None:
self.m_thr.start() self.m_thr.start()
@ -36,8 +37,6 @@ class SVT(Channel):
def parse_feed(self, *args, **kwargs) -> None: def parse_feed(self, *args, **kwargs) -> None:
svt_id = args[0] svt_id = args[0]
feed = feedparser.parse(self.get_feed())
entries = feed['entries']
self.m_items: list[Item] = list() self.m_items: list[Item] = list()
resolved_link = str() resolved_link = str()
description = str() description = str()
@ -48,10 +47,12 @@ class SVT(Channel):
video_id = str() video_id = str()
if svt_id == 'feed': if svt_id == 'feed':
feed = feedparser.parse(self.get_feed())
entries = feed['entries']
for entry in entries: for entry in entries:
video_id = hash_string(entry['id']) video_id = hash_string(entry['id'])
if video_exists(video_id, svt_id): if video_exists(video_id, svt_id):
pass break
for link in entry['links']: for link in entry['links']:
if str(link['type']).startswith('image/'): if str(link['type']).startswith('image/'):
thumbnail_link = str(link['href']) thumbnail_link = str(link['href'])
@ -74,6 +75,11 @@ class SVT(Channel):
if resolved_link and thumbnail_link: if resolved_link and thumbnail_link:
thumbnail = make_bitmap_from_url( thumbnail = make_bitmap_from_url(
thumbnail_link, wx.Size(self.m_screen_width, 150)) 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: else:
chan_dict = resolve_svt_channel(svt_id) chan_dict = resolve_svt_channel(svt_id)
@ -87,8 +93,6 @@ class SVT(Channel):
item = Item(description, resolved_link, self.m_provider_name, item = Item(description, resolved_link, self.m_provider_name,
published_parsed, thumbnail, title) published_parsed, thumbnail, title)
self.m_items.append(item) self.m_items.append(item)
add_video(video_id, svt_id, self.m_provider_name, description,
resolved_link, published_parsed, thumbnail, title, 0)
def resolve_link(svt_id: str) -> str: def resolve_link(svt_id: str) -> str:

@ -16,7 +16,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: if len(self.m_channels) > 0 and not providerid == 'SVT':
self.m_thr = threading.Thread(target=self.make_latest, self.m_thr = threading.Thread(target=self.make_latest,
args=(), args=(),
kwargs={}) kwargs={})

Loading…
Cancel
Save