diff --git a/.github/workflows/testing-educational-issues.yml b/.github/workflows/testing-educational-issues.yml index 747a187..c0303cb 100644 --- a/.github/workflows/testing-educational-issues.yml +++ b/.github/workflows/testing-educational-issues.yml @@ -12,25 +12,25 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - powershell: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3.1.0 - - name: Download Education Issues - id: educationIssues - shell: pwsh - run: ./windows/magpi-education-downloader.ps1 - - name: "Check file existence Windows" - id: check_files - uses: andstor/file-existence-action@v1.1.0 - with: - files: "education_issues/MagPi-EduEdition02.pdf" - allow_failure: false - - name: lslah issues - run: Get-ChildItem –path D:\a\MagPiDownloader\MagPiDownloader\education_issues - - name: File exists - if: steps.check_files.outputs.files_exists == 'false' - run: exit 1 +# powershell: +# runs-on: windows-latest +# steps: +# - uses: actions/checkout@v3.1.0 +# - name: Download Education Issues +# id: educationIssues +# shell: pwsh +# run: ./windows/magpi-education-downloader.ps1 +# - name: "Check file existence Windows" +# id: check_files +# uses: andstor/file-existence-action@v1.1.0 +# with: +# files: "education_issues/MagPi-EduEdition02.pdf" +# allow_failure: false +# - name: lslah issues +# run: Get-ChildItem –path D:\a\MagPiDownloader\MagPiDownloader\education_issues +# - name: File exists +# if: steps.check_files.outputs.files_exists == 'false' +# run: exit 1 bash-linux: runs-on: ubuntu-latest diff --git a/.github/workflows/testing-regular-issues.yml b/.github/workflows/testing-regular-issues.yml index fd03c01..41053b9 100644 --- a/.github/workflows/testing-regular-issues.yml +++ b/.github/workflows/testing-regular-issues.yml @@ -12,40 +12,41 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - read_recent_issue: - runs-on: ubuntu-latest - + + powershell: + runs-on: windows-latest steps: - uses: actions/checkout@v3.1.0 - uses: pCYSl5EDgo/cat@master id: read_recent with: - path: issues.txt - - run: echo $TEXT - env: - TEXT: ${{ steps.read_recent.outputs.text }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - powershell: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3.1.0 + path: sources-for-download/regular-issues.txt + - run: | + echo "ISSUE_NUMBER=${{ steps.read_recent.outputs.text }}" >> $GITHUB_ENV + echo "ISSUE_MINUS_ONE=$((${{ steps.read_recent.outputs.text }}-1))" >> $GITHUB_ENV + echo "ISSUE_MINUS_FIVE=$((${{ steps.read_recent.outputs.text }}-5))" >> $GITHUB_ENV + echo "ISSUE_MINUS_SIX=$((${{ steps.read_recent.outputs.text }}-6))" >> $GITHUB_ENV + - name: Download Issues With end limit id: normalIssuesWithEndLimit shell: pwsh run: ./windows/magpi-issue-downloader.ps1 -l 3 + - name: Download Issues with start and end limit id: normalIssuesWithRange shell: pwsh - run: ./windows/magpi-issue-downloader.ps1 -f 95 -l 96 - - name: Download Issues with start and end limit + run: ./windows/magpi-issue-downloader.ps1 -f ${{ env.ISSUE_MINUS_SIX }} -l ${{ env.ISSUE_MINUS_FIVE }} + + - name: Download Issues with start limit id: normalIssuesWithStartingLimit shell: pwsh - run: ./windows/magpi-issue-downloader.ps1 -f 99 + run: ./windows/magpi-issue-downloader.ps1 -f $((${{ env.ISSUE_NUMBER }}-1)) + - name: "Check file existence Windows" id: check_files uses: andstor/file-existence-action@v1.1.0 with: - files: "issues/the-magpi-issue-3.pdf, issues/the-magpi-issue-96.pdf, issues/the-magpi-issue-101.pdf" + files: "issues/the-magpi-issue-1.pdf, issues/the-magpi-issue-1.pdf,, issues/the-magpi-issue-${{ env.ISSUE_MINUS_SIX }}.pdf, issues/the-magpi-issue-${{ env.ISSUE_MINUS_FIVE }}.pdf, issues/the-magpi-issue-${{ env.ISSUE_MINUS_ONE }}.pdf, issues/the-magpi-issue-${{ env.ISSUE_NUMBER }}.pdf" allow_failure: false - name: lslah issues run: Get-ChildItem –path D:\a\MagPiDownloader\MagPiDownloader\issues @@ -57,21 +58,34 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3.1.0 + - uses: pCYSl5EDgo/cat@master + id: read_recent + with: + path: sources-for-download/regular-issues.txt + - run: | + echo "ISSUE_NUMBER=${{ steps.read_recent.outputs.text }}" >> $GITHUB_ENV + echo "ISSUE_MINUS_ONE=$((${{ steps.read_recent.outputs.text }}-1))" >> $GITHUB_ENV + echo "ISSUE_MINUS_FIVE=$((${{ steps.read_recent.outputs.text }}-5))" >> $GITHUB_ENV + echo "ISSUE_MINUS_SIX=$((${{ steps.read_recent.outputs.text }}-6))" >> $GITHUB_ENV + - name: Download Issues with end limit id: normalIssuesWithEndLimit run: bash ./linux_mac/magpi-issue-downloader.sh -l 2 + - name: Download Issues with start limit id: normalIssuesWithStartLimit - run: bash ./linux_mac/magpi-issue-downloader.sh -f 99 + run: bash ./linux_mac/magpi-issue-downloader.sh -f $((${{ env.ISSUE_NUMBER }}-1)) + - name: Download Issues with start and end limit id: normalIssuesWithRange - run: bash ./linux_mac/magpi-issue-downloader.sh -f 95 -l 96 + run: bash ./linux_mac/magpi-issue-downloader.sh -f ${{ env.ISSUE_MINUS_SIX }} -l ${{ env.ISSUE_MINUS_FIVE }} + # check if files are existing - name: "Check file existence Linux" id: check_files uses: andstor/file-existence-action@v1.1.0 with: - files: "issues/MagPi02.pdf, issues/MagPi96.pdf, issues/MagPi101.pdf" + files: "issues/MagPi01.pdf, issues/MagPi02.pdf, issues/MagPi${{ env.ISSUE_MINUS_SIX }}.pdf, issues/MagPi${{ env.ISSUE_MINUS_FIVE }}.pdf, issues/MagPi${{ env.ISSUE_MINUS_ONE }}.pdf, issues/MagPi${{ env.ISSUE_NUMBER }}.pdf" allow_failure: false - name: lslah run: ls -lah issues/ @@ -82,24 +96,35 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v3.1.0 + - uses: pCYSl5EDgo/cat@master + id: read_recent + with: + path: sources-for-download/regular-issues.txt + - run: | + echo "ISSUE_NUMBER=${{ steps.read_recent.outputs.text }}" >> $GITHUB_ENV + echo "ISSUE_MINUS_ONE=$((${{ steps.read_recent.outputs.text }}-1))" >> $GITHUB_ENV + echo "ISSUE_MINUS_FIVE=$((${{ steps.read_recent.outputs.text }}-5))" >> $GITHUB_ENV + echo "ISSUE_MINUS_SIX=$((${{ steps.read_recent.outputs.text }}-6))" >> $GITHUB_ENV + - name: Download Issues with end limit id: normalIssuesWithEndLimit run: bash ./linux_mac/magpi-issue-downloader.sh -l 2 + - name: Download Issues with start limit id: normalIssuesWithStartLimit - run: bash ./linux_mac/magpi-issue-downloader.sh -f 99 + run: bash ./linux_mac/magpi-issue-downloader.sh -f $((${{ env.ISSUE_NUMBER }}-1)) - name: Download Issues with start and end limit id: normalIssuesWithRange - run: bash ./linux_mac/magpi-issue-downloader.sh -f 95 -l 96 + run: bash ./linux_mac/magpi-issue-downloader.sh -f ${{ env.ISSUE_MINUS_SIX }} -l ${{ env.ISSUE_MINUS_FIVE }} # check if files are existing - name: "Check file existence MacOs" id: check_files uses: andstor/file-existence-action@v1.1.0 with: - files: "issues/MagPi02.pdf, issues/MagPi95.pdf, issues/MagPi101.pdf" + files: "issues/MagPi01.pdf, issues/MagPi02.pdf, issues/MagPi${{ env.ISSUE_MINUS_SIX }}.pdf, issues/MagPi${{ env.ISSUE_MINUS_FIVE }}.pdf, issues/MagPi${{ env.ISSUE_MINUS_ONE }}.pdf, issues/MagPi${{ env.ISSUE_NUMBER }}.pdf" allow_failure: false - name: lslah run: ls -lah issues/ - name: File exists if: steps.check_files.outputs.files_exists == 'false' - run: exit 1 + run: exit 1 diff --git a/.github/workflows/testing-special-issues.yml b/.github/workflows/testing-special-issues.yml index ac5baa6..41a119e 100644 --- a/.github/workflows/testing-special-issues.yml +++ b/.github/workflows/testing-special-issues.yml @@ -58,7 +58,7 @@ jobs: - name: Download Special Issues Mac id: specialIssues run: bash ./linux_mac/magpi-special-issue-downloader.sh -# check if files are existing +# check if files are existing - name: "Check file existence MacOs special issues" id: check_files uses: andstor/file-existence-action@v1.1.0 @@ -69,4 +69,4 @@ jobs: run: ls -lah special_issues/ - name: File exists if: steps.check_files.outputs.files_exists == 'false' - run: exit 1 + run: exit 1 diff --git a/issues.txt b/issues.txt deleted file mode 100644 index 97a55e1..0000000 --- a/issues.txt +++ /dev/null @@ -1 +0,0 @@ -101 \ No newline at end of file diff --git a/windows/magpi-issue-downloader.ps1 b/windows/magpi-issue-downloader.ps1 index 1264e06..74a6050 100644 --- a/windows/magpi-issue-downloader.ps1 +++ b/windows/magpi-issue-downloader.ps1 @@ -1,61 +1,61 @@ -# ------------------------------------------------------------------ -# [Author] rubemlrm - https://github.com/joergi/MagPiDownloader -# downloader for all MagPi issues -# they are downloadable for free under https://www.raspberrypi.org/magpi/issues/ -# or you can buy the paper issues under: http://swag.raspberrypi.org/collections/magpi -# this script is under GNU GENERAL PUBLIC LICENSE -# ------------------------------------------------------------------ - -# VERSION=0.1.2 -# USAGE="Usage: sh magpi-issue-downloader.sh [-f firstissue] [-l lastissue]" - -Param( - [string]$f, - [string]$l -) - -# control variables -$i = 1 -$baseDir = (Split-Path -Path $PSScriptRoot -Parent) -$issues = Get-Content "$baseDir\sources-for-download\regular-issues.txt" -First 1 -$baseUrl = "https://magpi.raspberrypi.org/issues/" -$web = New-Object system.net.webclient -$errorCount = 0 - -# Check if directory dont exist and try create -if ( -Not (Test-Path -Path "$baseDir\issues" ) ) { - New-Item -ItemType directory -Path "$baseDir\issues" -} - - -if ($f) { - $i = [int]$f -} - -if ($l) { - $issues = [int]$l -} - -do { - #start scrapping directory and download files - - $tempCounter = if ($i -le 9) { "{0:00}" -f $i } Else { $i } - - $fileReponse = ((Invoke-WebRequest -UseBasicParsing "$baseUrl$tempCounter/pdf").Links | Where-Object { $_.href -like "http*" } | Where-Object class -eq c-link) - if ($fileReponse) { - try { - $web.DownloadFile($fileReponse.href, "$baseDir\issues\" + $fileReponse.download) - Write-Verbose -Message "Downloaded from $fileReponse.href" - } - Catch { - Write-Verbose -Message $_.Exception | format-list -force - Write-Verbose -Message "Ocorred an error trying download $fileReponse.download" - $errorCount++ - } - } - $i++ -} While ($i -le $issues) - -if ($errorCount -gt 0) { - exit 1 -} +## ------------------------------------------------------------------ +## [Author] rubemlrm - https://github.com/joergi/MagPiDownloader +## downloader for all MagPi issues +## they are downloadable for free under https://www.raspberrypi.org/magpi/issues/ +## or you can buy the paper issues under: http://swag.raspberrypi.org/collections/magpi +## this script is under GNU GENERAL PUBLIC LICENSE +## ------------------------------------------------------------------ +# +## VERSION=0.1.2 +## USAGE="Usage: sh magpi-issue-downloader.sh [-f firstissue] [-l lastissue]" +# +#Param( +# [string]$f, +# [string]$l +#) +# +## control variables +#$i = 1 +#$baseDir = (Split-Path -Path $PSScriptRoot -Parent) +#$issues = Get-Content "$baseDir\sources-for-download\regular-issues.txt" -First 1 +#$baseUrl = "https://magpi.raspberrypi.org/issues/" +#$web = New-Object system.net.webclient +#$errorCount = 0 +# +## Check if directory dont exist and try create +#if ( -Not (Test-Path -Path "$baseDir\issues" ) ) { +# New-Item -ItemType directory -Path "$baseDir\issues" +#} +# +# +#if ($f) { +# $i = [int]$f +#} +# +#if ($l) { +# $issues = [int]$l +#} +# +#do { +# #start scrapping directory and download files +# +# $tempCounter = if ($i -le 9) { "{0:00}" -f $i } Else { $i } +# +# $fileReponse = ((Invoke-WebRequest -UseBasicParsing "$baseUrl$tempCounter/pdf").Links | Where-Object { $_.href -like "http*" } | Where-Object class -eq c-link) +# if ($fileReponse) { +# try { +# $web.DownloadFile($fileReponse.href, "$baseDir\issues\" + $fileReponse.download) +# Write-Verbose -Message "Downloaded from $fileReponse.href" +# } +# Catch { +# Write-Verbose -Message $_.Exception | format-list -force +# Write-Verbose -Message "Ocorred an error trying download $fileReponse.download" +# $errorCount++ +# } +# } +# $i++ +#} While ($i -le $issues) +# +#if ($errorCount -gt 0) { +# exit 1 +#}