From f10d6cabc6d9d579f3a8682f453863e50ca90b7b Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Mon, 30 Sep 2024 14:42:35 -0400 Subject: [PATCH 01/13] WIP scripting config stuff --- .gitignore | 4 +- scripts/configure.sh | 103 +++++++++++++++++++++++++++++++++++++++++++ xapi.lua | 2 +- 3 files changed, 107 insertions(+), 2 deletions(-) create mode 100755 scripts/configure.sh diff --git a/.gitignore b/.gitignore index 8b13789..464663e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ - +.DS_Store +.resources +scripts/test.sh diff --git a/scripts/configure.sh b/scripts/configure.sh new file mode 100755 index 0000000..1e010ce --- /dev/null +++ b/scripts/configure.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +get_vlc_config_directory() { + local config_dir="" + + # Check the OS type using uname + if [[ "$(uname)" == "Darwin" ]]; then + # macOS + if [[ -n "$HOME" ]]; then + config_dir="$HOME/Library/Preferences/org.videolan.vlc/" + fi + elif [[ "$(uname)" == "Linux" ]]; then + # Linux + if [[ -n "$HOME" ]]; then + config_dir="$HOME/.config/vlc/" + fi + elif [[ "$(uname -o 2>/dev/null)" == "Cygwin" || "$(uname -o 2>/dev/null)" == "Msys" || "$(uname -o 2>/dev/null)" == "MINGW32_NT" || "$(uname -o 2>/dev/null)" == "MINGW64_NT" ]]; then + # Windows (Cygwin or WSL environments can also be checked) + if [[ -n "$APPDATA" ]]; then + config_dir="$APPDATA/vlc/" + fi + fi + + # Check if config directory was determined + if [[ -z "$config_dir" ]]; then + echo "Could not determine VLC configuration directory." >&2 + return 1 + fi + + # Ensure the directory exists + if [[ ! -d "$config_dir" ]]; then + mkdir -p "$config_dir" + if [[ $? -ne 0 ]]; then + echo "Failed to create directory: $config_dir" >&2 + return 1 + fi + fi + + echo "$config_dir" + return 0 +} + +write_config() { + local file_path="$(get_vlc_config_directory)xapi-extension-config.txt" + shift # Remove the file_path from the arguments list + + # Variables to store the required options + local api_key="" + local api_secret="" + local api_url="" + local threshold="" + + # Parse command line options + while getopts "k:s:u:t:" opt; do + case $opt in + k) + api_key="$OPTARG" + ;; + s) + api_secret="$OPTARG" + ;; + u) + api_url="$OPTARG" + ;; + t) + threshold="$OPTARG" + ;; + *) + echo "Usage: $0 -k -s -u -t " + exit 1 + ;; + esac + done + + + # Debugging: Output parsed values + echo "API Key: $api_key" + echo "API Secret: $api_secret" + echo "API URL: $api_url" + echo "Threshold: $threshold" + + + # Ensure all required options are provided + #if [[ -z "$api_key" || -z "$api_secret" || -z "$url" || -z "$threshold" ]]; then + # echo "Error: Missing required options." >&2 + # echo "Usage: $0 --api-key --api-secret --api-url --threshold " >&2 + # return 1 + #fi + + # Write the key-value pairs to the file, only if they exist + [[ -n "$api_key" ]] && echo "api_key = $api_key" >> "$file_path" + [[ -n "$api_secret" ]] && echo "api_secret = $api_secret" >> "$file_path" + [[ -n "$api_url" ]] && echo "api_url = $api_url" >> "$file_path" + [[ -n "$threshold" ]] && echo "threshold = $threshold" >> "$file_path" + + echo "config written to $file_path" + + return 0 +} + +#echo "$(get_vlc_config_directory)" + +write_config "$@" diff --git a/xapi.lua b/xapi.lua index 4b16e1d..e909c9b 100644 --- a/xapi.lua +++ b/xapi.lua @@ -20,7 +20,7 @@ local config_file_path = "" function activate() api_userid = get_uid() - config_file_path = get_vlc_config_directory() .. "config.txt" + config_file_path = get_vlc_config_directory() .. "xapi-extension-config.txt" load_config(config_file_path) vlc.msg.info("config_file_path: "..config_file_path) vlc.msg.info("UID is: " .. api_userid) From 4bb93e87feab5992dd6d002f7fe9a2c0e348888c Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Mon, 14 Oct 2024 10:20:52 -0400 Subject: [PATCH 02/13] script for getting the VLC directory --- scripts/get-config-dir.sh | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 scripts/get-config-dir.sh diff --git a/scripts/get-config-dir.sh b/scripts/get-config-dir.sh new file mode 100755 index 0000000..efaea9b --- /dev/null +++ b/scripts/get-config-dir.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +get_vlc_config_directory() { + local config_dir="" + + # Check the OS type using uname + if [[ "$(uname)" == "Darwin" ]]; then + # macOS + if [[ -n "$HOME" ]]; then + config_dir="$HOME/Library/Preferences/org.videolan.vlc/" + fi + elif [[ "$(uname)" == "Linux" ]]; then + # Linux + if [[ -n "$HOME" ]]; then + config_dir="$HOME/.config/vlc/" + fi + elif [[ "$(uname -o 2>/dev/null)" == "Cygwin" || "$(uname -o 2>/dev/null)" == "Msys" || "$(uname -o 2>/dev/null)" == "MINGW32_NT" || "$(uname -o 2>/dev/null)" == "MINGW64_NT" ]]; then + # Windows (Cygwin or WSL environments can also be checked) + if [[ -n "$APPDATA" ]]; then + config_dir="$APPDATA/vlc/" + fi + fi + + # Check if config directory was determined + if [[ -z "$config_dir" ]]; then + echo "Could not determine VLC configuration directory." >&2 + return 1 + fi + + # Ensure the directory exists + if [[ ! -d "$config_dir" ]]; then + mkdir -p "$config_dir" + if [[ $? -ne 0 ]]; then + echo "Failed to create directory: $config_dir" >&2 + return 1 + fi + fi + + echo "$config_dir" + return 0 +} From 72769e393b1b13be365112f7af7013fd2504e3af Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Mon, 14 Oct 2024 10:21:45 -0400 Subject: [PATCH 03/13] relevant scripting for setting the threshold value --- scripts/configure.sh | 82 +++++++++++++++++--------------------------- xapi.lua | 23 ++++++++++++- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/scripts/configure.sh b/scripts/configure.sh index 1e010ce..552ff65 100755 --- a/scripts/configure.sh +++ b/scripts/configure.sh @@ -1,57 +1,39 @@ #!/bin/bash -get_vlc_config_directory() { - local config_dir="" +source "$(dirname "$0")/get-config-dir.sh" - # Check the OS type using uname - if [[ "$(uname)" == "Darwin" ]]; then - # macOS - if [[ -n "$HOME" ]]; then - config_dir="$HOME/Library/Preferences/org.videolan.vlc/" - fi - elif [[ "$(uname)" == "Linux" ]]; then - # Linux - if [[ -n "$HOME" ]]; then - config_dir="$HOME/.config/vlc/" - fi - elif [[ "$(uname -o 2>/dev/null)" == "Cygwin" || "$(uname -o 2>/dev/null)" == "Msys" || "$(uname -o 2>/dev/null)" == "MINGW32_NT" || "$(uname -o 2>/dev/null)" == "MINGW64_NT" ]]; then - # Windows (Cygwin or WSL environments can also be checked) - if [[ -n "$APPDATA" ]]; then - config_dir="$APPDATA/vlc/" - fi - fi - # Check if config directory was determined - if [[ -z "$config_dir" ]]; then - echo "Could not determine VLC configuration directory." >&2 - return 1 - fi +delete_if_exists() { + local file_path="$1" # The file path is passed as an argument - # Ensure the directory exists - if [[ ! -d "$config_dir" ]]; then - mkdir -p "$config_dir" - if [[ $? -ne 0 ]]; then - echo "Failed to create directory: $config_dir" >&2 - return 1 - fi + # Check if the file exists + if [ -f "$file_path" ]; then + echo "File exists: $file_path" + + # Delete the file + rm "$file_path" + echo "File deleted: $file_path" + else + echo "File does not exist: $file_path" fi - - echo "$config_dir" - return 0 } -write_config() { - local file_path="$(get_vlc_config_directory)xapi-extension-config.txt" - shift # Remove the file_path from the arguments list +configure() { + local xapi_config_file="$(get_vlc_config_directory)xapi-extension-config.txt" + local threshold_config_file="$(get_vlc_config_directory)xapi-threshold-config.txt" + + delete_if_exists "$xapi_config_file" + delete_if_exists "$threshold_config_file" # Variables to store the required options local api_key="" local api_secret="" local api_url="" local threshold="" + local homepage="" # Parse command line options - while getopts "k:s:u:t:" opt; do + while getopts "k:s:u:t:h:" opt; do case $opt in k) api_key="$OPTARG" @@ -65,6 +47,9 @@ write_config() { t) threshold="$OPTARG" ;; + h) + homepage="$OPTARG" + ;; *) echo "Usage: $0 -k -s -u -t " exit 1 @@ -78,26 +63,21 @@ write_config() { echo "API Secret: $api_secret" echo "API URL: $api_url" echo "Threshold: $threshold" + echo "API Homepage: $homepage" - - # Ensure all required options are provided - #if [[ -z "$api_key" || -z "$api_secret" || -z "$url" || -z "$threshold" ]]; then - # echo "Error: Missing required options." >&2 - # echo "Usage: $0 --api-key --api-secret --api-url --threshold " >&2 - # return 1 - #fi # Write the key-value pairs to the file, only if they exist - [[ -n "$api_key" ]] && echo "api_key = $api_key" >> "$file_path" - [[ -n "$api_secret" ]] && echo "api_secret = $api_secret" >> "$file_path" - [[ -n "$api_url" ]] && echo "api_url = $api_url" >> "$file_path" - [[ -n "$threshold" ]] && echo "threshold = $threshold" >> "$file_path" + [[ -n "$api_key" ]] && echo "api_key = $api_key" >> "$xapi_config_file" + [[ -n "$api_secret" ]] && echo "api_secret = $api_secret" >> "$xapi_config_file" + [[ -n "$api_url" ]] && echo "api_url = $api_url" >> "$xapi_config_file" + [[ -n "$threshold" ]] && echo "threshold = $threshold" >> "$threshold_config_file" + [[ -n "$homepage" ]] && echo "api_homepage = $homepage" >> "$xapi_config_file" - echo "config written to $file_path" + echo "config written to $xapi_config_file and threshold written to $threshold_config_file" return 0 } #echo "$(get_vlc_config_directory)" -write_config "$@" +configure "$@" diff --git a/xapi.lua b/xapi.lua index e909c9b..54ca289 100644 --- a/xapi.lua +++ b/xapi.lua @@ -15,13 +15,17 @@ local api_homepage = "" local api_userid = "" local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' local config_file_path = "" - +local threshold_file_path = "" +local threshold = 0.9 -- *************** Events ************ function activate() api_userid = get_uid() config_file_path = get_vlc_config_directory() .. "xapi-extension-config.txt" + threshold_file_path = get_vlc_config_directory() .. "xapi-threshold-config.txt" load_config(config_file_path) + load_threshold_config(threshold_file_path) + vlc.msg.info("threshold value is: "..threshold) vlc.msg.info("config_file_path: "..config_file_path) vlc.msg.info("UID is: " .. api_userid) show_api_settings_dialog() @@ -169,6 +173,23 @@ function load_config(file_path) end end +function load_threshold_config(file_path) + local config = read_config(file_path) + if config then + for key, value in pairs(config) do + if key == "threshold" then + threshold = tonumber(value) + else + vlc.msg.err("Unknown threshold config. setting threshold to default (0.9)") + threshold = 0.9 + end + end + else + vlc.msg.err("Unable to load threshold config. setting threshold to default (0.9)") + threshold = 0.9 + end +end + function write_config(config, file_path) -- Open the file for writing ("w" overwrites the file) local file = io.open(file_path, "w") From 223fa3cee29f799df9ec91cfb642c96f247cb1fb Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Mon, 14 Oct 2024 11:41:21 -0400 Subject: [PATCH 04/13] updated docs for script --- scripts/configure.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/configure.sh b/scripts/configure.sh index 552ff65..0af0b70 100755 --- a/scripts/configure.sh +++ b/scripts/configure.sh @@ -51,7 +51,7 @@ configure() { homepage="$OPTARG" ;; *) - echo "Usage: $0 -k -s -u -t " + echo "Usage: $0 -k -s -u -t -h " exit 1 ;; esac From b385398f4cba954609b79443e37adc7e31f551fe Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Mon, 14 Oct 2024 11:41:41 -0400 Subject: [PATCH 05/13] added condition for completion --- xapi.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xapi.lua b/xapi.lua index 54ca289..a55eea5 100644 --- a/xapi.lua +++ b/xapi.lua @@ -305,6 +305,9 @@ function form_statement(args) local duration = args.duration local progress = args.progress local current_time = args.current_time + if progress >= threshold then + status = "complete" + end local base_url = "https://yet.systems/xapi/profiles/vlc" local verb = base_url .. "/verbs/" .. status local activity_url = base_url .. "/activity" From 8a0e40ad51fae4c532ae575a3b176201411d0f15 Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Mon, 14 Oct 2024 11:45:18 -0400 Subject: [PATCH 06/13] converting progress to numeric value --- xapi.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xapi.lua b/xapi.lua index a55eea5..361ad2c 100644 --- a/xapi.lua +++ b/xapi.lua @@ -303,7 +303,7 @@ function form_statement(args) local title = args.title local status = args.status local duration = args.duration - local progress = args.progress + local progress = tonumber(args.progress) local current_time = args.current_time if progress >= threshold then status = "complete" From feecd339fe01731df60cf2466dd103dbeb24646b Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Tue, 15 Oct 2024 11:50:55 -0400 Subject: [PATCH 07/13] added "is_completed" state --- xapi.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xapi.lua b/xapi.lua index 361ad2c..9b99f45 100644 --- a/xapi.lua +++ b/xapi.lua @@ -17,6 +17,7 @@ local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' local config_file_path = "" local threshold_file_path = "" local threshold = 0.9 +local is_completed = false -- *************** Events ************ function activate() @@ -42,6 +43,7 @@ end function input_changed() vlc.msg.info("[Now Playing] input_changed") + is_completed = false end function playing_changed() @@ -305,11 +307,14 @@ function form_statement(args) local duration = args.duration local progress = tonumber(args.progress) local current_time = args.current_time - if progress >= threshold then - status = "complete" - end local base_url = "https://yet.systems/xapi/profiles/vlc" local verb = base_url .. "/verbs/" .. status + + -- Override verb if we get a completion + if is_completed and progress >= threshold then + verb = base_url .. "/verbs/complete" + is_completed = true + end local activity_url = base_url .. "/activity" local video_url = activity_url .. "/video" local object = video_url .. "/" .. title @@ -317,6 +322,7 @@ function form_statement(args) local duration_url = extension_url .. "duration" local progress_url = extension_url .. "progress" local current_time_url = extension_url .. "currentTime" + local status_url = extension_url .. "status" -- Manually construct the JSON string with results local json_statement = @@ -339,6 +345,7 @@ function form_statement(args) '"extensions": {' .. '"' .. duration_url .. '": ' .. duration .. ',' .. '"' .. progress_url .. '": ' .. progress .. ',' .. + '"' .. status_url .. '": ' .. status .. ',' .. '"' .. current_time_url .. '": ' .. current_time .. '}' .. '}' .. @@ -366,7 +373,7 @@ function post_request(json_body) -- Encode API key and secret as Base64 for Basic Auth local auth = "Basic " .. base64_encode(api_key .. ":" .. api_secret) -- Construct the curl command to make the HTTP POST request - local command = 'curl -X POST ' .. api_url .. ' ' + local command = 'curl -X POST ' .. api_url .. '/statements ' .. '-H "Content-Type: application/json" ' .. '-H "Authorization: ' .. auth .. '" ' .. '-H "X-Experience-API-Version: 1.0.3" ' From e21a8edf53a761ac07e6b75062da857b3a3a36af Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Tue, 15 Oct 2024 13:25:36 -0400 Subject: [PATCH 08/13] fixed is_completed condition --- xapi.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xapi.lua b/xapi.lua index 9b99f45..8615251 100644 --- a/xapi.lua +++ b/xapi.lua @@ -311,7 +311,7 @@ function form_statement(args) local verb = base_url .. "/verbs/" .. status -- Override verb if we get a completion - if is_completed and progress >= threshold then + if is_completed == false and progress >= threshold then verb = base_url .. "/verbs/complete" is_completed = true end From 3c59de4b0a56f58539fd21a281ee578b4baf2c62 Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Wed, 16 Oct 2024 12:38:00 -0400 Subject: [PATCH 09/13] added config params to Makefile --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 39a6422..ca84a50 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,15 @@ -.PHONY: install +.PHONY: install configure + +configure: + @chmod +x scripts/configure.sh + @scripts/configure.sh -t $(THRESHOLD) -k $(API_KEY) -s $(API_SECRET) -u $(API_URL) -h $(API_HOMEPAGE) install: @chmod +x scripts/install.sh @scripts/install.sh + +THRESHOLD ?= 0.9 +API_KEY ?= username +API_SECRET ?= password +API_URL ?= http://localhost:8080/xapi +API_HOMEPAGE ?= http://yetanalytics.com From 1d53ac23914c49da070b328c5c168aa275475f68 Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Wed, 16 Oct 2024 12:51:16 -0400 Subject: [PATCH 10/13] fixed missing quotes around status --- xapi.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xapi.lua b/xapi.lua index 8615251..280ca4d 100644 --- a/xapi.lua +++ b/xapi.lua @@ -345,7 +345,7 @@ function form_statement(args) '"extensions": {' .. '"' .. duration_url .. '": ' .. duration .. ',' .. '"' .. progress_url .. '": ' .. progress .. ',' .. - '"' .. status_url .. '": ' .. status .. ',' .. + '"' .. status_url .. '": "' .. status .. '",' .. '"' .. current_time_url .. '": ' .. current_time .. '}' .. '}' .. From 26cf1adb146e0fd8cd3b6ce5e88f3a956e63ca3f Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Wed, 16 Oct 2024 13:04:31 -0400 Subject: [PATCH 11/13] added `make configure` to README --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a356ee5..038425c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,13 @@ An XAPI integrated VLC player ### Setup +0) (optional) `make configure` will setup the configuration files for the plugin. to override defaults, run the command with the appropriate overrides. Example being: `make configure THRESHOLD=0.87`. The following is a list of variables and what they mean. + - `THRESHOLD` - Decimal value between 0 and 1 that represents point in video considered a completion. Once a video reaches this threshold, the plugin will issue a completion statement + - `API_KEY` - API key for LRS + - `API_SECRET` - API Secret for LRS + - `API_URL` - API Url for LRS + - `API_HOMEPAGE` - system that identifies user. In the statement this is set at `actor.account.homePage`. + 1) Run `make install` . This will move the plugin into the appropriate directory for VLC. 2) Open VLC. when you do, click on the view dropdown and click 'xAPI Integration.' 3) Enter the fields in the form: @@ -11,7 +18,7 @@ An XAPI integrated VLC player - Homepage URL: Domain specific URL to identify from which system the user is located - API Key: Key for LRS - API Secret: Secret for LRS -- API URL: URL for lrs (example: http://localhost:8080/xapi/statements) +- API URL: URL for LRS (example: http://localhost:8080/xapi) 4) Play a video of your choice and verify the data is flowing from the LRS. From 749fd2810f2662f67f42b3485070ee2b2ff59a52 Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Wed, 16 Oct 2024 13:14:00 -0400 Subject: [PATCH 12/13] changed api_url to api_endpoint --- Makefile | 4 ++-- README.md | 2 +- scripts/configure.sh | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ca84a50..08e9fc6 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ configure: @chmod +x scripts/configure.sh - @scripts/configure.sh -t $(THRESHOLD) -k $(API_KEY) -s $(API_SECRET) -u $(API_URL) -h $(API_HOMEPAGE) + @scripts/configure.sh -t $(THRESHOLD) -k $(API_KEY) -s $(API_SECRET) -u $(API_ENDPOINT) -h $(API_HOMEPAGE) install: @chmod +x scripts/install.sh @@ -11,5 +11,5 @@ install: THRESHOLD ?= 0.9 API_KEY ?= username API_SECRET ?= password -API_URL ?= http://localhost:8080/xapi +API_ENDPOINT ?= http://localhost:8080/xapi API_HOMEPAGE ?= http://yetanalytics.com diff --git a/README.md b/README.md index 4e5dcfc..600f98c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ An XAPI integrated VLC player - `THRESHOLD` - Decimal value between 0 and 1 that represents point in video considered a completion. Once a video reaches this threshold, the plugin will issue a completion statement - `API_KEY` - API key for LRS - `API_SECRET` - API Secret for LRS - - `API_URL` - API Url for LRS + - `API_ENDPOINT` - API Endpoint for LRS - `API_HOMEPAGE` - system that identifies user. In the statement this is set at `actor.account.homePage`. 1) Run `make install` . This will move the plugin into the appropriate directory for VLC. diff --git a/scripts/configure.sh b/scripts/configure.sh index 0af0b70..6246887 100755 --- a/scripts/configure.sh +++ b/scripts/configure.sh @@ -28,7 +28,7 @@ configure() { # Variables to store the required options local api_key="" local api_secret="" - local api_url="" + local api_endpoint="" local threshold="" local homepage="" @@ -42,7 +42,7 @@ configure() { api_secret="$OPTARG" ;; u) - api_url="$OPTARG" + api_endpoint="$OPTARG" ;; t) threshold="$OPTARG" @@ -51,7 +51,7 @@ configure() { homepage="$OPTARG" ;; *) - echo "Usage: $0 -k -s -u -t -h " + echo "Usage: $0 -k -s -u -t -h " exit 1 ;; esac @@ -61,7 +61,7 @@ configure() { # Debugging: Output parsed values echo "API Key: $api_key" echo "API Secret: $api_secret" - echo "API URL: $api_url" + echo "API URL: $api_endpoint" echo "Threshold: $threshold" echo "API Homepage: $homepage" @@ -69,7 +69,7 @@ configure() { # Write the key-value pairs to the file, only if they exist [[ -n "$api_key" ]] && echo "api_key = $api_key" >> "$xapi_config_file" [[ -n "$api_secret" ]] && echo "api_secret = $api_secret" >> "$xapi_config_file" - [[ -n "$api_url" ]] && echo "api_url = $api_url" >> "$xapi_config_file" + [[ -n "$api_endpoint" ]] && echo "api_endpoint = $api_endpoint" >> "$xapi_config_file" [[ -n "$threshold" ]] && echo "threshold = $threshold" >> "$threshold_config_file" [[ -n "$homepage" ]] && echo "api_homepage = $homepage" >> "$xapi_config_file" From 8b197b7835720caee3937eb49e7d09c79feac18b Mon Sep 17 00:00:00 2001 From: Henk Reder Date: Fri, 18 Oct 2024 12:06:51 -0400 Subject: [PATCH 13/13] hardcoded threshold to not go above 0.98 --- xapi.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xapi.lua b/xapi.lua index 615ec9a..c10efcf 100644 --- a/xapi.lua +++ b/xapi.lua @@ -181,6 +181,12 @@ function load_threshold_config(file_path) for key, value in pairs(config) do if key == "threshold" then threshold = tonumber(value) + + -- if someone sets the threshold too high it may never issue a completion + if threshold >= 0.98 then + threshold = 0.98 + end + else vlc.msg.err("Unknown threshold config. setting threshold to default (0.9)") threshold = 0.9