forked from krywenko/all-recipe-skill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFAV
35 lines (26 loc) · 1.12 KB
/
FAV
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
#!/bin/bash
URL="$( echo -e $1 | sed 's/\?.*//' )"
#echo $1
#echo $URL
FILE="$( echo -e $URL | tr '/' ' ' | awk '{print $NF}' )"
#echo $FILE
TITLE="$( echo $FILE | tr '-' ' ' )"
#echo $TITLE
LINE="'$TITLE': join(abspath(dirname(__file__)), 'recipes', '$FILE'),"
#echo $LINE
NO_WHITESPACE="$(echo -e "${LINE}" | tr -d '[:space:]')"
DATA="$(grep "'$TITLE': join(abspath(dirname(__file__)), 'recipes', '$FILE')," $HOME/mycroft-core/skills/all-recipes-skill/__init__.py) "
NO_WHITESPACE1="$(echo -e "${DATA}" | tr -d '[:space:]')"
#echo $DATA
#echo $NO_WHITESPACE
if [[ $NO_WHITESPACE1 == $NO_WHITESPACE ]]
then
echo "exist already "
else
sed -i "/^ self.play_list = {/a\ $LINE" $HOME/mycroft-core/skills/all-recipes-skill/__init__.py
echo $TITLE >> $HOME/mycroft-core/skills/all-recipes-skill/vocab/en-us/title.entity
echo Saving to $HOME/mycroft-core/skills/all-recipes-skill/recipes/$FILE
$HOME/mycroft-core/skills/all-recipes-skill/process_recipe $URL |
sed "1s/^/$TITLE\n\n /" > $HOME/mycroft-core/skills/all-recipes-skill/recipes/$FILE
#sed -i "1s/^/$TITLE\n\n /" $HOME/AllRecipes/$FILE
fi