From 95471a8bd8ffece38c4fafeccb8fe1f848611c43 Mon Sep 17 00:00:00 2001 From: coolnsx Date: Fri, 6 Oct 2023 16:53:16 +0530 Subject: [PATCH] feat: better config loading --- screen | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/screen b/screen index eda6b9f..85d9e76 100755 --- a/screen +++ b/screen @@ -13,7 +13,7 @@ menu() { compress() { duration=$(ffprobe -hide_banner -i "$tmp_file" 2>&1 | sed -nE 's|.*Duration: ([^,]*).*|\1|p') - i=19 + i=20 while :; do ffmpeg -loglevel error -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i "$tmp_file" -vf 'format=nv12,hwupload' -c:v h264_vaapi -qp "$i" "$process_file" -y -progress - | while read -r line; do @@ -61,20 +61,32 @@ stop() { ;; *nextcloud) - info "icloud" "" "Uploading to NextCloud" #shellcheck disable=SC1091 . "$HOME"/.secrets + + #load nextcloud creds only + load_nextcloud_creds + cloudname="screenrecord-$(date +"%F_%H-%M-%S").mp4" #upload to nextcloud instance, universal code - curl -s "$NC_HOST/remote.php/dav/files/${NC_USER}${NC_FOLDER_PATH}/$cloudname" -u "$NC_USER:$NC_PASS" -T "$tmp_file" && curl -u "$NC_USER:$NC_PASS" "$NC_HOST/ocs/v2.php/apps/files_sharing/api/v1/shares" -H 'content-type: application/json' -H 'accept: application/json, text/plain, */*' -H 'OCS-APIRequest: true' --data-raw "{\"path\":\"${NC_FOLDER_PATH}/$cloudname\",\"shareType\":3,\"attributes\":\"[]\"}" | sed -nE 's|.*"url":"([^"]*)".*|\1|p' | sed 's/\\//g' | wl-copy && info "com.github.davidmhewitt.clipped" "2000" "uploaded and copied link to clipboard" && return 0 - info "" "2000" "Unable to upload to Nextcloud,moved the file from temp to your home folder as .mp4" && mv "$tmp_file" "$HOME/$(date +%s).mp4" && return 1 + info "nextcloud" "10000" "Uploading to NextCloud" + curl -s "$NC_HOST/remote.php/dav/files/${NC_USER}${NC_FOLDER_PATH}/$cloudname" -H "Authorization: Basic $NC_AUTH" -T "$tmp_file" || (info "" "2000" "Unable to upload to Nextcloud,moved the file from temp to your home folder as $cloudname" && mv "$tmp_file" "$HOME/$cloudname" && return 1) + info "nextcloud" "" "Getting File Id" + file_id=$(curl -s "$NC_HOST/remote.php/dav/files/${NC_USER}${NC_FOLDER_PATH}" -X 'PROPFIND' -H "Authorization: Basic $NC_AUTH" --data-raw '' | sed 's|d:response|\n|g' | sed -nE "s|.*.*$cloudname.*([^<]*).*|\1|p" | head -1) + [ "$file_id" = "$NC_FOLDER_ID" ] && file_id="" + info "nextcloud" "10000" "Setting Retention Policy & Generating Share Link" + curl -sX PUT "$NC_HOST/remote.php/dav/systemtags-relations/files/$file_id/1" -H "Authorization: Basic $NC_AUTH" -: -s -H "Authorization: Basic $NC_AUTH" "$NC_HOST/ocs/v2.php/apps/files_sharing/api/v1/shares" -H 'content-type: application/json' -H 'accept: application/json, text/plain, */*' -H 'OCS-APIRequest: true' --data-raw "{\"path\":\"${NC_FOLDER_PATH}/$cloudname\",\"shareType\":3,\"attributes\":\"[]\"}" | sed -nE 's|.*"url":"([^"]*)".*|\1|p' | sed 's/\\//g' | wl-copy && info "com.github.davidmhewitt.clipped" "2000" "Share Link Created and copied to clipboard" ;; *discord) #shellcheck disable=SC1091 . "$HOME"/.secrets + + #load discord creds only + load_discord_creds + base_url="https://discord.com/api/v10" channel=$(curl -s "$base_url/guilds/$SERVER_ID/channels" -H "Authorization: $TOKEN" | tr '{}' '\n' | sed -nE 's|.*"id":"([^"]*)".*last_message_id.*"name":"([^"]*)".*|\1\t\2|p' | menu "Select Channel: ")