mirror of
https://github.com/vinefeeder/TwinVine.git
synced 2026-07-15 18:10:04 +02:00
fix STV search
This commit is contained in:
@@ -14,6 +14,7 @@ from envied.core.search_result import SearchResult
|
|||||||
from envied.core.service import Service
|
from envied.core.service import Service
|
||||||
from envied.core.titles import Episode, Movie, Movies, Series
|
from envied.core.titles import Episode, Movie, Movies, Series
|
||||||
from envied.core.tracks import Chapter, Chapters, Tracks
|
from envied.core.tracks import Chapter, Chapters, Tracks
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
class STV(Service):
|
class STV(Service):
|
||||||
@@ -55,25 +56,25 @@ class STV(Service):
|
|||||||
self.base = self.config["endpoints"]["base"]
|
self.base = self.config["endpoints"]["base"]
|
||||||
|
|
||||||
def search(self) -> Generator[SearchResult, None, None]:
|
def search(self) -> Generator[SearchResult, None, None]:
|
||||||
data = {
|
|
||||||
"engine_key": "S1jgssBHdk8ZtMWngK_y",
|
search_term = self.title.replace(" ", "+")
|
||||||
"q": self.title,
|
r = self.session.get(self.config["endpoints"]["search"].format(search_term=search_term))
|
||||||
}
|
|
||||||
r = self.session.post(self.config["endpoints"]["search"], data=data)
|
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
results = r.json()["records"]["page"]
|
results = json.loads(r.text)["data"]
|
||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
label = result.get("category")
|
title = result['attributes']["title"]
|
||||||
if label and isinstance(label, list):
|
url = result['attributes']["permalink"]
|
||||||
label = result["category"][0]
|
synopsis = result['attributes']["long_description"]
|
||||||
|
|
||||||
|
label = result["attributes"]["subGenre"]
|
||||||
|
|
||||||
yield SearchResult(
|
yield SearchResult(
|
||||||
id_=result.get("url"),
|
id_= self.config["endpoints"]["prefix"].strip("/") + result["attributes"]["permalink"],
|
||||||
title=result.get("title"),
|
title=title,
|
||||||
description=result.get("body"),
|
description=synopsis,
|
||||||
label=label,
|
label=label,
|
||||||
url=result.get("url"),
|
url=url,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_titles(self) -> Union[Movies, Series]:
|
def get_titles(self) -> Union[Movies, Series]:
|
||||||
|
|||||||
@@ -17,4 +17,5 @@ headers:
|
|||||||
endpoints:
|
endpoints:
|
||||||
base: https://player.api.stv.tv/v1/
|
base: https://player.api.stv.tv/v1/
|
||||||
playback: https://edge.api.brightcove.com/playback/v1/accounts/{accounts}/videos/{id}
|
playback: https://edge.api.brightcove.com/playback/v1/accounts/{accounts}/videos/{id}
|
||||||
search: https://api.swiftype.com/api/v1/public/engines/search.json
|
prefix: https://player.stv.tv/
|
||||||
|
search: https://v4.api.stv.tv/v4/discovery/search?query={search_term}&indexUid=programme_index&limit=20&offset=0&facets="
|
||||||
|
|||||||
Reference in New Issue
Block a user