i thiiiiink download_file_list be workan-ish
This commit is contained in:
@@ -40,6 +40,7 @@ Install customscripts on linux with
|
|||||||
* `pyenv_setup`
|
* `pyenv_setup`
|
||||||
* `xrdp-start`
|
* `xrdp-start`
|
||||||
* `add_apache2_site`
|
* `add_apache2_site`
|
||||||
|
* `download_file_list`
|
||||||
|
|
||||||
### Windowwz
|
### Windowwz
|
||||||
#### git helpers
|
#### git helpers
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# manually created arrays for file types and extensions
|
# manually created arrays for file types and extensions
|
||||||
types_arr=('MPEG' 'JPEG' 'PNG' 'GIF' 'WebM' 'RIFF')
|
## notes: from twitter downloader mp4 files show as ISO?
|
||||||
exts_arr=('mp4' 'jpg' 'png' 'gif' 'webm' 'webp')
|
types_arr=('MPEG' 'ISO' 'JPEG' 'PNG' 'GIF' 'WebM' 'RIFF')
|
||||||
|
exts_arr=('mp4' 'mp4' 'jpg' 'png' 'gif' 'webm' 'webp')
|
||||||
tmp_file="$1/download.tmp"
|
tmp_file="$1/download.tmp"
|
||||||
|
|
||||||
# check for existance of $1 or if $2 is a file
|
# check for existance of $1 or if $2 is a file
|
||||||
@@ -20,8 +21,11 @@ fi
|
|||||||
# read the input file and loop through it
|
# read the input file and loop through it
|
||||||
cat "$2" | \
|
cat "$2" | \
|
||||||
while read line; do
|
while read line; do
|
||||||
|
# get default basename of downloaded file
|
||||||
|
file_basename=$(basename "$line")
|
||||||
|
|
||||||
# download the file to a tmp
|
# download the file to a tmp
|
||||||
echo "Downloading $line to $1"
|
echo "Downloading $line to $1/$file_basename"
|
||||||
curl -s -o "$tmp_file" "$line"
|
curl -s -o "$tmp_file" "$line"
|
||||||
|
|
||||||
# get the file type
|
# get the file type
|
||||||
@@ -39,11 +43,11 @@ cat "$2" | \
|
|||||||
if [[ "$item" == "$type" ]]; then
|
if [[ "$item" == "$type" ]]; then
|
||||||
# rename the downloaded file
|
# rename the downloaded file
|
||||||
new_name="$1/$namehash.$(echo ${exts_arr[$count]})"
|
new_name="$1/$namehash.$(echo ${exts_arr[$count]})"
|
||||||
echo "Renaming $tmp_file to $new_name"
|
echo -e "\tRenaming $file_basename to $new_name\n"
|
||||||
mv "$tmp_file" "$new_name"
|
mv "$tmp_file" "$new_name"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "$(basename $line) not a supported format: $type! Deleting"
|
echo -e "\n$file_basename not a supported format: $(file $tmp_file)! Deleting\n"
|
||||||
rm -f "$tmp_file"
|
rm -f "$tmp_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user