diff options
Diffstat (limited to 'src/plugins/Youtube.cpp')
-rw-r--r-- | src/plugins/Youtube.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index c6e8533..9b64054 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -136,6 +136,50 @@ namespace QuickMedia { return true; } + index = youtube_url.find("youtube.com/@"); + if(index != std::string::npos) { + index += 12; // 13 - 1, to include @ + size_t end_index = youtube_url.find("/", index); + if(end_index == std::string::npos) + end_index = youtube_url.size(); + channel_id = youtube_url.substr(index, end_index - index); + channel_url = "https://www.youtube.com/" + channel_id; + return true; + } + + index = youtube_url.find("youtu.be/@"); + if(index != std::string::npos) { + index += 9; // 10 - 1, to include @ + size_t end_index = youtube_url.find("/", index); + if(end_index == std::string::npos) + end_index = youtube_url.size(); + channel_id = youtube_url.substr(index, end_index - index); + channel_url = "https://www.youtube.com/" + channel_id; + return true; + } + + index = youtube_url.find("youtube.com/user/"); + if(index != std::string::npos) { + index += 17; + size_t end_index = youtube_url.find("/", index); + if(end_index == std::string::npos) + end_index = youtube_url.size(); + channel_id = youtube_url.substr(index, end_index - index); + channel_url = "https://www.youtube.com/user/" + channel_id; + return true; + } + + index = youtube_url.find("youtu.be/user/"); + if(index != std::string::npos) { + index += 14; + size_t end_index = youtube_url.find("/", index); + if(end_index == std::string::npos) + end_index = youtube_url.size(); + channel_id = youtube_url.substr(index, end_index - index); + channel_url = "https://www.youtube.com/user/" + channel_id; + return true; + } + return false; } |