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

Create special-editions.txt #6

Merged
merged 13 commits into from
Jul 28, 2020
6 changes: 3 additions & 3 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
name: LINTERS

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
# events but only for the main branch
on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
# events but only for the main branch
on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down Expand Up @@ -48,18 +48,20 @@ jobs:
- name: Download Issues with start and end limit
id: normalIssuesWithRange
run: bash ./wireframe-downloader.sh -f 39 -l 40
- name: Download all special ediations
id: downloadSpecial-Editions
run: bash ./wireframe-books-downloader.sh
- name: "Check file existence Linux"
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "issues/WF_02_Digital_Edition_v3.pdf, issues/Wireframe40.pdf"
files: "issues/WF_02_Digital_Edition_v3.pdf, issues/Wireframe40.pdf, special-issues/Code_the_Classics-book.pdf, special-issues/Wireframe_BYOFPS.pdf"
allow_failure: false
- name: lslah
run: ls -lah issues/
- name: File exists
if: steps.check_files.outputs.files_exists == 'false'
run: exit 1

bash-macos:
runs-on: macos-latest
steps:
Expand All @@ -70,15 +72,17 @@ jobs:
- name: Download Issues with start and end limit
id: normalIssuesWithRange
run: bash ./wireframe-downloader.sh -f 39 -l 40
- name: Download all special ediations
id: downloadSpecial-Editions
run: bash ./wireframe-books-downloader.sh
- name: "Check file existence mac"
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "issues/WF_02_Digital_Edition_v3.pdf, issues/Wireframe40.pdf"
files: "issues/WF_02_Digital_Edition_v3.pdf, issues/Wireframe40.pdf, special-issues/Code_the_Classics-book.pdf, special-issues/Wireframe_BYOFPS.pdf"
allow_failure: false
- name: lslah
run: ls -lah issues/
- name: File exists
if: steps.check_files.outputs.files_exists == 'false'
run: exit 1

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.idea
issues
**.pdf
issues
2 changes: 2 additions & 0 deletions special-editions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://wireframe.raspberrypi.org/books/code-the-classics1/pdf
https://wireframe.raspberrypi.org/books/unity-fps/pdf
26 changes: 26 additions & 0 deletions wireframe-books-downloader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# ------------------------------------------------------------------
# [Author] joergi - https://github.com/joergi/WireframeDownloader
# downloader for all Wireframe magzine issues and books
# based on Magpi Downloader: https://github.com/joergi/MagpiDownloader
# they are downloadable for free under https://wireframe.raspberrypi.org/issues
# or you can buy the paper issues under: https://store.rpipress.cc/collections/wireframe
# this script is under GNU GENERAL PUBLIC LICENSE 3
# ------------------------------------------------------------------

# VERSION=0.2.0
# USAGE="Usage: bash wireframe-books-downloader.sh [-f firstissue] [-l lastissue]"

OUTDIR=special-issues

if [ ! -d "$OUTDIR" ]; then
mkdir "$OUTDIR"
fi

file="special-editions.txt"
while IFS= read -r line
do
bash <(curl https://raw.githubusercontent.com/joergi/downloader/main/linux_mac/downloader.sh) "$line" "$OUTDIR"
done < "$file"

exit 0
34 changes: 10 additions & 24 deletions wireframe-downloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,15 @@ if [ ! -d "$OUTDIR" ]; then
mkdir "$OUTDIR"
fi

i=1
file="$BASEDIR/regular-issues.txt";

issues=$(cat "$file");

while :
do
case "$1" in
-f) shift; i="$1";;
-l) shift; issues="$1";;
--) shift; break;;
-*) usage "bad argument $1";;
*) break;;
esac
shift
done

while [ "$i" -le "$issues" ]
do
printf -v page_url "https://wireframe.raspberrypi.org/issues/%02d/pdf" "$i"
pdf_url=$(curl -sf "$page_url" | grep \"c-link\" | sed 's/^.*href=\"//' | sed 's/\?.*$//')
wget -N "$pdf_url" -P "$OUTDIR"
i=$(( i+1 ))
done
downloadUrl="https://wireframe.raspberrypi.org/issues/%02d/pdf"

file="$BASEDIR/sources-for-download/regular-issues.txt";
recentIssue=$(cat "$file");

# workaround for a known limitation in bash 3.x: http://lists.gnu.org/archive/html/bug-bash/2006-01/msg00018.html
# stackoverflow: https://stackoverflow.com/questions/32596123/why-source-command-doesnt-work-with-process-substitution-in-bash-3-2/32596626#32596626
# shellcheck disable=SC1091
source /dev/stdin <<<"$(curl -s https://raw.githubusercontent.com/joergi/downloader/main/linux_mac/downloader.sh)" "$downloadUrl" "$OUTDIR" "$recentIssue" "$@"

exit 0