<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div><br></div><div><br></div><div>On Tue, Sep 22, 2020, at 10:23, Rémi Denis-Courmont wrote:<br></div><blockquote type="cite" id="qt" style=""><div>Hi,<br></div><div><br></div><div>For each HTTP URL, this checks if an extractor exists.<br></div><div><br></div><div>In the normal case, the URL is already a playable media and it won't match, so we will just fallback to the normal access. This takes some processing, just like the Lua parsers. But it's not even close to being as terrible as the 3 BD and DVD modules which systematically try to open and parse every file URI.<br></div></blockquote><div><br></div><div>I didn't know that BD/DVD could slow down the access opening. We should open a ticket (if not already done) and try to improve it.<br></div><div><br></div><div>For information, lua parsers are terribly slow on android. We spent a lot of time trying to improve or just disable it for some case (mp3 parsing take 50ms without lua versus 1seconds with lua).<br></div><div><br></div><div>I would love to have youtube-dl on any platforms via your patches (but it's another story to put python3 on Android), but I'm also afraid of normal http URI slowdown (when ytdl parsing fails).<br></div><div><br></div><div><br></div><blockquote type="cite" id="qt" style=""><div><br></div><div>In the special case that it's a web page needing extraction, then it wouldn't have worked without the new module, so it's vain to even make a comparison.<br></div><div><br></div><div><br></div><div>As for the security of YoutubeDL, it's out of scope. It's not even part of contribs. Besides, Python is far less prone to security issues than C. There are far more dangerous libraries that we ship and use and yet don't fuzz ourselves.<br></div><div><br></div><div>If you found a security issue with the code in the patch, please say so.<br></div><div><br></div><div class="qt-gmail_quote"><div>Le 22 septembre 2020 08:50:48 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:0pt;margin-left:0.8ex;border-left-color:rgb(204, 204, 204);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><pre class="qt-k9mail"><div>On 2020-09-21 18:02, Rémi Denis-Courmont wrote:<br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:1px;padding-left:1ex;">This passes every HTTP(S) URL through YoutubeDL to extract playlists<br></blockquote><div><br></div><div>That sounds like a terrible idea. What is the extra time and memory <br></div><div>consumption added to every HTTP call ?<br></div><div><br></div><div>Also that means the python script becomes a very sensitive part of VLC. <br></div><div>Is it going to be fuzzed ? What about the Youtube-DL that users may <br></div><div>download from questionable locations, since we don't ship it (nor fuzz it) ?<br></div><div><br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div>or media. If YoutubeDL fails, it falls back to the normal HTTP(S)<br></div><div>access. This includes if YoutubeDL or Python 3 are not found.<hr> NEWS | 1 +<br></div><div> modules/access/Makefile.am | 5 +<br></div><div> modules/access/ytdl.c | 200 +++++++++++++++++++++++++++++++++++++<br></div><div> po/POTFILES.in | 1 +<br></div><div> 4 files changed, 207 insertions(+)<br></div><div> create mode 100644 modules/access/ytdl.c<br></div><div><br></div><div>diff --git a/NEWS b/NEWS<br></div><div>index 9af6a77b8f..7eb1a72567 100644<br></div><div>--- a/NEWS<br></div><div>+++ b/NEWS<br></div><div>@@ -65,6 +65,7 @@ Access:<br></div><div> * Audio CD data tracks are now correctly detected and skipped<br></div><div> * Deprecates Audio CD CDDB lookups in favor of more accurate Musicbrainz<br></div><div> * Improved CD-TEXT and added Shift-JIS encoding support<br></div><div>+ * Support for YoutubeDL (where available).<br></div><div> <br></div><div> Access output:<br></div><div> * Added support for the RIST (Reliable Internet Stream Transport) Protocol<br></div><div>diff --git a/modules/access/Makefile.am b/modules/access/Makefile.am<br></div><div>index 9cd3098fc2..f7dc76d6d3 100644<br></div><div>--- a/modules/access/Makefile.am<br></div><div>+++ b/modules/access/Makefile.am<br></div><div>@@ -436,6 +436,11 @@ libaccess_mtp_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(accessdir)'<br></div><div> access_LTLIBRARIES += $(LTLIBaccess_mtp)<br></div><div> EXTRA_LTLIBRARIES += libaccess_mtp_plugin.la<br></div><div> <br></div><div>+libaccess_ytdl_plugin_la_SOURCES = access/ytdl.c<br></div><div>+if !HAVE_WIN32<br></div><div>+access_LTLIBRARIES += libaccess_ytdl_plugin.la<br></div><div>+endif<br></div><div>+<br></div><div> ### SRT ###<br></div><div> <br></div><div> libaccess_srt_plugin_la_SOURCES = access/srt.c access/srt_common.c access/srt_common.h dummy.cpp<br></div><div>diff --git a/modules/access/ytdl.c b/modules/access/ytdl.c<br></div><div>new file mode 100644<br></div><div>index 0000000000..4a47f4491e<br></div><div>--- /dev/null<br></div><div>+++ b/modules/access/ytdl.c<br></div><div>@@ -0,0 +1,200 @@<br></div><div>+/*****************************************************************************<br></div><div>+ * ytdl.c:<br></div><div>+ *****************************************************************************<br></div><div>+ * Copyright (C) 2019-2020 Rémi Denis-Courmont<br></div><div>+ *<br></div><div>+ * This program is free software; you can redistribute it and/or modify it<br></div><div>+ * under the terms of the GNU Lesser General Public License as published by<br></div><div>+ * the Free Software Foundation; either version 2.1 of the License, or<br></div><div>+ * (at your option) any later version.<br></div><div>+ *<br></div><div>+ * This program is distributed in the hope that it will be useful,<br></div><div>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br></div><div>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br></div><div>+ * GNU Lesser General Public License for more details.<br></div><div>+ *<br></div><div>+ * You should have received a copy of the GNU Lesser General Public License<br></div><div>+ * along with this program; if not, write to the Free Software Foundation,<br></div><div>+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br></div><div>+ *****************************************************************************/<br></div><div>+<br></div><div>+#ifdef HAVE_CONFIG_H<br></div><div>+# include "config.h"<br></div><div>+#endif<br></div><div>+<br></div><div>+#define PY_SSIZE_T_CLEAN<br></div><div>+<br></div><div>+#include <assert.h><br></div><div>+#include <errno.h><br></div><div>+#include <signal.h><br></div><div>+#include <stdlib.h><br></div><div>+<br></div><div>+#include <vlc_common.h><br></div><div>+#include <vlc_access.h><br></div><div>+#include <vlc_fs.h><br></div><div>+#include <vlc_input_item.h><br></div><div>+#include <vlc_interrupt.h><br></div><div>+#include <vlc_plugin.h><br></div><div>+#include <vlc_spawn.h><br></div><div>+<br></div><div>+<br></div><div>+struct ytdl_sys {<br></div><div>+ pid_t pid;<br></div><div>+ int fd;<br></div><div>+ char first_byte;<br></div><div>+};<br></div><div>+<br></div><div>+static size_t readall(int fd, void *buf, size_t len)<br></div><div>+{<br></div><div>+ size_t total = 0;<br></div><div>+<br></div><div>+ while (len > 0 && !vlc_killed()) {<br></div><div>+ ssize_t val = vlc_read_i11e(fd, buf, len);<br></div><div>+<br></div><div>+ if (val == 0)<br></div><div>+ break; /* EOS */<br></div><div>+<br></div><div>+ if (val < 0) {<br></div><div>+ if (errno != EINTR)<br></div><div>+ break; /* fatal error */<br></div><div>+ continue;<br></div><div>+ }<br></div><div>+<br></div><div>+ buf = (char *)buf + val;<br></div><div>+ len -= val;<br></div><div>+ total += val;<br></div><div>+ }<br></div><div>+<br></div><div>+ return total;<br></div><div>+}<br></div><div>+<br></div><div>+static ssize_t Read(stream_t *s, void *buf, size_t len)<br></div><div>+{<br></div><div>+ struct ytdl_sys *sys = s->p_sys;<br></div><div>+ ssize_t val = vlc_read_i11e(sys->fd, buf, len);<br></div><div>+<br></div><div>+ if (val < 0) {<br></div><div>+ if (errno == EINTR || errno == EAGAIN)<br></div><div>+ return -1;<br></div><div>+<br></div><div>+ msg_Err(s, "read error: %s", vlc_strerror_c(errno));<br></div><div>+ val = 0;<br></div><div>+ }<br></div><div>+<br></div><div>+ return val;<br></div><div>+}<br></div><div>+<br></div><div>+static int Control(stream_t *s, int query, va_list args)<br></div><div>+{<br></div><div>+ switch (query)<br></div><div>+ {<br></div><div>+ case STREAM_CAN_SEEK:<br></div><div>+ case STREAM_CAN_FASTSEEK:<br></div><div>+ case STREAM_CAN_PAUSE:<br></div><div>+ case STREAM_CAN_CONTROL_PACE:<br></div><div>+ *va_arg(args, bool *) = false;<br></div><div>+ break;<br></div><div>+<br></div><div>+ case STREAM_GET_TYPE:<br></div><div>+ *va_arg(args, int *) = ITEM_TYPE_PLAYLIST;<br></div><div>+ break;<br></div><div>+<br></div><div>+ case STREAM_GET_PTS_DELAY:<br></div><div>+ *va_arg(args, vlc_tick_t *) =<br></div><div>+ VLC_TICK_FROM_MS(var_InheritInteger(s, "network-caching"));<br></div><div>+ break;<br></div><div>+<br></div><div>+ default:<br></div><div>+ return VLC_EGENERIC;<br></div><div>+<br></div><div>+ }<br></div><div>+<br></div><div>+ return VLC_SUCCESS;<br></div><div>+}<br></div><div>+<br></div><div>+static ssize_t ReadFirstByte(stream_t *s, void *buf, size_t len)<br></div><div>+{<br></div><div>+ struct ytdl_sys *sys = s->p_sys;<br></div><div>+<br></div><div>+ if (unlikely(len == 0))<br></div><div>+ return 0;<br></div><div>+<br></div><div>+ *(char *)buf = sys->first_byte;<br></div><div>+ s->pf_read = Read;<br></div><div>+ return 1;<br></div><div>+}<br></div><div>+<br></div><div>+static void Close(vlc_object_t *obj)<br></div><div>+{<br></div><div>+ stream_t *s = (stream_t *)obj;<br></div><div>+ struct ytdl_sys *sys = s->p_sys;<br></div><div>+<br></div><div>+ kill(sys->pid, SIGTERM);<br></div><div>+ vlc_close(sys->fd);<br></div><div>+ vlc_waitpid(sys->pid);<br></div><div>+}<br></div><div>+<br></div><div>+static int Open(vlc_object_t *obj)<br></div><div>+{<br></div><div>+ stream_t *s = (stream_t *)obj;<br></div><div>+ ssize_t val;<br></div><div>+<br></div><div>+ if (!var_InheritBool(s, "ytdl"))<br></div><div>+ return VLC_EGENERIC;<br></div><div>+<br></div><div>+ struct ytdl_sys *sys = vlc_obj_malloc(obj, sizeof (*sys));<br></div><div>+ if (unlikely(sys == NULL))<br></div><div>+ return VLC_EGENERIC;<br></div><div>+<br></div><div>+ char *path = config_GetSysPath(VLC_PKG_DATA_DIR, "ytdl-extract.py");<br></div><div>+ if (unlikely(path == NULL))<br></div><div>+ return VLC_EGENERIC;<br></div><div>+<br></div><div>+ int fds[2];<br></div><div>+<br></div><div>+ if (vlc_pipe(fds)) {<br></div><div>+ free(path);<br></div><div>+ return VLC_EGENERIC;<br></div><div>+ }<br></div><div>+<br></div><div>+ s->p_sys = sys;<br></div><div>+ sys->fd = fds[0];<br></div><div>+<br></div><div>+ int fdv[] = { -1, fds[1], 2, -1 };<br></div><div>+ const char *argv[] = { path, s->psz_url, NULL };<br></div><div>+<br></div><div>+ val = vlc_spawn(&sys->pid, path, fdv, argv);<br></div><div>+ vlc_close(fds[1]);<br></div><div>+<br></div><div>+ if (val) {<br></div><div>+ msg_Dbg(obj, "cannot start %s: %s", path, vlc_strerror_c(val));<br></div><div>+ free(path);<br></div><div>+ vlc_close(fds[0]);<br></div><div>+ return VLC_EGENERIC;<br></div><div>+ }<br></div><div>+<br></div><div>+ free(path);<br></div><div>+<br></div><div>+ if (readall(sys->fd, &sys->first_byte, 1) <= 0) {<br></div><div>+ /* Location not handled */<br></div><div>+ msg_Dbg(s, "cannot extract infos");<br></div><div>+ Close(obj);<br></div><div>+ return VLC_EGENERIC;<br></div><div>+ }<br></div><div>+<br></div><div>+ s->pf_read = ReadFirstByte;<br></div><div>+ s->pf_control = Control;<br></div><div>+ return VLC_SUCCESS;<br></div><div>+}<br></div><div>+<br></div><div>+vlc_module_begin()<br></div><div>+ set_shortname("YT-DL")<br></div><div>+ set_description("YoutubeDL")<br></div><div>+ set_category(CAT_INPUT)<br></div><div>+ set_subcategory(SUBCAT_INPUT_STREAM_FILTER)<br></div><div>+ set_capability("access", 10)<br></div><div>+ add_shortcut("http", "https")<br></div><div>+ set_callbacks(Open, Close)<br></div><div>+ add_bool("ytdl", true, N_("Enable YT-DL"), N_("Enable YT-DL"), true)<br></div><div>+ change_safe()<br></div><div>+vlc_module_end()<br></div><div>diff --git a/po/POTFILES.in b/po/POTFILES.in<br></div><div>index d5ce933408..9d49cb59d8 100644<br></div><div>--- a/po/POTFILES.in<br></div><div>+++ b/po/POTFILES.in<br></div><div>@@ -212,6 +212,7 @@ modules/access/vcd/vcd.c<br></div><div> modules/access/vdr.c<br></div><div> modules/access/vnc.c<br></div><div> modules/access/wasapi.c<br></div><div>+modules/access/ytdl.c<br></div><div> modules/access_output/dummy.c<br></div><div> modules/access_output/file.c<br></div><div> modules/access_output/http.c<br></div><div>-- <br></div><div>2.28.0<hr>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></blockquote><div><hr>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></pre></blockquote></div><div><br></div><div>-- <br></div><div>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté. <br></div><div>_______________________________________________<br></div><div>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></blockquote><div><br></div></body></html>