sanitize file name output
This commit is contained in:
parent
16f39a3f5c
commit
19d0fe69ed
30
bookmobile
30
bookmobile
|
@ -72,11 +72,33 @@ function set_metadata
|
|||
set -g title (readable $url --properties "title")
|
||||
|
||||
if test -z "$title" #if title was empty, set title to date time
|
||||
set -g title (date "+%Y-%m-%d_%H:%M:%S")
|
||||
end
|
||||
|
||||
echo "Title: " $title
|
||||
echo "URL: " $url
|
||||
set -g title (date "+%Y-%m-%d_%H:%M:%S")
|
||||
|
||||
else
|
||||
#clean up title
|
||||
|
||||
#stop a title at first : or - or • or | or (
|
||||
set -g title (string split ":" $title)[1]
|
||||
set -g title (string split " -" $title)[1] #split if - used to break up a title, not between 2 words
|
||||
set -g title (string split "|" $title)[1]
|
||||
set -g title (string split "•" $title)[1]
|
||||
set -g title (string split "(" $title)[1]
|
||||
#set -g title (echo $temp_title | sed 's/[:(-•|]/\n/g')[1]
|
||||
|
||||
#remove leading and trailing spaces
|
||||
set -g title (string trim $title)
|
||||
|
||||
#convert remaining spaces to _ underscores
|
||||
set -g title (string replace -a ' ' '_' $title)
|
||||
|
||||
#remove ,'? from title
|
||||
set -g title (string replace -r -a '[?,\'\"]' '' $title)
|
||||
|
||||
#limit length to 35 characters (arbitrarily selected but a prudent length)
|
||||
set -g title (string sub --length 35 $title)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function process_article
|
||||
|
|
Loading…
Reference in New Issue