forked from krywenko/all-recipe-skill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecipe
40 lines (29 loc) · 1.33 KB
/
recipe
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
#!/bin/bash
INPUT=$(sed "$1!d" tmp_URL) ## e comment out 2nd and 3rd line and uncomment 3 to test web address formating
URL="$( echo -e $INPUT | 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
PIC="$(cat PIC_URL)"
wget -O $HOME/mycroft-core/skills/all-recipes-skill/recipes/pics/$FILE $PIC
#sed -i "1s/^/$TITLE\n\n /" $HOME/AllRecipes/$FILE
fi