From 8c7e64991b6c05d57aaa8dda2df2dc53d789d6c4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 7 Feb 2021 08:29:09 +0100 Subject: Dont download video with --no-video option, ignore events with state_key set if the event is not a m.room.member type --- input.conf | 2 +- src/VideoPlayer.cpp | 6 +++++- src/plugins/Matrix.cpp | 12 ++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/input.conf b/input.conf index 8e7897a..249b43e 100644 --- a/input.conf +++ b/input.conf @@ -1,5 +1,5 @@ Ctrl+c ignore -Backspace ignore +BS ignore q ignore WHEEL_UP ignore WHEEL_DOWN ignore diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index 4653c5b..3b93c44 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -91,7 +91,11 @@ namespace QuickMedia { create_directory_recursive(mpv_watch_later_dir); std::string watch_later_dir = "--watch-later-directory=" + mpv_watch_later_dir.data; - std::string ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best"; + std::string ytdl_format; + if(no_video) + ytdl_format = "--ytdl-format=bestaudio/best"; + else + ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best"; // TODO: Resume playback if the last video played matches the first video played next time QuickMedia is launched args.insert(args.end(), { diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 3a2c02c..9a785b6 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1732,9 +1732,17 @@ namespace QuickMedia { if(!sender_json->IsString()) return nullptr; + const rapidjson::Value &type_json = GetMember(event_item_json, "type"); + if(!type_json.IsString()) + return nullptr; + bool sent_by_somebody_else = false; const rapidjson::Value *state_key_json = &GetMember(event_item_json, "state_key"); if(state_key_json->IsString() && state_key_json->GetStringLength() != 0) { + if(strcmp(type_json.GetString(), "m.room.member") != 0) { + fprintf(stderr, "Matrix: received state key %s but event type is %s, expected m.room.member\n", type_json.GetString(), state_key_json->GetString()); + return nullptr; + } if(strcmp(sender_json->GetString(), state_key_json->GetString()) != 0) sent_by_somebody_else = true; sender_json = state_key_json; @@ -1768,10 +1776,6 @@ namespace QuickMedia { if(origin_server_ts.IsInt64()) timestamp = origin_server_ts.GetInt64(); - const rapidjson::Value &type_json = GetMember(event_item_json, "type"); - if(!type_json.IsString()) - return nullptr; - bool provisional = false; const rapidjson::Value &unsigned_json = GetMember(event_item_json, "unsigned"); if(unsigned_json.IsObject()) { -- cgit v1.2.3