Added Search on KNPY
This commit is contained in:
parent
1d39cf68e5
commit
6509198610
@ -5,6 +5,7 @@ from datetime import datetime, timezone
|
|||||||
from http.cookiejar import CookieJar
|
from http.cookiejar import CookieJar
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
|
from collections.abc import Generator
|
||||||
import click
|
import click
|
||||||
import jwt
|
import jwt
|
||||||
from langcodes import Language
|
from langcodes import Language
|
||||||
@ -365,43 +366,54 @@ class KNPY(Service):
|
|||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return r.content
|
return r.content
|
||||||
|
|
||||||
# def search(self) -> List[SearchResult]:
|
def search(self) -> Generator[SearchResult, None, None]:
|
||||||
# if not hasattr(self, 'search_query'):
|
if not hasattr(self, 'search_query') or not self.search_query:
|
||||||
# self.log.error("Search query not set. Cannot search.")
|
self.log.error("Search query not set. Cannot search.")
|
||||||
# return []
|
return
|
||||||
|
|
||||||
# self.log.info(f"Searching for '{self.search_query}'...")
|
self.log.info(f"Searching for '{self.search_query}'...")
|
||||||
# params = {
|
|
||||||
# "query": self.search_query,
|
# Ensure we have a domain ID (Library ID) before searching
|
||||||
# "sort": "relevance",
|
if not self._domain_id:
|
||||||
# "domainId": self._domain_id,
|
self._fetch_user_details()
|
||||||
# "page": 0,
|
|
||||||
# "perPage": 20
|
|
||||||
# }
|
|
||||||
# r = self.session.get(self.config["endpoints"]["search"], params=params)
|
|
||||||
# r.raise_for_status()
|
|
||||||
# search_data = r.json()
|
|
||||||
|
|
||||||
# results = []
|
params = {
|
||||||
# for item in search_data.get("list", []):
|
"query": self.search_query,
|
||||||
# item_type = item.get("type")
|
"sort": "relevance",
|
||||||
# if item_type not in ["playlist", "video"]:
|
"domainId": self._domain_id,
|
||||||
# continue
|
"isKids": "false",
|
||||||
|
"page": 0,
|
||||||
|
"perPage": 40
|
||||||
|
}
|
||||||
|
|
||||||
# video_id = item.get("videoId")
|
r = self.session.get(self.config["endpoints"]["search"], params=params)
|
||||||
# title = item.get("title", "No Title")
|
r.raise_for_status()
|
||||||
# label = "Series" if item_type == "playlist" else "Movie"
|
search_data = r.json()
|
||||||
|
|
||||||
|
# The API returns results in a "list" key
|
||||||
|
results_list = search_data.get("list", [])
|
||||||
|
|
||||||
|
if not results_list:
|
||||||
|
self.log.warning(f"No results found for '{self.search_query}'")
|
||||||
|
return
|
||||||
|
|
||||||
|
for item in results_list:
|
||||||
|
# Kanopy search results use 'videoId' as the unique identifier
|
||||||
|
video_id = item.get("videoId")
|
||||||
|
if not video_id:
|
||||||
|
continue
|
||||||
|
|
||||||
|
title = item.get("title", "Unknown Title")
|
||||||
|
|
||||||
# results.append(
|
# Since the search API doesn't explicitly return "type",
|
||||||
# SearchResult(
|
# we provide a generic label or try to guess.
|
||||||
# id_=str(video_id),
|
# In your get_titles logic, you handle both, so we point to the watch URL.
|
||||||
# title=title,
|
yield SearchResult(
|
||||||
# description="",
|
id_=str(video_id),
|
||||||
# label=label,
|
title=title,
|
||||||
# url=f"https://www.kanopy.com/watch/{video_id}"
|
label="VIDEO/SERIES",
|
||||||
# )
|
url=f"https://www.kanopy.com/video/{video_id}"
|
||||||
# )
|
)
|
||||||
# return results
|
|
||||||
|
|
||||||
def get_chapters(self, title: Title_T) -> list:
|
def get_chapters(self, title: Title_T) -> list:
|
||||||
return []
|
return []
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
- Subtitle has little quirk of having javanese and sundanese language labeled on the HLS one but not the DASH one
|
- Subtitle has little quirk of having javanese and sundanese language labeled on the HLS one but not the DASH one
|
||||||
- Search functionality not available yet
|
- Search functionality not available yet
|
||||||
8. KNPY:
|
8. KNPY:
|
||||||
- Need to fix the search function
|
- HLS downloading is not working
|
||||||
9. VRT:
|
9. VRT:
|
||||||
- Search functionality
|
- Search functionality
|
||||||
- Fixing few hickups
|
- Fixing few hickups
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user