aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-04 00:06:11 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-04 00:06:11 +0100
commita13c19e31cb033730fa179a90f0bc5bd961bd3dc (patch)
treeee459da17b1baa8a1aba503451231a5075c46c8a /src/QuickMedia.cpp
parent8497b3daea44fe26fbc2d089a55e75a219e8d603 (diff)
Fix xv video and related page, fix possible crash when going back from related video
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 1ee0816..b788e0b 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -922,6 +922,23 @@ namespace QuickMedia {
media_generic_search_page->search_handler("https://www.xvideos.com/?k=%s&p=%p", 0)
.text_handler({{"//div[id='main']//div[class='thumb-under']//a", "title", "href", "/video"}})
.thumbnail_handler({{"//div[id='main']//div[class='thumb']//img", "data-src", "/videos"}})
+ .video_url_custom_handler([](const std::string &html_source) -> std::string {
+ size_t start_index = html_source.find("html5player.setVideoHLS");
+ if(start_index == std::string::npos)
+ return "";
+
+ start_index += 23;
+ start_index = html_source.find("'", start_index);
+ if(start_index == std::string::npos)
+ return "";
+
+ start_index += 1;
+ size_t end_index = html_source.find("'", start_index);
+ if(end_index == std::string::npos)
+ return "";
+
+ return html_source.substr(start_index, end_index - start_index);
+ })
.related_media_custom_handler([](const std::string &html_source) {
std::vector<MediaRelatedItem> related_items;
size_t related_start = html_source.find("video_related=[");
@@ -969,10 +986,10 @@ namespace QuickMedia {
static void add_xhamster_handlers(MediaGenericSearchPage *media_generic_search_page) {
media_generic_search_page->search_handler("https://xhamster.com/search/%s?page=%p", 1)
- .text_handler({{"//div[class='video-thumb-info']//a", "text", "href", "/videos/"}})
- .thumbnail_handler({{"//img", "src", "/thumb-"}})
- .related_media_text_handler({{"//div[class='video-thumb-info']//a", "text", "href", "/videos/"}})
- .related_media_thumbnail_handler({{"//img", "src", "/thumb-"}});
+ .text_handler({{"//div[data-role='video-list']//div[class='video-thumb-info']//a", "text", "href", "/videos/"}})
+ .thumbnail_handler({{"//div[data-role='video-list']//img", "src", "/thumb-"}})
+ .related_media_text_handler({{"//div[data-role='video-relations']//div[class='video-thumb-info']//a", "text", "href", "/videos/"}})
+ .related_media_thumbnail_handler({{"//div[data-role='video-relations']//img", "src", "/thumb-"}});
}
static void check_youtube_dl_installed(const std::string &plugin_name) {
@@ -1250,15 +1267,12 @@ namespace QuickMedia {
tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)});
use_youtube_dl = true;
} else if(strcmp(plugin_name, "xvideos") == 0) {
- check_youtube_dl_installed(plugin_name);
-
std::vector<CommandArg> extra_commands = {
{ "--header", "Cookie: last_views=%5B%2236247565-" + std::to_string(time(nullptr)) + "%22%5D" }
};
auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://www.xvideos.com/", mgl::vec2i(352/1.5f, 198/1.5f), true, std::move(extra_commands));
add_xvideos_handlers(search_page.get());
tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)});
- use_youtube_dl = true;
} else if(strcmp(plugin_name, "xhamster") == 0) {
check_youtube_dl_installed(plugin_name);
auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://xhamster.com/", mgl::vec2i(240, 135), true);
@@ -2854,7 +2868,6 @@ namespace QuickMedia {
return url.find("pornhub.com") != std::string::npos
|| url.find("xhamster.com") != std::string::npos
|| url.find("spankbang.com") != std::string::npos
- || url.find("xvideos.com") != std::string::npos
// TODO: Remove when youtube-dl is no longer required to download soundcloud music
|| is_soundcloud(url);
}
@@ -3235,6 +3248,7 @@ namespace QuickMedia {
return;
std::string url = video_page->get_url();
+ related_videos.clear();
related_videos_task = AsyncTask<void>([&related_videos, url, video_page]() {
video_page->mark_watched();
related_videos = video_page->get_related_media(url);