[vlc-commits] ytdl: factor out meta handling

Rémi Denis-Courmont git at videolan.org
Mon Sep 28 20:14:35 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Sep 27 21:08:00 2020 +0300| [76fc65bce5c3f277fc7fdb99a31a34a0569dc3e2] | committer: Rémi Denis-Courmont

ytdl: factor out meta handling

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=76fc65bce5c3f277fc7fdb99a31a34a0569dc3e2
---

 modules/demux/ytdl.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/modules/demux/ytdl.c b/modules/demux/ytdl.c
index 52c3a77bd7..589218b7f4 100644
--- a/modules/demux/ytdl.c
+++ b/modules/demux/ytdl.c
@@ -132,6 +132,25 @@ static const char *PickArt(const struct json_object *entry)
     return json_get_str(&v->object, "url");
 }
 
+static void GetMeta(vlc_meta_t *meta, const struct json_object *json)
+{
+    const char *title = json_get_str(json, "title");
+    if (title != NULL)
+        vlc_meta_Set(meta, vlc_meta_Title, title);
+
+    const char *desc = json_get_str(json, "description");
+    if (desc != NULL)
+        vlc_meta_Set(meta, vlc_meta_Description, desc);
+
+    const char *author = json_get_str(json, "uploader");
+    if (author != NULL)
+        vlc_meta_Set(meta, vlc_meta_Artist, author);
+
+    const char *arturl = PickArt(json);
+    if (arturl != NULL)
+        vlc_meta_Set(meta, vlc_meta_ArtworkURL, arturl);
+}
+
 static int ReadItem(stream_t *s, input_item_node_t *node,
                     const struct json_object *json)
 {
@@ -158,18 +177,8 @@ static int ReadItem(stream_t *s, input_item_node_t *node,
     if (unlikely(item == NULL))
         return VLC_ENOMEM;
 
-    const char *desc = json_get_str(json, "description");
-    if (desc != NULL)
-        input_item_SetDescription(item, desc);
-
-    const char *author = json_get_str(json, "uploader");
-    if (author != NULL)
-        input_item_SetArtist(item, author);
-
-    const char *arturl = PickArt(json);
-    if (arturl != NULL)
-        input_item_SetArtURL(item, arturl);
-
+    /* Don't care to lock, the item is still private. */
+    GetMeta(item->p_meta, json);
     input_item_AddOption(item, "no-ytdl", 0);
     input_item_node_AppendItem(node, item);
     input_item_Release(item);



More information about the vlc-commits mailing list