1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
#!/bin/sh
: "${YTFZF_GUI_CSS:=$YTFZF_CONFIG_DIR/interface-gui.css}"
display_text_gui () {
MAIN_DIALOG="
<window>
<edit>
<width>500</width>
<height>500</height>
<default>$*</default>
</edit>
</window>" gtkdialog
}
info_wait_prompt_gui () {
:
}
gui_dialog () {
css_file="${session_temp_dir}/gtk.css"
if [ -f "$YTFZF_GUI_CSS" ]; then
css_file="$YTFZF_GUI_CSS"
else
: > "$css_file"
fi
export MAIN_DIALOG="<window><vbox scrollable=\"true\" vscrollbar-policy=\"0\">"
urls="$(jq -r '.url')"
while read -r url; do
_correct_json="$(jq -r --arg url "$url" '[.[]|select(.url==$url)]|unique_by(.ID)[0]' < "$video_json_file")"
id="$(_get_video_json_attr "ID")"
title="$(_get_video_json_attr "title")"
channel="$(_get_video_json_attr "channel")"
views="$(_get_video_json_attr "views" | add_commas)"
date="$(_get_video_json_attr "date")"
scraper="$(_get_video_json_attr "scraper")"
duration="$(_get_video_json_attr "duration")"
description="$(_get_video_json_attr "description" | sed 's/\\n/\n/g')"
unset IFS
for path in "${YTFZF_CUSTOM_THUMBNAILS_DIR}/$id.jpg" "${thumb_dir}/${id}.jpg" "${YTFZF_CUSTOM_THUMBNAILS_DIR}/YTFZF:DEFAULT.jpg"; do
thumb_path="$path"
[ -f "${thumb_path}" ] && break
done
export MAIN_DIALOG="$MAIN_DIALOG
<hbox>
<vbox>
<text name=\"TitleText\">
<label>$title (@$channel)</label>
</text>
<text name=\"ViewsText\">
<label>$views views</label>
</text>
<text name=\"DateText\">
<label>uploaded: $date</label>
</text>
<text name=\"DurationText\">
<label>duration: $duration</label>
</text>
<button name=\"UrlButton\">
<label>$url</label>
</button>
</vbox>
<pixmap name=\"Thumbnail\">
<width>400</width>
<input file>$thumb_path</input>
</pixmap>
</hbox>"
done <<-EOF
$urls
EOF
export MAIN_DIALOG="$MAIN_DIALOG</vbox></window>"
if gtkdialog -h 2> /dev/null | grep -q -- '--styles'; then
MAIN_DIALOG=$MAIN_DIALOG gtkdialog --styles "$css_file"
else
MAIN_DIALOG=$MAIN_DIALOG gtkdialog
fi
}
interface_gui () {
video_json_file="$1"
selected_id_file="$2"
command_exists "gtkdialog" || die 3 "gtkdialog (https://github.com/puppylinux-woof-CE/gtkdialog) is required for the gui interface\n"
create_sorted_video_data | gui_dialog | sed -n -e 's/EXIT="\(.*\)"/\1/p' -e 's/[[:space:]]*//g' > "$selected_id_file"
while read -r line; do
[ "$line" = "abort" ] && exit 0
done < "$selected_id_file"
}
print_help_gui (){
print_info "YTFZF_GUI_CSS is a file for custom css for the window\nselectors:\n#TitleText\n#ViewsText\n#DateText\n#DurationText\n#UrlButton\n#Thumbnail\n"
exit 0
}
search_prompt_menu_gui () {
vars=$(MAIN_DIALOG="
<window>
<vbox>
<entry>
<default>Search...</default>
<variable>SEARCH</variable>
</entry>
<button>
<label>Search!</label>
</button>
</vbox>
</window>" gtkdialog)
while read -r line; do
case "$line" in
*SEARCH*)
_search=$(printf "%s" "$line" | tr -d '"')
_search="${_search#*=}" ;;
EXIT*) break ;;
esac
done <<-EOF
$vars
EOF
}
|