From eb7a96ee94a864270f5561d8d3b3ef01cd303703 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 8 Nov 2023 21:50:05 +0100 Subject: [PATCH] [`youtube`] Added more metadata fields to search results. --- platypush/plugins/media/__init__.py | 1 - platypush/plugins/youtube/__init__.py | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/media/__init__.py b/platypush/plugins/media/__init__.py index 04ff279c8d..0ea952941c 100644 --- a/platypush/plugins/media/__init__.py +++ b/platypush/plugins/media/__init__.py @@ -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, diff --git a/platypush/plugins/youtube/__init__.py b/platypush/plugins/youtube/__init__.py index aff9f2a086..d82e68236f 100644 --- a/platypush/plugins/youtube/__init__.py +++ b/platypush/plugins/youtube/__init__.py @@ -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", []) ]