[youtube] Added more metadata fields to search results.

This commit is contained in:
Fabio Manganiello 2023-11-08 21:50:05 +01:00
parent d7093d18c5
commit eb7a96ee94
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 9 additions and 1 deletions

View file

@ -170,7 +170,6 @@ class MediaPlugin(Plugin, ABC):
env: Optional[Dict[str, str]] = None, env: Optional[Dict[str, str]] = None,
volume: Optional[Union[float, int]] = None, volume: Optional[Union[float, int]] = None,
torrent_plugin: str = 'torrent', torrent_plugin: str = 'torrent',
# youtube_format: Optional[str] = 'bv*[height<=?1080][ext=mp4]+bestaudio/best',
youtube_format: Optional[str] = 'best[height<=?1080][ext=mp4]', youtube_format: Optional[str] = 'best[height<=?1080][ext=mp4]',
youtube_dl: str = 'yt-dlp', youtube_dl: str = 'yt-dlp',
**kwargs, **kwargs,

View file

@ -1,3 +1,4 @@
from datetime import datetime
import urllib.parse import urllib.parse
import requests import requests
@ -61,6 +62,14 @@ class YoutubePlugin(Plugin):
"image": item.get("thumbnail"), "image": item.get("thumbnail"),
"duration": item.get("duration", 0), "duration": item.get("duration", 0),
"description": item.get("shortDescription"), "description": item.get("shortDescription"),
"channel": item.get("uploaderName"),
"channel_url": "https://www.youtube.com" + item["uploaderUrl"]
if item.get("uploaderUrl")
else None,
"channel_image": item.get("uploaderAvatar"),
"created_at": datetime.fromtimestamp(item["uploaded"] / 1000)
if item.get("uploaded")
else None,
} }
for item in rs.json().get("items", []) for item in rs.json().get("items", [])
] ]