Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add script to check if lead picture is not equal the favicon and if t… #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions check-lead-picture.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

set -eu

lang="en es ja cz fr pt pl de it ko zh tr cn"

if ! cmd=$(command -v curl)
then
echo "please install curl"
exit 1
fi

if (( $# == 0 ))
then
feed="https://weeklyosm.eu/feed"
article_id=$(curl -Ls "$feed" | grep "<link>https://weeklyosm.eu/archives/" | head -n 1 | cut -d "<" -f 2 | grep -o '[^/]*$')
else
article_id=$1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are calling our script with parameters - so I guess this would always go this path. $1 would be the first parameter, which is not the article id at the moment.

fi
echo "checking for weekly https://weeklyosm.eu/archives/$article_id"

exit_code=0
for i in $lang
do
article_url="https://weeklyosm.eu/$i/archives/$article_id"
sourcecode=$(curl -Ls "$article_url")
echo "$sourcecode" | grep "og:image" | grep "favicon" > /dev/random && echo "wrong share image for language $i in $article_url"
no_of_leadpics=$(echo "$sourcecode" | grep 'alt="lead picture"' | wc -l)
if [ $no_of_leadpics -ge 2 ]
then
echo "more than one lead picture ($no_of_leadpics) found for language $i in $article_url"
exit_code=2
fi
done

exit $exit_code

2 changes: 2 additions & 0 deletions runenvweekly2all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
set -e
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a bash pro - but would that mean also the actual notification script would abort on error? For example if an error is thrown, because a telegram group removed permissions for our bot?

bash check-lead-picture.sh
source spamenv/bin/activate
export PYTHONIOENCODING="UTF-8"
export LC_CTYPE="C.UTF-8"
Expand Down