|
|
|
@ -68,8 +68,13 @@ def add_video(video_id: str,
|
|
|
|
|
|
|
|
|
|
con.commit()
|
|
|
|
|
|
|
|
|
|
def get_svt_thumb_from_id_changed(id: str, changed: str, size: str = "480") -> str:
|
|
|
|
|
return "https://www.svtstatic.se/image/custom/{}/{}/{}".format(size, id, changed)
|
|
|
|
|
|
|
|
|
|
def get_svt_thumb_from_id_changed(id: str,
|
|
|
|
|
changed: str,
|
|
|
|
|
size: str = "480") -> str:
|
|
|
|
|
return "https://www.svtstatic.se/image/custom/{}/{}/{}".format(
|
|
|
|
|
size, id, changed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_all_svt_categories() -> list:
|
|
|
|
|
categories: list = list()
|
|
|
|
@ -81,6 +86,7 @@ def get_all_svt_categories() -> list:
|
|
|
|
|
break
|
|
|
|
|
return categories
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_svt_category(category: str) -> list:
|
|
|
|
|
url = 'https://www.svtplay.se/kategori/{}?tab=all'.format(category)
|
|
|
|
|
data = get_svt_data(url)
|
|
|
|
@ -94,15 +100,18 @@ def get_svt_category(category: str) -> list:
|
|
|
|
|
break
|
|
|
|
|
return programs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_svt_data(url: str) -> list:
|
|
|
|
|
result: list = list()
|
|
|
|
|
res = requests.get(url)
|
|
|
|
|
soup = BeautifulSoup(res.text, features="lxml")
|
|
|
|
|
data = json.loads(soup.find(id="__NEXT_DATA__").string)["props"]["urqlState"]
|
|
|
|
|
data = json.loads(
|
|
|
|
|
soup.find(id="__NEXT_DATA__").string)["props"]["urqlState"]
|
|
|
|
|
for key in data.keys():
|
|
|
|
|
result.append(json.loads(data[key]["data"]))
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_all_svt_programs() -> list:
|
|
|
|
|
url = 'https://www.svtplay.se/program'
|
|
|
|
|
data = get_svt_data(url)
|
|
|
|
@ -352,7 +361,14 @@ def resolve_svt_channel(svt_id: str, path: str = '/usr/share/cast') -> dict:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for category in get_all_svt_categories():
|
|
|
|
|
channels[category['id']] = {"name": category["name"], "thumbnail": make_bitmap_from_url(get_svt_thumb_from_id_changed(category['image']['id'], category['image']['changed']))}
|
|
|
|
|
channels[category['id']] = {
|
|
|
|
|
"name":
|
|
|
|
|
category["name"],
|
|
|
|
|
"thumbnail":
|
|
|
|
|
make_bitmap_from_url(
|
|
|
|
|
get_svt_thumb_from_id_changed(category['image']['id'],
|
|
|
|
|
category['image']['changed']))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return channels[svt_id]
|
|
|
|
|
|
|
|
|
|