reverted flake
This commit is contained in:
67
gdl/gdl_log_report
Executable file
67
gdl/gdl_log_report
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
mkdir -p /dev/shm/logs
|
||||
|
||||
set logs (journalctl --user -e -n 99999 \
|
||||
-u download@\* \
|
||||
-u instagram@\* \
|
||||
--no-pager \
|
||||
| string replace -r \
|
||||
"(^.*)(workstation download\[\d+\]\: )" "" \
|
||||
| grep -F \[error\] -B 1)
|
||||
|
||||
for i in (seq 1 (count $logs))
|
||||
set -l log $logs[$i]
|
||||
if test (string match -r "\[error\]" $log)
|
||||
if test (string match -r \
|
||||
"NotFoundError\: Twitter suspends accounts" \
|
||||
$log)
|
||||
set -a filter_suspended $i
|
||||
else if test (string match -r \
|
||||
"Tweets are protected" $log)
|
||||
set -a filter_protected $i
|
||||
else if test (string match -r \
|
||||
"Requested user could not be found" $log)
|
||||
set -a filter_missing $i
|
||||
else if test (string match -r \
|
||||
"\[instagram\]\[error\] HttpError\: \'404 Not Found\'" $log)
|
||||
set -a filter_missing $i
|
||||
else if test (string match -r \
|
||||
"Unable to retrieve Tweets from this timeline" $log)
|
||||
set -a filter_empty $i
|
||||
else
|
||||
set -a filter_others $i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function _print_accounts -a filter_name --inherit-variable logs
|
||||
set i_list $argv[3..-1]
|
||||
for i in $i_list
|
||||
set regex "\[\d+\/\d+\] "
|
||||
set log $logs[(math $i-1)]
|
||||
if test (string match -r $regex $log)
|
||||
string replace -r $regex "" $log >>/dev/shm/logs/$filter_name
|
||||
end
|
||||
end
|
||||
if test -e /dev/shm/logs/$filter_name
|
||||
echo "The following accounts are $filter_name:"
|
||||
for line in (cat /dev/shm/logs/$filter_name | sort | uniq)
|
||||
echo "- " $line
|
||||
end
|
||||
echo ""
|
||||
end
|
||||
end
|
||||
|
||||
_print_accounts suspended $filter_suspended
|
||||
_print_accounts protected $filter_protected
|
||||
_print_accounts missing $filter_missing
|
||||
_print_accounts empty $filter_empty
|
||||
|
||||
echo "The following accouns have other errors:"
|
||||
for i in $filter_others
|
||||
echo $logs[(math $i-1)]
|
||||
echo $logs[$i]
|
||||
end
|
||||
|
||||
command rm -rf /dev/shm/logs
|
||||
68
gdl/gdl_log_report.sh
Executable file
68
gdl/gdl_log_report.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i fish -p fish fd ripgrep gum
|
||||
|
||||
mkdir -vp /dev/shm/logs
|
||||
|
||||
set logs (journalctl --user -e -n 99999 \
|
||||
-u download@\* \
|
||||
-u instagram@\* \
|
||||
--no-pager \
|
||||
| string replace -r \
|
||||
"(^.*)(workstation download\[\d+\]\: )" "" \
|
||||
| grep -F \[error\] -B 1)
|
||||
|
||||
for i in (seq 1 (count $logs))
|
||||
set -l log $logs[$i]
|
||||
if test (string match -r "\[error\]" $log)
|
||||
if test (string match -r \
|
||||
"NotFoundError\: Twitter suspends accounts" \
|
||||
$log)
|
||||
set -a filter_suspended $i
|
||||
else if test (string match -r \
|
||||
"Tweets are protected" $log)
|
||||
set -a filter_protected $i
|
||||
else if test (string match -r \
|
||||
"Requested user could not be found" $log)
|
||||
set -a filter_missing $i
|
||||
else if test (string match -r \
|
||||
"\[instagram\]\[error\] HttpError\: \'404 Not Found\'" $log)
|
||||
set -a filter_missing $i
|
||||
else if test (string match -r \
|
||||
"Unable to retrieve Tweets from this timeline" $log)
|
||||
set -a filter_empty $i
|
||||
else
|
||||
set -a filter_others $i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function _print_accounts -a filter_name --inherit-variable logs
|
||||
set i_list $argv[3..-1]
|
||||
for i in $i_list
|
||||
set regex "\[\d+\/\d+\] "
|
||||
set log $logs[(math $i-1)]
|
||||
if test (string match -r $regex $log)
|
||||
string replace -r $regex "" $log >>/dev/shm/logs/$filter_name
|
||||
end
|
||||
end
|
||||
if test -e /dev/shm/logs/$filter_name
|
||||
echo "The following accounts are $filter_name:"
|
||||
for line in (cat /dev/shm/logs/$filter_name | sort | uniq)
|
||||
echo "- " $line
|
||||
end
|
||||
echo ""
|
||||
end
|
||||
end
|
||||
|
||||
_print_accounts suspended $filter_suspended
|
||||
_print_accounts protected $filter_protected
|
||||
_print_accounts missing $filter_missing
|
||||
_print_accounts empty $filter_empty
|
||||
|
||||
echo "The following accouns have other errors:"
|
||||
for i in $filter_others
|
||||
echo $logs[(math $i-1)]
|
||||
echo $logs[$i]
|
||||
end
|
||||
|
||||
command rm -rf /dev/shm/logs
|
||||
68
gdl/gdl_mv
Executable file
68
gdl/gdl_mv
Executable file
@@ -0,0 +1,68 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i fish -p fish
|
||||
|
||||
|
||||
set d_parent '/srv/disk2/scrapping/JawZ'
|
||||
set d_gdl 'gallery-dl'
|
||||
set d_gdl_filtered 'organized'
|
||||
|
||||
function _get_parent
|
||||
dirname (dirname $argv[1])
|
||||
end
|
||||
function _replace_path
|
||||
string replace $argv[1] $argv[2] $argv[3]
|
||||
end
|
||||
|
||||
function _mv_files -a d
|
||||
for f in (find $d -type f)
|
||||
set f_name (basename $f)
|
||||
|
||||
# Search for video files
|
||||
if test (string match -r "\.mp4|\.webm\$" $f_name)
|
||||
set f_dest (dirname $f)/Videos/(basename $f)
|
||||
# Loop until the parent directory isn't named Videos|mp4
|
||||
while test (string match -r "Videos|mp4" (basename (_get_parent $f_dest)))
|
||||
set f_dest (_get_parent $f_dest)/(basename $f_dest)
|
||||
end
|
||||
# Place videos in their own subdirectory
|
||||
set f_dest (_replace_path $d_gdl $d_gdl_filtered $f_dest)
|
||||
else # Not a video file
|
||||
set f_dest (_replace_path $d_gdl $d_gdl_filtered $f)
|
||||
echo $f_dest
|
||||
end
|
||||
|
||||
set d_dest (dirname $f_dest)
|
||||
# Strip dirname for logging
|
||||
set d_name (string replace $d_parent "" $d_dest)
|
||||
# Check if destination exists
|
||||
if test ! -e $d_dest
|
||||
echo (set_color green)$d_name(set_color normal) \
|
||||
"Doesn't exist, creating..."
|
||||
mkdir -p $d_dest
|
||||
end
|
||||
|
||||
# If destination exists, and basename isn't duplicated
|
||||
if test \( -e $d_dest \) -a \( (basename $f) = (basename $f_dest) \)
|
||||
echo "Moving the file" (set_color green)$f_name(set_color normal) \
|
||||
into (set_color green)$d_name(set_color normal)
|
||||
echo "Original path:"
|
||||
echo (set_color brblue)$f(set_color normal)
|
||||
echo "New path:"
|
||||
echo (set_color brblue)$f_dest | grep -F "$d_name"
|
||||
echo (set_color yellow)__________________________________(set_color normal)
|
||||
# Move files
|
||||
mv $f $f_dest
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# TEST IF THE SCRIPT RAN WITH ARGUMENTS
|
||||
if test -z "$argv[1]"
|
||||
echo "Please drag a few directories!"
|
||||
# _mv_files $d_gdl false
|
||||
end
|
||||
if test -n "$argv[1]"
|
||||
for d in $argv
|
||||
_mv_files $d true
|
||||
end
|
||||
end
|
||||
33
gdl/gdl_mv.sh
Executable file
33
gdl/gdl_mv.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#! /nix/store/kxkdrxvc3da2dpsgikn8s2ml97h88m46-bash-interactive-5.2-p15/bin/bash
|
||||
#! nix-shell -i bash -p bash fd ripgrep
|
||||
|
||||
base_directory='/srv/disk2/scrapping/JawZ'
|
||||
gdl_directory=$base_directory/gallery-dl
|
||||
filtered_directory=$base_directory/organized
|
||||
|
||||
move_files() {
|
||||
orig_file=$(realpath "$1")
|
||||
|
||||
dest_file=${orig_file//$gdl_directory/$filtered_directory}
|
||||
dest_dir=$(realpath "$(dirname "$dest_file")")
|
||||
|
||||
mkdir -vp "$dest_dir"
|
||||
command mv -in "$orig_file" "$dest_dir"
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Please drag a few directories or files!"
|
||||
else
|
||||
for arg in "$@"; do
|
||||
if [ -d "$arg" ]; then
|
||||
while IFS= read -r file; do
|
||||
move_files "$file"
|
||||
done < <(fd . "$arg" -tf)
|
||||
elif [ -f "$arg" ]; then
|
||||
move_files "$arg"
|
||||
else
|
||||
echo "It's neither a file or a directory"
|
||||
echo "Please check your input"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
16
gdl/track_files.fish
Normal file
16
gdl/track_files.fish
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
function _update_count
|
||||
count (find ~/Pictures/To\ Organize/gdl-organizing/ -type f)
|
||||
end
|
||||
|
||||
function track_files -a goal
|
||||
set -f original_count (_update_count)
|
||||
while test (_update_count) -ge $goal
|
||||
echo "Currently there are:" \
|
||||
(set_color red)(_update_count)(set_color normal)
|
||||
echo Delete (set_color green)(math (_update_count) - $goal)(set_color normal) "more files to finish"
|
||||
sleep 10
|
||||
clear
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user