aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-09 11:54:24 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-09 11:57:38 +0200
commitc64d577cb053b6fee8e84f768419e84c3c9df2cc (patch)
tree26f9b83b97670f38155d8ca21bb94d77c93b15ad
parent76ef34393aa72230a3490ecf7b06647ede1448da (diff)
Fix peertube video download
-rw-r--r--plugins/Page.hpp1
-rw-r--r--plugins/Peertube.hpp1
-rw-r--r--src/DownloadUtils.cpp16
-rw-r--r--src/QuickMedia.cpp6
-rw-r--r--src/plugins/Peertube.cpp8
5 files changed, 20 insertions, 12 deletions
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index 071351b..925a53a 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -135,6 +135,7 @@ namespace QuickMedia {
virtual std::unique_ptr<Page> create_channels_page(Program *program, const std::string &channel_url) = 0;
virtual void set_url(std::string new_url) { url = std::move(new_url); }
std::string get_url() { return url; }
+ virtual std::string get_download_url(int max_height) { return url; }
// Returns empty string for no timestamp or if the video doesn't support timestamps.
// Timestamp is in seconds.
virtual std::string get_url_timestamp() { return ""; }
diff --git a/plugins/Peertube.hpp b/plugins/Peertube.hpp
index 833cb5f..88ba1ca 100644
--- a/plugins/Peertube.hpp
+++ b/plugins/Peertube.hpp
@@ -78,6 +78,7 @@ namespace QuickMedia {
std::unique_ptr<Page> create_comments_page(Program *program) override;
std::unique_ptr<RelatedVideosPage> create_related_videos_page(Program *program) override;
std::unique_ptr<Page> create_channels_page(Program *program, const std::string &channel_url) override;
+ std::string get_download_url(int max_height) override;
std::string get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) override;
std::string get_audio_url(std::string &ext) override;
PluginResult load(std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters, std::string &err_str) override;
diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp
index a56a56e..93df291 100644
--- a/src/DownloadUtils.cpp
+++ b/src/DownloadUtils.cpp
@@ -136,18 +136,18 @@ namespace QuickMedia {
fprintf(stderr, "Download duration for %s: %d ms\n", url.c_str(), timer.getElapsedTime().asMilliseconds());
std::string content_disposition = header_extract_value(header, "content-disposition");
- size_t filename_start = content_disposition.find("filename=");
+ // TODO: after filename*= the encoding type will follow. We need to support other formats than utf-8 as well
+ size_t filename_start = content_disposition.find("filename*=");
if(filename_start == std::string::npos) {
- // TODO: after filename*= the encoding type will follow. We need to support other formats than utf-8 as well
- filename_start = content_disposition.find("filename*=");
+ filename_start = content_disposition.find("filename=");
if(filename_start != std::string::npos) {
- filename_start += 10;
- filename_start = content_disposition.find("''", filename_start);
- if(filename_start != std::string::npos)
- filename_start += 2;
+ filename_start += 9;
}
} else {
- filename_start += 9;
+ filename_start += 10;
+ filename_start = content_disposition.find("''", filename_start);
+ if(filename_start != std::string::npos)
+ filename_start += 2;
}
if(filename_start == std::string::npos) {
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index a038f66..32696b6 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1213,7 +1213,7 @@ namespace QuickMedia {
if(instance.empty()) {
tabs.push_back(Tab{create_body(false, false), std::make_unique<PeertubeInstanceSelectionPage>(this), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
} else {
- tabs.push_back(Tab{create_body(false, true), std::make_unique<PeertubeSearchPage>(this, instance), create_search_bar("Search...", 350)});
+ tabs.push_back(Tab{create_body(false, true), std::make_unique<PeertubeSearchPage>(this, instance), create_search_bar("Search...", 500)});
}
} else if(strcmp(plugin_name, "pornhub") == 0) {
check_youtube_dl_installed(plugin_name);
@@ -2561,7 +2561,7 @@ namespace QuickMedia {
}
void Program::video_page_download_video(const std::string &url, sf::WindowHandle video_player_window) {
- bool separate_audio_option = url_should_download_with_youtube_dl(url);;
+ bool separate_audio_option = url_should_download_with_youtube_dl(url);
std::string video_id;
separate_audio_option |= youtube_url_extract_id(url, video_id);
@@ -3042,7 +3042,7 @@ namespace QuickMedia {
} else if(pressed_keysym == XK_f && pressing_ctrl) {
window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::TOGGLE);
} else if(pressed_keysym == XK_s && pressing_ctrl) {
- video_page_download_video(video_page->get_url(), video_player_window);
+ video_page_download_video(video_page->get_download_url(get_largest_monitor_height(disp)), video_player_window);
} else if(pressed_keysym == XK_F5) {
double resume_start_time = 0.0;
video_player->get_time_in_file(&resume_start_time);
diff --git a/src/plugins/Peertube.cpp b/src/plugins/Peertube.cpp
index dacd2d0..2b2d654 100644
--- a/src/plugins/Peertube.cpp
+++ b/src/plugins/Peertube.cpp
@@ -15,7 +15,7 @@ namespace QuickMedia {
}
PluginResult PeertubeInstanceSelectionPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{create_body(false, true), std::make_unique<PeertubeSearchPage>(program, url), create_search_bar("Search...", 350)});
+ result_tabs.push_back(Tab{create_body(false, true), std::make_unique<PeertubeSearchPage>(program, url), create_search_bar("Search...", 500)});
return PluginResult::OK;
}
@@ -318,6 +318,12 @@ namespace QuickMedia {
return url.substr(dot_index);
}
+ std::string PeertubeVideoPage::get_download_url(int max_height) {
+ bool has_embedded_audio;
+ std::string ext;
+ return get_video_url(max_height, has_embedded_audio, ext);
+ }
+
std::string PeertubeVideoPage::get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) {
has_embedded_audio = true;