[`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: 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,
volume: Optional[Union[float, int]] = None,
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_dl: str = 'yt-dlp',
**kwargs,

View File

@ -1,3 +1,4 @@
from datetime import datetime
import urllib.parse
import requests
@ -61,6 +62,14 @@ class YoutubePlugin(Plugin):
"image": item.get("thumbnail"),
"duration": item.get("duration", 0),
"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", [])
]