Hotfix for yt restricted search

This commit is contained in:
Christoph Stahl 2024-09-22 21:23:06 +02:00
parent b80f6559a7
commit bf104362ea
2 changed files with 11 additions and 4 deletions

View file

@ -32,7 +32,8 @@ import socketio
from aiohttp import web
from profanity_check import predict
from syng.result import Result
from .result import Result
from .sources.youtube import YouTube
from . import jsonencoder
from .entry import Entry
@ -1125,6 +1126,12 @@ async def handle_search_results(sid: str, data: dict[str, Any]) -> None:
web_sid = data["sid"]
results = [Result.from_dict(result) for result in data["results"]]
# TODO this handles YouTubes anti-bot measures
__unused_yt_list = [
YouTube.from_result(result) for result in data["results"] if "youtube" in "ident"
]
await send_search_results(web_sid, results)

View file

@ -27,9 +27,9 @@ class YouTube:
A minimal compatibility layer for the YouTube object of pytube, implemented via yt-dlp
"""
__cache__: dict[str, Any] = (
{}
) # TODO: this may grow fast... but atm it fixed youtubes anti bot measures
__cache__: dict[
str, Any
] = {} # TODO: this may grow fast... but atm it fixed youtubes anti bot measures
def __init__(self, url: Optional[str] = None):
"""