Skip to content

Commit 4d3dcc0

Browse files
committed
Merge branch '1886-cant-get-show-listing-on-tv4'
2 parents 1117e63 + dd2794b commit 4d3dcc0

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ _None_
1111
[B]Channel related[/B]
1212
* Fixed: NPO Luister radio stations.
1313
* Fixed: SRF Channel.
14+
* Fixed: TV4 Play Channel needs POSTs now (Fixes #1886).

channels/channel.se/tv4se/chn_tv4se.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ def __create_item(lang_id: int, url: str, json: Optional[dict] = None):
197197
tvshow_url, tvshow_data = self.__get_api_query(
198198
"MediaIndex",
199199
{"input": {"letterFilters": list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
200-
"limit": self.__max_page_size, "offset": 0}},
201-
use_get=True)
200+
"limit": self.__max_page_size, "offset": 0}})
202201
items.append(__create_item(LanguageHelper.TvShows, tvshow_url, tvshow_data))
203202

204203
recent_url, recent_data = self.__get_api_query("Panel", {"panelId": "2K0BCBpDDfhpW1NRLY0jET", "limit": self.__max_page_size, "offset": 0})
@@ -242,11 +241,11 @@ def fetch_mainlist_pages(self, data: str) -> Tuple[str, List[MediaItem]]:
242241

