aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO7
-rw-r--r--include/VideoPlayer.hpp5
-rw-r--r--src/QuickMedia.cpp25
-rw-r--r--src/VideoPlayer.cpp13
-rw-r--r--src/plugins/Matrix.cpp4
5 files changed, 33 insertions, 21 deletions
diff --git a/TODO b/TODO
index fe5b750..6e6a578 100644
--- a/TODO
+++ b/TODO
@@ -93,7 +93,7 @@ Modify matrix sync to download and parse json but not handle it, and then add a
Fetch replies/pinned message using multiple threads.
Show in room tags list when there is a message in any of the rooms in the tag.
Cancel video download when pressing escape or closing window (important in matrix).
-Support webp (or it seems to already be supported?).
+Support webp. Then switch to the youtube thumbnails from the response json instead of hqdefault, to remove the black bars.
Show images while they download by showing them as scanlines starting from the top. Needed for slow websites such as 4chan.
Use curl parallel download instead of downloading with multiple threads.
Handle matrix groups? (which also contains join, invite, leave...).
@@ -158,5 +158,6 @@ Sort reactions by timestamp.
Check what happens with xsrf_token if comments are not fetched for a long time. Does it time out? if so do we need to refetch the video page to get the new token?.
Add support for comments in live youtube videos, api is at: https://www.youtube.com/youtubei/v1/live_chat/get_live_chat?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8.
Make video visible when reading comments (youtube).
-Convert nyaa.si date from unix date to local time.
-When ui is scaled then the predicated thumbnail size will be wrong since its scaled in Body but not in the plugins where they are requested. \ No newline at end of file
+Convert nyaa.si/spotify/soundcloud date from ISO date string to local time.
+When ui is scaled then the predicated thumbnail size will be wrong since its scaled in Body but not in the plugins where they are requested.
+Automatically fetch the next page on soundcloud when playing music and reaching the bottom, to be able to play the music from the next page as well. \ No newline at end of file
diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp
index b2326bb..adb19c8 100644
--- a/include/VideoPlayer.hpp
+++ b/include/VideoPlayer.hpp
@@ -41,8 +41,7 @@ namespace QuickMedia {
VideoPlayer(const VideoPlayer&) = delete;
VideoPlayer& operator=(const VideoPlayer&) = delete;
- // @path can also be an url if youtube-dl is installed and accessible to mpv
- Error load_video(const char *path, sf::WindowHandle parent_window, const std::string &plugin_name);
+ Error load_video(const char *path, sf::WindowHandle parent_window, const std::string &plugin_name, const std::string &title);
// Should be called every update frame
Error update();
@@ -70,7 +69,7 @@ namespace QuickMedia {
int exit_status;
private:
Error send_command(const char *cmd, size_t size);
- Error launch_video_process(const char *path, sf::WindowHandle parent_window, const std::string &plugin_name);
+ Error launch_video_process(const char *path, sf::WindowHandle parent_window, const std::string &plugin_name, const std::string &title);
VideoPlayer::Error read_ipc_func();
private:
bool use_tor;
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index cc89146..a26f52f 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1750,6 +1750,7 @@ namespace QuickMedia {
PageType previous_page = pop_page_stack();
std::string video_url = video_page->get_url();
+ std::string original_video_url = video_url;
bool video_url_is_local = false;
if(download_if_streaming_fails) {
@@ -1836,7 +1837,7 @@ namespace QuickMedia {
}
video_player = std::make_unique<VideoPlayer>(use_tor, no_video, use_system_mpv_config, resume_video, is_matrix, video_event_callback, on_window_create, resources_root, get_largest_monitor_height(disp));
- VideoPlayer::Error err = video_player->load_video(video_url_converted.c_str(), window.getSystemHandle(), plugin_name);
+ VideoPlayer::Error err = video_player->load_video(video_url_converted.c_str(), window.getSystemHandle(), plugin_name, video_title);
if(err != VideoPlayer::Error::OK) {
std::string err_msg = "Failed to play url: ";
err_msg += video_url;
@@ -1916,23 +1917,23 @@ namespace QuickMedia {
bool cursor_visible = true;
sf::Clock cursor_hide_timer;
- auto save_video_url_to_clipboard = [&video_url_is_local, &video_url, &video_player_window, &video_player]() {
- if(!video_player_window || video_url_is_local)
+ auto save_video_url_to_clipboard = [&original_video_url, &video_player_window, &video_player]() {
+ if(!video_player_window)
return;
- if(video_url_supports_timestamp(video_url)) {
+ if(video_url_supports_timestamp(original_video_url)) {
// TODO: Remove timestamp (&t= or ?t=) from video_url
double time_in_file;
if(video_player->get_time_in_file(&time_in_file) != VideoPlayer::Error::OK)
time_in_file = 0.0;
- std::string clipboard = video_url;
+ std::string clipboard = original_video_url;
if((int)time_in_file > 0)
clipboard += "&t=" + std::to_string((int)time_in_file);
sf::Clipboard::setString(sf::String::fromUtf8(clipboard.begin(), clipboard.end()));
} else {
- sf::Clipboard::setString(sf::String::fromUtf8(video_url.begin(), video_url.end()));
+ sf::Clipboard::setString(sf::String::fromUtf8(original_video_url.begin(), original_video_url.end()));
}
};
@@ -2844,10 +2845,10 @@ namespace QuickMedia {
page_stack.push(PageType::IMAGE_BOARD_THREAD);
current_page = PageType::VIDEO_CONTENT;
watched_videos.clear();
- // TODO: Use real title
thread_page->video_url = selected_item->attached_content_url;
BodyItems next_items;
- video_content_page(thread_page, "No title.webm", true, next_items, 0);
+ // TODO: Use real title
+ video_content_page(thread_page, "", true, next_items, 0);
redraw = true;
} else {
if(downloading_image && load_image_future.valid())
@@ -4139,10 +4140,10 @@ namespace QuickMedia {
page_stack.push(PageType::CHAT);
watched_videos.clear();
current_page = PageType::VIDEO_CONTENT;
- // TODO: Add title
video_page->url = url;
BodyItems next_items;
- video_content_page(video_page.get(), "No title", false, next_items, 0);
+ // TODO: Add title
+ video_content_page(video_page.get(), "", false, next_items, 0);
redraw = true;
} else {
const char *launch_program = "xdg-open";
@@ -4219,10 +4220,10 @@ namespace QuickMedia {
bool is_audio = (message_type == MessageType::AUDIO);
bool prev_no_video = no_video;
no_video = is_audio;
- // TODO: Add title
video_page->url = selected->url;
BodyItems next_items;
- video_content_page(video_page.get(), "No title", message_type == MessageType::VIDEO || message_type == MessageType::AUDIO, next_items, 0);
+ // TODO: Add title
+ video_content_page(video_page.get(), "", message_type == MessageType::VIDEO || message_type == MessageType::AUDIO, next_items, 0);
no_video = prev_no_video;
redraw = true;
return true;
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index 3b93c44..679f5bf 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -64,7 +64,7 @@ namespace QuickMedia {
XCloseDisplay(display);
}
- VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, sf::WindowHandle _parent_window, const std::string&) {
+ VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, sf::WindowHandle _parent_window, const std::string&, const std::string &title) {
parent_window = _parent_window;
if(!tmpnam(ipc_server_path)) {
@@ -97,6 +97,10 @@ namespace QuickMedia {
else
ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best";
+ std::string script_opts;
+ if(!title.empty())
+ script_opts = "--script-opts='osc-title=" + title + "'";
+
// TODO: Resume playback if the last video played matches the first video played next time QuickMedia is launched
args.insert(args.end(), {
"mpv",
@@ -122,6 +126,9 @@ namespace QuickMedia {
if(!resume_playback)
args.push_back("--no-resume-playback");
+ if(!script_opts.empty())
+ args.push_back(script_opts.c_str());
+
if(!use_system_mpv_config) {
args.insert(args.end(), {
"--no-config", /*"--demuxer-max-bytes=40M", "--demuxer-max-back-bytes=20M",*/
@@ -168,12 +175,12 @@ namespace QuickMedia {
return Error::OK;
}
- VideoPlayer::Error VideoPlayer::load_video(const char *path, sf::WindowHandle _parent_window, const std::string &plugin_name) {
+ VideoPlayer::Error VideoPlayer::load_video(const char *path, sf::WindowHandle _parent_window, const std::string &plugin_name, const std::string &title) {
// This check is to make sure we dont change window that the video belongs to. This is not a usecase we will have so
// no need to support it for now at least.
assert(parent_window == 0 || parent_window == _parent_window);
if(video_process_id == -1)
- return launch_video_process(path, _parent_window, plugin_name);
+ return launch_video_process(path, _parent_window, plugin_name, title);
Json::Value command_data(Json::arrayValue);
command_data.append("loadfile");
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 1460687..220a059 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -2100,6 +2100,8 @@ namespace QuickMedia {
message->thumbnail_url = message_content_extract_thumbnail_url(*content_json, homeserver);
message_content_extract_thumbnail_size(*content_json, message->thumbnail_size);
message->type = MessageType::VIDEO;
+ if(message->thumbnail_url.empty())
+ prefix = "🎥 play ";
} else if(strcmp(content_type.GetString(), "m.audio") == 0) {
const rapidjson::Value &url_json = GetMember(*content_json, "url");
if(!url_json.IsString() || strncmp(url_json.GetString(), "mxc://", 6) != 0)
@@ -2107,6 +2109,7 @@ namespace QuickMedia {
message->url = homeserver + "/_matrix/media/r0/download/" + (url_json.GetString() + 6);
message->type = MessageType::AUDIO;
+ prefix = "🎵 play ";
} else if(strcmp(content_type.GetString(), "m.file") == 0) {
const rapidjson::Value &url_json = GetMember(*content_json, "url");
if(!url_json.IsString() || strncmp(url_json.GetString(), "mxc://", 6) != 0)
@@ -2114,6 +2117,7 @@ namespace QuickMedia {
message->url = homeserver + "/_matrix/media/r0/download/" + (url_json.GetString() + 6);
message->type = MessageType::FILE;
+ prefix = "💾 download ";
} else if(strcmp(content_type.GetString(), "m.emote") == 0) { // this is a /me message, TODO: show /me messages differently
message->type = MessageType::TEXT;
prefix = "*" + room_data->get_user_display_name(user) + "* ";