Compare commits
No commits in common. "60ab02b4bac56084bdccfcd242926d68b137ba76" and "e794b336ee3a9ffe745d3c80a74f2db35241a8cc" have entirely different histories.
60ab02b4ba
...
e794b336ee
2 changed files with 13 additions and 42 deletions
43
scripts/cast
43
scripts/cast
|
@ -2,7 +2,6 @@
|
|||
import sys
|
||||
import threading
|
||||
import time
|
||||
import os
|
||||
from typing import Callable
|
||||
|
||||
import pychromecast
|
||||
|
@ -14,7 +13,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, BASEPATH)
|
||||
make_sized_button)
|
||||
|
||||
WIDTH = int(720 / 2)
|
||||
HEIGHT = int(1440 / 2)
|
||||
|
@ -44,9 +43,6 @@ 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()
|
||||
|
@ -54,6 +50,7 @@ class Cast(wx.Frame):
|
|||
args=(),
|
||||
kwargs={})
|
||||
self.m_vlc = Instance()
|
||||
self.m_vlc_medialist = self.m_vlc.media_list_new()
|
||||
self.m_vlc_listplayer = self.m_vlc.media_list_player_new()
|
||||
self.m_chromecast_thr.start()
|
||||
self.m_sizer: wx.Sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
@ -122,7 +119,8 @@ class Cast(wx.Frame):
|
|||
inner_sizer.Add(stop_button, FLAGS)
|
||||
inner_sizer.Add(back_button, FLAGS)
|
||||
|
||||
if self.has_usable_chromecasts():
|
||||
if not self.m_chromecast_thr.is_alive(
|
||||
) and not self.m_selected_chromecast:
|
||||
btm = make_bitmap_from_file(
|
||||
'{}/assets/Cast.png'.format(self.asset_path), wx.Size(24, 24))
|
||||
cast_button = wx.BitmapButton(self.m_panel,
|
||||
|
@ -190,19 +188,6 @@ class Cast(wx.Frame):
|
|||
|
||||
return providers
|
||||
|
||||
def has_usable_chromecasts(self) -> bool:
|
||||
if self.m_chromecast_thr.is_alive():
|
||||
return False
|
||||
if self.m_selected_chromecast:
|
||||
return False
|
||||
result = False
|
||||
for cast in self.m_chromecasts:
|
||||
if cast.cast_type != 'audio':
|
||||
result = True
|
||||
break
|
||||
return result
|
||||
|
||||
|
||||
def show_channel_list(self, _, provider_index) -> None:
|
||||
self.m_selected_provider_index = provider_index
|
||||
self.m_selected_provider = self.m_providers[provider_index]
|
||||
|
@ -358,10 +343,8 @@ class Cast(wx.Frame):
|
|||
:param uri str: the link to the video stream
|
||||
"""
|
||||
media = self.m_vlc.media_new(uri)
|
||||
medialist = self.m_vlc.media_list_new()
|
||||
|
||||
medialist.add_media(media)
|
||||
self.m_vlc_listplayer.set_media_list(medialist)
|
||||
self.m_vlc_medialist.add_media(media)
|
||||
self.m_vlc_listplayer.set_media_list(self.m_vlc_medialist)
|
||||
|
||||
self.m_sizer.Clear(delete_windows=True)
|
||||
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
@ -387,17 +370,11 @@ class Cast(wx.Frame):
|
|||
self.m_sizer.Add(cancel_btn)
|
||||
|
||||
for cast in self.m_chromecasts:
|
||||
if cast.cast_type == 'audio':
|
||||
continue
|
||||
friendly_name = "Unknown Chromecast"
|
||||
try:
|
||||
friendly_name = cast.device.friendly_name
|
||||
except AttributeError:
|
||||
friendly_name = cast.cast_info.friendly_name
|
||||
friendly_name = cast.device.friendly_name
|
||||
btn = wx.Button(self.m_panel,
|
||||
id=-1,
|
||||
label=friendly_name,
|
||||
size=(WIDTH, BTN_HEIGHT))
|
||||
id=-1,
|
||||
label=friendly_name,
|
||||
size=(WIDTH, BTN_HEIGHT))
|
||||
btn.Bind(
|
||||
wx.EVT_BUTTON,
|
||||
lambda event, chromecast=cast, muri=uri, cindex=channel_index:
|
||||
|
|
|
@ -106,14 +106,8 @@ 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)
|
||||
video_id = hash_string(url.split('/')[1])
|
||||
svt_id = elem["videoSvtId"]
|
||||
resolved_link = self.resolve_link(svt_id)
|
||||
if not resolved_link:
|
||||
|
@ -122,8 +116,8 @@ class SVT(Channel):
|
|||
description = str(entry["description"])
|
||||
published_parsed = datetime.now()
|
||||
thumbnail_link = get_svt_thumb_from_id_changed(
|
||||
elem['images'][imgformat]["id"],
|
||||
elem['images'][imgformat]["changed"],
|
||||
elem['images']["wide"]["id"],
|
||||
elem['images']["wide"]["changed"],
|
||||
size=self.m_screen_width)
|
||||
thumbnail = make_bitmap_from_url(
|
||||
thumbnail_link, wx.Size(int(self.m_screen_width), 150), video_id)
|
||||
|
|
Loading…
Add table
Reference in a new issue