243242
tvshow_url, tvshow_data = self.__get_api_query(
244243
"MediaIndex",
245-
{"input": {
246-
"letterFilters": list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
247-
"limit": self.__max_page_size, "offset": next_offset}
248-
},
249-
use_get=True
244+
{
245+
"input": {
246+
"letterFilters": list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
247+
"limit": self.__max_page_size, "offset": next_offset}
248+
}
250249
)
251250
new_data = UriHandler.open(
252251
tvshow_url, additional_headers=self.httpHeaders, json=tvshow_data,
@@ -400,7 +399,6 @@ def create_api_series(self, result_set: dict) -> Optional[MediaItem]:
400399
url, data = self.__get_api_query(
401400
operation="ContentDetailsPage",
402401
variables={"mediaId": series_id, "panelsInput": {"offset": 0, "limit": 20}},
403-
use_get=True
404402
)
405403
title = result_set["title"]
406404
if not title:
@@ -432,7 +430,6 @@ def create_api_page(self, result_set: dict) -> Optional[MediaItem]:
432430
url, data = self.__get_api_query(
433431
operation="Page",
434432
variables={"pageId": page_id, "input": {"limit": self.__max_page_size, "offset": 0}},
435-
use_get=False
436433
)
437434

438435
item = FolderItem(title, url, content_type=contenttype.TVSHOWS, media_type=mediatype.FOLDER)
@@ -458,8 +455,7 @@ def create_api_live_panel(self, result_set: dict) -> Optional[MediaItem]:
458455
title = result_set["title"]
459456
url, data = self.__get_api_query(
460457
operation="LivePanel",
461-
variables={"panelId": panel_id, "limit": self.__max_page_size, "offset": 0},
462-
use_get=True
458+
variables={"panelId": panel_id, "limit": self.__max_page_size, "offset": 0}
463459
)
464460

465461
item = FolderItem(title, url, content_type=contenttype.VIDEOS)
@@ -928,7 +924,7 @@ def __get_api_query(self, operation: str, variables: dict, use_get: bool = False
928924
return base_url, data
929925

930926
# For GETs (but the request URLs become to long!)
931-
url = f"{base_url}query={HtmlEntityHelper.url_encode(query)}&variables={HtmlEntityHelper.url_encode(json.dumps(variables))}"
927+
url = f"{base_url}query={HtmlEntityHelper.url_encode(query)}&variables={HtmlEntityHelper.url_encode(json.dumps(variables))}"
932928
return url, None
933929

934930
def __update_dash_video(self, item, stream_info):

tests/channel_tests/test_chn_tv4se.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def test_main_list(self):
1919
self.assertGreaterEqual(len(items), 5, "Incorrect number of items in mainlist")
2020

2121
def test_program_list(self):
22-
url = "https://client-gateway.tv4.a2d.tv/graphql?operationName=MediaIndex&query=query%20MediaIndex%28%24input%3A%20MediaIndexListInput%21%2C%20%24genres%3A%20%5BString%21%5D%29%20%7B%20mediaIndex%28genres%3A%20%24genres%29%20%7B%20overview%20%7B%20letterIndex%20%7B%20letter%20totalCount%20%7D%20%7D%20contentList%28input%3A%20%24input%29%20%7B%20__typename%20items%20%7B%20...%20on%20MediaIndexSeriesItem%20%7B%20__typename%20letter%20series%20%7B%20...SeriesFieldsLight%20__typename%20%7D%20%7D%20...%20on%20MediaIndexMovieItem%20%7B%20__typename%20letter%20movie%20%7B%20...MovieFieldsLight%20__typename%20%7D%20%7D%20%7D%20pageInfo%20%7B%20hasMoreForLastLetter%20totalCount%20lastLetter%20nextPageOffset%20%7D%20%7D%20%7D%20%7D%20fragment%20SeriesFieldsLight%20on%20Series%20%7B%20id%20slug%20title%20genres%20mediaClassification%20numberOfAvailableSeasons%20label%20%7B%20...LabelFields%20%7D%20images%20%7B%20cover2x3%20%7B%20...ImageFieldsFull%20%7D%20main16x9Annotated%20%7B%20...ImageFieldsLight%20%7D%20%7D%20parentalRating%20%7B%20...ParentalRatingFields%20%7D%20trailers%20%7B%20mp4%20webm%20%7D%20upsell%20%7B%20tierId%20%7D%20%7D%20fragment%20MovieFieldsLight%20on%20Movie%20%7B%20id%20slug%20title%20genres%20productionYear%20isLiveContent%20productionCountries%20%7B%20name%20%7D%20parentalRating%20%7B%20...ParentalRatingFields%20%7D%20liveEventEnd%20%7B%20isoString%20%7D%20label%20%7B%20...LabelFields%20%7D%20images%20%7B%20cover2x3%20%7B%20...ImageFieldsFull%20%7D%20main16x9Annotated%20%7B%20...ImageFieldsLight%20%7D%20%7D%20playableUntil%20%7B%20readableDistance%28type%3A%20DAYS_LEFT%29%20%7D%20playableFrom%20%7B%20isoString%20humanDateTime%20readableDate%20%7D%20trailers%20%7B%20mp4%20webm%20%7D%20upsell%20%7B%20tierId%20%7D%20%7D%20fragment%20LabelFields%20on%20Label%20%7B%20id%20airtime%20announcement%20recurringBroadcast%20%7D%20fragment%20ImageFieldsFull%20on%20Image%20%7B%20sourceEncoded%20meta%20%7B%20muteBgColor%20%7B%20hex%20%7D%20%7D%20%7D%20fragment%20ImageFieldsLight%20on%20Image%20%7B%20sourceEncoded%20isFallback%20%7D%20fragment%20ParentalRatingFields%20on%20ParentalRating%20%7B%20finland%20%7B%20ageRestriction%20reason%20%7D%20sweden%20%7B%20ageRecommendation%20suitableForChildren%20%7D%20%7D&variables=%7B%22input%22%3A%20%7B%22letterFilters%22%3A%20%5B%22A%22%2C%20%22B%22%2C%20%22C%22%2C%20%22D%22%2C%20%22E%22%2C%20%22F%22%2C%20%22G%22%2C%20%22H%22%2C%20%22I%22%2C%20%22J%22%2C%20%22K%22%2C%20%22L%22%2C%20%22M%22%2C%20%22N%22%2C%20%22O%22%2C%20%22P%22%2C%20%22Q%22%2C%20%22R%22%2C%20%22S%22%2C%20%22T%22%2C%20%22U%22%2C%20%22V%22%2C%20%22W%22%2C%20%22X%22%2C%20%22Y%22%2C%20%22Z%22%5D%2C%20%22limit%22%3A%20100%2C%20%22offset%22%3A%200%7D%7D"
23-
self._test_folder_url(url, expected_results=1000)
22+
url = "https://client-gateway.tv4.a2d.tv/graphql?operationName=MediaIndex&"
23+
data = {"operationName": "MediaIndex", "query": "query MediaIndex($input: MediaIndexListInput!, $genres: [String!]) { mediaIndex(genres: $genres) { overview { letterIndex { letter totalCount } } contentList(input: $input) { __typename items { ... on MediaIndexSeriesItem { __typename letter series { ...SeriesFieldsLight __typename } } ... on MediaIndexMovieItem { __typename letter movie { ...MovieFieldsLight __typename } } } pageInfo { hasMoreForLastLetter totalCount lastLetter nextPageOffset } } } } fragment SeriesFieldsLight on Series { id slug title genres mediaClassification numberOfAvailableSeasons label { ...LabelFields } images { cover2x3 { ...ImageFieldsFull } main16x9Annotated { ...ImageFieldsLight } } parentalRating { ...ParentalRatingFields } trailers { mp4 webm } upsell { tierId } } fragment MovieFieldsLight on Movie { id slug title genres productionYear isLiveContent productionCountries { name } parentalRating { ...ParentalRatingFields } liveEventEnd { isoString } label { ...LabelFields } images { cover2x3 { ...ImageFieldsFull } main16x9Annotated { ...ImageFieldsLight } } playableUntil { readableDistance(type: DAYS_LEFT) } playableFrom { isoString humanDateTime readableDate } trailers { mp4 webm } upsell { tierId } } fragment LabelFields on Label { id airtime announcement recurringBroadcast } fragment ImageFieldsFull on Image { sourceEncoded meta { muteBgColor { hex } } } fragment ImageFieldsLight on Image { sourceEncoded isFallback } fragment ParentalRatingFields on ParentalRating { finland { ageRestriction reason } sweden { ageRecommendation suitableForChildren } }", "variables": {"input": {"letterFilters": ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"], "limit": 100, "offset": 0}}}
24+
self._test_folder_url(url, expected_results=1000, json=data)
2425

2526
def test_lastest_news(self):
2627
url = "https://client-gateway.tv4.a2d.tv/graphql?operationName=Panel&"

0 commit comments

Comments
 (0)