Skip to content

Commit

Permalink
Added: Latest News for TV4 Play.
Browse files Browse the repository at this point in the history
  • Loading branch information
basrieter committed Oct 28, 2023
1 parent 09a0ffd commit ea35dbc
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion channels/channel.se/tv4se/chn_tv4se.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def list_main_content(self, data: str) -> Tuple[str, List[MediaItem]]:

def __create_item(lang_id: int, url: str):
name = LanguageHelper.get_localized_string(lang_id)
item = MediaItem(name, url)
item = FolderItem(name, url, content_type=contenttype.VIDEOS)
item.dontGroup = True
return item

Expand All @@ -262,6 +262,12 @@ def __create_item(lang_id: int, url: str):
{"panelId": "3QnNaigt4Szgkyz8yMU9oF", "limit": self.__max_page_size, "offset": 0}
)
items.append(__create_item(LanguageHelper.Popular, popular_url))

latest_news_url = self.__get_api_url(
"Panel", "3ef650feea500555e560903fee7fc06f8276d046ea880c5540282a5341b65985",
{"panelId": "5Rqb0w0SN16A6YHt5Mx8BU", "limit": self.__max_page_size, "offset": 0}
)
items.append(__create_item(LanguageHelper.LatestNews, latest_news_url))
return data, items

def fetch_mainlist_pages(self, data: str) -> Tuple[str, List[MediaItem]]:
Expand Down Expand Up @@ -338,6 +344,11 @@ def create_api_typed_item(self, result_set):
elif api_type == "MediaIndexSeriesItem":
item = self.create_api_typed_item(result_set["series"])

elif api_type == "Clip":
item = self.create_api_clip(result_set)
elif api_type == "ClipsPanelItem":
item = self.create_api_typed_item(result_set["clip"])

elif api_type == "Episode":
item = self.create_api_episode(result_set)

Expand Down Expand Up @@ -373,6 +384,24 @@ def create_api_movie(self, result_set: dict) -> Optional[MediaItem]:
item = self.__update_base_typed_item(item, result_set)
return item

def create_api_clip(self, result_set: dict) -> Optional[MediaItem]:
clip_id = result_set["id"]
url = self.__get_video_url(clip_id)
title = result_set["title"]
if not title:
return None

item = MediaItem(title, url, media_type=mediatype.VIDEO)
item = self.__update_base_typed_item(item, result_set)
item.isPaid = not JsonHelper.get_from(
result_set, "clipVideo", "access", "hasAccess", fallback=True)
item.isLive = result_set.get("isLiveContent", False)

duration = JsonHelper.get_from(result_set, "clipVideo", "duration", "seconds", fallback=0)
if duration:
item.set_info_label(MediaItem.LabelDuration, duration)
return item

def create_api_episode(self, result_set: dict) -> Optional[MediaItem]:
video_id: str = result_set["id"]
url = self.__get_video_url(video_id)
Expand Down

0 comments on commit ea35dbc

Please sign in to comment.