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.titles import Episode, Movie, Movies, Series
|
||||
from envied.core.tracks import Chapter, Chapters, Tracks
|
||||
import json
|
||||
|
||||
|
||||
class STV(Service):
|
||||
@@ -55,25 +56,25 @@ class STV(Service):
|
||||
self.base = self.config["endpoints"]["base"]
|
||||
|
||||
def search(self) -> Generator[SearchResult, None, None]:
|
||||
data = {
|
||||
"engine_key": "S1jgssBHdk8ZtMWngK_y",
|
||||
"q": self.title,
|
||||
}
|
||||
r = self.session.post(self.config["endpoints"]["search"], data=data)
|
||||
|
||||
search_term = self.title.replace(" ", "+")
|
||||
r = self.session.get(self.config["endpoints"]["search"].format(search_term=search_term))
|
||||
r.raise_for_status()
|
||||
results = r.json()["records"]["page"]
|
||||
results = json.loads(r.text)["data"]
|
||||
|
||||
for result in results:
|
||||
label = result.get("category")
|
||||
if label and isinstance(label, list):
|
||||
label = result["category"][0]
|
||||
title = result['attributes']["title"]
|
||||
url = result['attributes']["permalink"]
|
||||
synopsis = result['attributes']["long_description"]
|
||||
|
||||
label = result["attributes"]["subGenre"]
|
||||
|
||||
yield SearchResult(
|
||||
id_=result.get("url"),
|
||||
title=result.get("title"),
|
||||
description=result.get("body"),
|
||||
id_= self.config["endpoints"]["prefix"].strip("/") + result["attributes"]["permalink"],
|
||||
title=title,
|
||||
description=synopsis,
|
||||
label=label,
|
||||
url=result.get("url"),
|
||||
url=url,
|
||||
)
|
||||
|
||||
def get_titles(self) -> Union[Movies, Series]:
|
||||
|
||||
@@ -17,4 +17,5 @@ headers:
|
||||
endpoints:
|
||||
base: https://player.api.stv.tv/v1/
|
||||
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