From 985781640264e4b99dab67eaf3509f7607c8cf21 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Sun, 10 Jul 2022 15:07:07 +0200 Subject: [PATCH] Create cache dir --- scripts/cast | 6 +++++- src/Channel/SVT/__init__.py | 12 +++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/cast b/scripts/cast index dab67bd..726f516 100755 --- a/scripts/cast +++ b/scripts/cast @@ -2,6 +2,7 @@ import sys import threading import time +import os from typing import Callable import pychromecast @@ -13,7 +14,7 @@ from vlc import Instance from Channel import SVT from ChannelProvider import ChannelProvider from Utils import (get_all_svt_categories, make_bitmap_from_file, - make_sized_button) + make_sized_button, BASEPATH) WIDTH = int(720 / 2) HEIGHT = int(1440 / 2) @@ -43,6 +44,9 @@ class Cast(wx.Frame): url = kw['url'] del kw['url'] super().__init__(*args, **kw) + if not os.path.isdir(BASEPATH): + os.mkdir(BASEPATH) + self.m_selected_chromecast = None self.SetSizeHints(WIDTH, HEIGHT, maxW=WIDTH) self.m_style = self.GetWindowStyle() diff --git a/src/Channel/SVT/__init__.py b/src/Channel/SVT/__init__.py index 5422845..8d3c120 100644 --- a/src/Channel/SVT/__init__.py +++ b/src/Channel/SVT/__init__.py @@ -106,8 +106,14 @@ class SVT(Channel): entries = get_svt_category(self.m_id) for entry in entries: elem = entry["item"] + imgformat = "wide" + if not "wide" in elem["images"].keys(): + if "cleanWide" in elem["images"].keys(): + imgformat = "cleanWide" + else: + continue url = elem["urls"]["svtplay"] - video_id = hash_string(url.split('/')[1]) + video_id = hash_string(url) svt_id = elem["videoSvtId"] resolved_link = self.resolve_link(svt_id) if not resolved_link: @@ -116,8 +122,8 @@ class SVT(Channel): description = str(entry["description"]) published_parsed = datetime.now() thumbnail_link = get_svt_thumb_from_id_changed( - elem['images']["wide"]["id"], - elem['images']["wide"]["changed"], + elem['images'][imgformat]["id"], + elem['images'][imgformat]["changed"], size=self.m_screen_width) thumbnail = make_bitmap_from_url( thumbnail_link, wx.Size(int(self.m_screen_width), 150), video_id)