diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index aae329c..8446c76 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -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: diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 638a9f6..71c6479 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -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: @@ -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: @@ -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 - diff --git a/.gitignore b/.gitignore index c741b1a..50dd1f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.idea -issues \ No newline at end of file +**.pdf +issues diff --git a/special-editions.txt b/special-editions.txt new file mode 100644 index 0000000..b86d086 --- /dev/null +++ b/special-editions.txt @@ -0,0 +1,2 @@ +https://wireframe.raspberrypi.org/books/code-the-classics1/pdf +https://wireframe.raspberrypi.org/books/unity-fps/pdf diff --git a/wireframe-books-downloader.sh b/wireframe-books-downloader.sh new file mode 100755 index 0000000..20dd420 --- /dev/null +++ b/wireframe-books-downloader.sh @@ -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 diff --git a/wireframe-downloader.sh b/wireframe-downloader.sh index d34a0c7..afffa66 100644 --- a/wireframe-downloader.sh +++ b/wireframe-downloader.sh @@ -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 +