recycleactor commited on
Commit
57386cb
·
verified ·
1 Parent(s): 5a60ff5

Upload 4 files

Browse files
Files changed (1) hide show
  1. app.py +0 -79
app.py CHANGED
@@ -245,85 +245,6 @@ async def _get_vk_token() -> str:
245
  return token
246
 
247
 
248
- @app.get("/vkvideo/search")
249
- async def vkvideo_search(q: str, offset: int = 0, count: int = 50):
250
- """Пошук відео VK Video БЕЗ фільтрів - включає весь контент"""
251
- token = await _get_vk_token()
252
- if not token:
253
- return Response(content='{"error":"no_token"}', status_code=503,
254
- media_type="application/json", headers={"Access-Control-Allow-Origin": "*"})
255
-
256
- import urllib.parse
257
- post_data = (
258
- "screen_ref=search_video_service&input_method=keyboard_search_button"
259
- f"&q={urllib.parse.quote(q)}&offset={offset}&count={count}&access_token={token}"
260
- )
261
-
262
- async with httpx.AsyncClient(timeout=15, follow_redirects=True) as client:
263
- r = await client.post(
264
- VK_SEARCH_URL,
265
- content=post_data.encode(),
266
- headers={
267
- "Content-Type": "application/x-www-form-urlencoded",
268
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
269
- "Origin": "https://vkvideo.ru",
270
- "Referer": "https://vkvideo.ru/",
271
- }
272
- )
273
-
274
- try:
275
- data = r.json()
276
- except Exception:
277
- return Response(content='{"error":"parse"}', status_code=500,
278
- media_type="application/json", headers={"Access-Control-Allow-Origin": "*"})
279
-
280
- videos = data.get("response", {}).get("catalog_videos", [])
281
-
282
- # БЕЗ фільтрації - віддаємо все що є
283
- results = []
284
- for item in videos:
285
- v = item.get("video")
286
- if not v:
287
- continue
288
-
289
- files = v.get("files") or {}
290
- player_url = v.get("player")
291
-
292
- results.append({
293
- "id": v.get("id"),
294
- "owner_id": v.get("owner_id"),
295
- "title": v.get("title"),
296
- "description": v.get("description", ""),
297
- "duration": v.get("duration", 0),
298
- "image": v.get("image"),
299
- "date": v.get("date"),
300
- "views": v.get("views", 0),
301
- "player": player_url,
302
- "mp4_2160": files.get("mp4_2160"),
303
- "mp4_1440": files.get("mp4_1440"),
304
- "mp4_1080": files.get("mp4_1080"),
305
- "mp4_720": files.get("mp4_720"),
306
- "mp4_480": files.get("mp4_480"),
307
- "mp4_360": files.get("mp4_360"),
308
- "mp4_240": files.get("mp4_240"),
309
- "hls": files.get("hls"),
310
- "dash": files.get("dash"),
311
- "subtitles": v.get("subtitles") or [],
312
- "tracks": v.get("tracks") or [],
313
- })
314
-
315
- import json
316
- return Response(
317
- content=json.dumps({
318
- "items": results,
319
- "count": len(results),
320
- "offset": offset
321
- }, ensure_ascii=False),
322
- media_type="application/json",
323
- headers={"Access-Control-Allow-Origin": "*"}
324
- )
325
-
326
-
327
  @app.get("/vkmovie/search")
328
  async def vkmovie_search(q: str, kp: str = "", year: str = ""):
329
  """Ищет фильм в VK Video по названию+год, возвращает прямые MP4 ссылки"""
 
245
  return token
246
 
247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  @app.get("/vkmovie/search")
249
  async def vkmovie_search(q: str, kp: str = "", year: str = ""):
250
  """Ищет фильм в VK Video по названию+год, возвращает прямые MP4 ссылки"""