aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--plugins/Youtube.hpp2
-rw-r--r--src/QuickMedia.cpp44
3 files changed, 28 insertions, 21 deletions
diff --git a/README.md b/README.md
index 214b9f8..535a7f4 100644
--- a/README.md
+++ b/README.md
@@ -31,4 +31,5 @@ Add scrollbar.\
Add option to scale image to window size.\
If you search too fast the search suggestion wont show up and when you press enter it will clear and you wont progress.
The search should wait until there are search results before clearing the search field and selecting the search suggestion.\
-Full-screening a video doesn't work. \ No newline at end of file
+Full-screening a video doesn't work.\
+Somehow deal with youtube banning ip when searching too often. \ No newline at end of file
diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp
index f459630..6fc6039 100644
--- a/plugins/Youtube.hpp
+++ b/plugins/Youtube.hpp
@@ -9,7 +9,7 @@ namespace QuickMedia {
BodyItems get_related_media(const std::string &url) override;
bool search_suggestions_has_thumbnails() const override { return true; }
bool search_results_has_thumbnails() const override { return false; }
- int get_search_delay() const override { return 150; }
+ int get_search_delay() const override { return 500; }
bool search_suggestion_is_search() const override { return true; }
Page get_page_after_search() const override { return Page::VIDEO_CONTENT; }
};
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index ce56b79..4b3698d 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -214,25 +214,28 @@ namespace QuickMedia {
search_bar->onTextSubmitCallback = [this](const std::string &text) {
Page next_page = current_plugin->get_page_after_search();
- if(search_selected_suggestion(body, current_plugin, content_title, content_url) == SearchResult::OK) {
- if(next_page == Page::EPISODE_LIST) {
- Path content_storage_dir = get_storage_dir().join("manga");
- if(create_directory_recursive(content_storage_dir) != 0) {
- show_notification("Storage", "Failed to create directory: " + content_storage_dir.data, Urgency::CRITICAL);
- return;
- }
+ if(search_selected_suggestion(body, current_plugin, content_title, content_url) != SearchResult::OK)
+ return;
- content_storage_file = content_storage_dir.join(base64_encode(content_title));
- content_storage_json.clear();
- content_storage_json["name"] = content_title;
- FileType file_type = get_file_type(content_storage_file);
- if(file_type == FileType::REGULAR)
- get_manga_storage_json(content_storage_file, content_storage_json);
- } else if(next_page == Page::VIDEO_CONTENT) {
- watched_videos.clear();
+ if(next_page == Page::EPISODE_LIST) {
+ Path content_storage_dir = get_storage_dir().join("manga");
+ if(create_directory_recursive(content_storage_dir) != 0) {
+ show_notification("Storage", "Failed to create directory: " + content_storage_dir.data, Urgency::CRITICAL);
+ return;
}
- current_page = next_page;
+
+ content_storage_file = content_storage_dir.join(base64_encode(content_title));
+ content_storage_json.clear();
+ content_storage_json["name"] = content_title;
+ FileType file_type = get_file_type(content_storage_file);
+ if(file_type == FileType::REGULAR)
+ get_manga_storage_json(content_storage_file, content_storage_json);
+ } else if(next_page == Page::VIDEO_CONTENT) {
+ watched_videos.clear();
+ if(content_url.empty())
+ next_page = Page::SEARCH_RESULT;
}
+ current_page = next_page;
};
sf::Vector2f body_pos;
@@ -276,9 +279,12 @@ namespace QuickMedia {
}
if(search_running && search_suggestion_future.valid() && search_suggestion_future.wait_for(std::chrono::seconds(0)) == std::future_status::ready) {
- body->clear_items();
- body->items = search_suggestion_future.get();
- body->clamp_selection();
+ if(update_search_text.empty()) {
+ body->items = search_suggestion_future.get();
+ body->clamp_selection();
+ } else {
+ search_suggestion_future.get();
+ }
search_running = false;
}