You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.2 KiB
65 lines
2.2 KiB
#!/usr/bin/env python3
|
|
import io
|
|
|
|
import requests
|
|
import wx
|
|
|
|
|
|
def get_default_log_url(providerid: str = 'default') -> str:
|
|
if providerid == 'SVT':
|
|
return 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Logotyp_SVT_Play.png/480px-Logotyp_SVT_Play.jpg'
|
|
if providerid == 'YouTube':
|
|
return 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Youtube.png/480px-Youtube.jpg'
|
|
|
|
else:
|
|
return 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/Cartoon_Hand_Playing_Multiple_Online_Videos.svg/480px-Cartoon_Hand_Playing_Multiple_Online_Videos.svg.jpg'
|
|
|
|
|
|
def make_bitmap_from_url(logo_url: str = get_default_log_url()) -> wx.Bitmap:
|
|
res = requests.get(logo_url)
|
|
content = res.content
|
|
content_bytes = io.BytesIO(content)
|
|
logo = wx.Image(content_bytes, type=wx.BITMAP_TYPE_ANY, index=-1)
|
|
return wx.Bitmap(logo)
|
|
|
|
|
|
def resolve_svt_channel(svt_id: str) -> dict:
|
|
channels = {
|
|
"ch-barnkanalen": {
|
|
"name":
|
|
"Barnkanalen",
|
|
"thumbnail_url":
|
|
"https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/SVT_Barnkanalen_logo_2008%E2%80%932012.svg/480px-SVT_Barnkanalen_logo_2008%E2%80%932012.svg.jpg"
|
|
},
|
|
"ch-svt1": {
|
|
"name":
|
|
"SVT 1",
|
|
"thumbnail_url":
|
|
"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/SVT1_logo_2012.svg/480px-SVT1_logo_2012.svg.jpg"
|
|
},
|
|
"ch-svt2": {
|
|
"name":
|
|
"SVT 2",
|
|
"thumbnail_url":
|
|
"https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/SVT2_logo_2012.svg/480px-SVT2_logo_2012.svg.jpg"
|
|
},
|
|
"ch-svt24": {
|
|
"name":
|
|
"SVT 24",
|
|
"thumbnail_url":
|
|
"https://upload.wikimedia.org/wikipedia/commons/thumb/8/8f/SVT24_logo.svg/480px-SVT24_logo.svg.jpg"
|
|
},
|
|
"kunskapskanalen": {
|
|
"name":
|
|
"Kunskapskanalen",
|
|
"thumbnail_url":
|
|
"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b9/Kunskapskanalen_logo.png/480px-Kunskapskanalen_logo.jpg"
|
|
},
|
|
"feed": {
|
|
"name": "Senaste program",
|
|
"thumbnail_url": get_default_log_url('SVT')
|
|
},
|
|
}
|
|
|
|
return channels[svt_id]
|