From f7653309817d9f6be208628e9809d894417570a6 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 18 Oct 2023 11:35:46 +0200 Subject: Youtube: fix youtube links with /live/ in url --- TODO | 4 +++- src/plugins/Youtube.cpp | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 0950061..d160342 100644 --- a/TODO +++ b/TODO @@ -287,4 +287,6 @@ Add option to get notified on any matrix event type (maybe have a config list wi we could know when somebody calls us. Also mark such room the same way as a mention - it should be put at the top of the room list. Add command to ignore/hide a room (should also not get notified when you are mentioned in the room). -Improve youtube live streaming performance. It's slow because mpv (ffmpeg) is slow at playing m3u8. \ No newline at end of file +Improve youtube live streaming performance. It's slow because mpv (ffmpeg) is slow at playing m3u8. +Add youtube config for allowing to specify download specific codec preference (or ignore video max height). Might have slow download so cant play high quality video but after downloading it it can be played. +Fix youtube age restricted videos. \ No newline at end of file diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index 0c9580f..2959223 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -67,9 +67,9 @@ namespace QuickMedia { return true; } - index = youtube_url.find("youtu.be/"); + index = youtube_url.find("youtube.com/shorts/"); if(index != std::string::npos) { - index += 9; + index += 19; size_t end_index = youtube_url.find("?", index); if(end_index == std::string::npos) end_index = youtube_url.size(); @@ -77,9 +77,19 @@ namespace QuickMedia { return true; } - index = youtube_url.find("youtube.com/shorts/"); + index = youtube_url.find("youtube.com/live/"); if(index != std::string::npos) { - index += 19; + index += 17; + size_t end_index = youtube_url.find("?", index); + if(end_index == std::string::npos) + end_index = youtube_url.size(); + youtube_video_id = youtube_url.substr(index, end_index - index); + return true; + } + + index = youtube_url.find("youtu.be/"); + if(index != std::string::npos) { + index += 9; size_t end_index = youtube_url.find("?", index); if(end_index == std::string::npos) end_index = youtube_url.size(); -- cgit v1.2.3