├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ └── build_and_publish.yml ├── .gitignore ├── .idea └── .idea.ZygorDownloader │ └── .idea │ ├── codeStyles │ └── codeStyleConfig.xml │ ├── encodings.xml │ ├── indexLayout.xml │ ├── modules.xml │ ├── projectSettingsUpdater.xml │ └── vcs.xml ├── ZygorDownloader.sln ├── ZygorDownloader ├── Addon │ ├── AddonInfo.cs │ ├── AddonInfoExtractor.cs │ └── AddonPacker.cs ├── Browser │ ├── BaseWebPage.cs │ ├── Codedeception │ │ ├── LoginPage.cs │ │ ├── Session.cs │ │ └── ZygorPage.cs │ ├── IWebPage.cs │ └── WebDriverFactory.cs ├── Ioc │ ├── IService.cs │ └── SerilogContextualLoggerInjectionBehavior.cs ├── Mega │ ├── DownloaderResult.cs │ └── RarDownloader.cs ├── Program.cs ├── ZygorDownloader.csproj └── appsettings.json └── docs ├── css └── custom.css └── index.html /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: nuget 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "05:00" 8 | open-pull-requests-limit: 10 -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ main, dev ] 6 | pull_request: 7 | branches: [ main, dev ] 8 | 9 | jobs: 10 | build: 11 | # The type of runner that the job will run on 12 | runs-on: windows-latest 13 | env: 14 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 15 | DOTNET_CLI_TELEMETRY_OPTOUT: true 16 | DOTNET_NOLOGO: true 17 | 18 | # Steps represent a sequence of tasks that will be executed as part of the job 19 | steps: 20 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 21 | - uses: actions/checkout@v2 22 | with: 23 | submodules: 'recursive' 24 | 25 | - uses: actions/cache@v2.1.1 26 | name: Cache nuget 27 | with: 28 | path: ~/.nuget/packages 29 | key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} 30 | restore-keys: | 31 | ${{ runner.os }}-nuget- 32 | 33 | - uses: actions/setup-dotnet@v1.7.2 34 | with: 35 | dotnet-version: '3.1.x' 36 | 37 | - name: Restore using netcore 38 | run: dotnet restore 39 | timeout-minutes: 5 40 | 41 | - name: Build Release 42 | run: dotnet build --configuration Release 43 | timeout-minutes: 5 44 | 45 | - name: Run Release 46 | env: 47 | ZY_CODEDECEPTION__LOGIN: ${{ secrets.ZY_CODEDECEPTION__LOGIN }} 48 | ZY_CODEDECEPTION__PASSWORD: ${{ secrets.ZY_CODEDECEPTION__PASSWORD }} 49 | run: | 50 | cd ZygorDownloader 51 | dotnet run --configuration Release 52 | timeout-minutes: 15 53 | -------------------------------------------------------------------------------- /.github/workflows/build_and_publish.yml: -------------------------------------------------------------------------------- 1 | name: Build & Publish 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | schedule: 7 | - cron: '33 */6 * * *' 8 | 9 | jobs: 10 | build_publish: 11 | # The type of runner that the job will run on 12 | runs-on: windows-latest 13 | env: 14 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 15 | DOTNET_CLI_TELEMETRY_OPTOUT: true 16 | DOTNET_NOLOGO: true 17 | 18 | # Steps represent a sequence of tasks that will be executed as part of the job 19 | steps: 20 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 21 | - uses: actions/checkout@v2 22 | with: 23 | submodules: 'recursive' 24 | 25 | - uses: actions/cache@v2.1.1 26 | name: Cache nuget 27 | with: 28 | path: ~/.nuget/packages 29 | key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} 30 | restore-keys: | 31 | ${{ runner.os }}-nuget- 32 | 33 | - uses: actions/setup-dotnet@v1 34 | with: 35 | dotnet-version: '3.1.x' 36 | 37 | - name: Restore using netcore 38 | run: dotnet restore 39 | timeout-minutes: 5 40 | 41 | - name: Build Release 42 | run: dotnet build --configuration Release 43 | timeout-minutes: 5 44 | 45 | - name: Lock using Turnstyle 46 | timeout-minutes: 15 47 | uses: softprops/turnstyle@v1 48 | env: 49 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 50 | 51 | - name: Run Release 52 | env: 53 | ZY_CODEDECEPTION__LOGIN: ${{ secrets.ZY_CODEDECEPTION__LOGIN }} 54 | ZY_CODEDECEPTION__PASSWORD: ${{ secrets.ZY_CODEDECEPTION__PASSWORD }} 55 | run: | 56 | cd ZygorDownloader 57 | dotnet run --configuration Release 58 | timeout-minutes: 15 59 | 60 | - name: Setup git 61 | id: setup_git 62 | timeout-minutes: 3 63 | shell: bash 64 | run: | 65 | set -x 66 | git fetch --tags --all 67 | git config --local user.email "action@github.com" 68 | git config --local user.name "GitHub Action" 69 | 70 | - name: Export env 71 | shell: python 72 | run: | 73 | import json 74 | from pathlib import Path 75 | import os 76 | 77 | def set_env(name: str, value: str): 78 | with open(os.getenv("GITHUB_ENV"), 'a', encoding='UTF-8') as f: 79 | return print(f"{name}={value}", file=f) 80 | 81 | retail_zip = next(Path(".").glob("**/ZygorGuidesViewer.zip")) 82 | set_env("RETAIL_ZIP", str(retail_zip.absolute())) 83 | set_env("RETAIL_FOLDER", str(retail_zip.parent.absolute())) 84 | retail_json = json.loads(next(Path(".").glob("**/ZygorGuidesViewer.json")).read_text()) 85 | set_env("RETAIL_REVISION", retail_json['Revision']) 86 | 87 | classic_zip = next(Path(".").glob("**/ZygorGuidesViewerClassic.zip")) 88 | set_env("CLASSIC_ZIP", str(classic_zip.absolute())) 89 | set_env("CLASSIC_FOLDER", str(classic_zip.parent.absolute())) 90 | classic_json = json.loads(next(Path(".").glob("**/ZygorGuidesViewerClassic.json")).read_text()) 91 | set_env("CLASSIC_REVISION", classic_json['Revision']) 92 | 93 | - name: Manage Tag 94 | timeout-minutes: 1 95 | shell: bash 96 | run: | 97 | set -x 98 | 99 | git ls-remote --exit-code origin "refs/tags/v${RETAIL_REVISION}" && 100 | echo "NEW_RETAIL_RELEASE=" >> $GITHUB_ENV || 101 | echo "NEW_RETAIL_RELEASE=1" >> $GITHUB_ENV 102 | git tag "v${RETAIL_REVISION}" || : 103 | 104 | git ls-remote --exit-code origin "refs/tags/v${CLASSIC_REVISION}" && 105 | echo "NEW_CLASSIC_RELEASE=" >> $GITHUB_ENV || 106 | echo "NEW_CLASSIC_RELEASE=1" >> $GITHUB_ENV 107 | git tag "v${CLASSIC_REVISION}" || : 108 | 109 | 110 | git ls-remote --exit-code origin "refs/tags/v_r${RETAIL_REVISION}_c${CLASSIC_REVISION}" && 111 | echo "NEW_RELEASE=" >> $GITHUB_ENV || 112 | echo "NEW_RELEASE=1" >> $GITHUB_ENV 113 | git tag "v_r${RETAIL_REVISION}_c${CLASSIC_REVISION}" || : 114 | 115 | git push -f --tags 116 | 117 | - name: Create artifact 118 | uses: actions/upload-artifact@v2 119 | with: 120 | name: zygor_all 121 | path: | 122 | ${{ env.RETAIL_FOLDER }} 123 | ${{ env.CLASSIC_FOLDER }} 124 | 125 | - name: Create retail artifact 126 | uses: actions/upload-artifact@v2 127 | with: 128 | name: zygor_retail 129 | path: | 130 | ${{ env.RETAIL_FOLDER }}/ZygorGuidesViewer.* 131 | 132 | - name: Create classic artifact 133 | uses: actions/upload-artifact@v2 134 | with: 135 | name: zygor_classic 136 | path: | 137 | ${{ env.CLASSIC_FOLDER }}/ZygorGuidesViewerClassic.* 138 | 139 | 140 | - name: Delete Draft Releases 141 | uses: hugo19941994/delete-draft-releases@v0.1.0 142 | if: success() && env.NEW_RELEASE == '1' 143 | continue-on-error: true 144 | env: 145 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 146 | 147 | 148 | - name: Create Release 149 | id: create_release 150 | if: success() && env.NEW_RELEASE == '1' 151 | continue-on-error: true 152 | uses: actions/create-release@v1 153 | env: 154 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 155 | with: 156 | tag_name: "v_r${{ env.RETAIL_REVISION }}_c${{ env.CLASSIC_REVISION }}" 157 | release_name: retail ${{ env.RETAIL_REVISION }} + classic ${{ env.CLASSIC_REVISION }} 158 | prerelease: false 159 | 160 | - name: Upload retail Asset 161 | id: upload-retail-asset 162 | if: success() && env.NEW_RELEASE == '1' 163 | uses: actions/upload-release-asset@v1 164 | env: 165 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 166 | with: 167 | upload_url: ${{ steps.create_release.outputs.upload_url }} 168 | asset_path: ${{ env.RETAIL_ZIP }} 169 | asset_name: ZygorGuidesViewer.zip 170 | asset_content_type: "application/zip" 171 | 172 | - name: Upload classic Asset 173 | uses: actions/upload-release-asset@v1 174 | id: upload-classic-asset 175 | if: success() && env.NEW_RELEASE == '1' 176 | env: 177 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 178 | with: 179 | upload_url: ${{ steps.create_release.outputs.upload_url }} 180 | asset_path: ${{ env.CLASSIC_ZIP }} 181 | asset_name: ZygorGuidesViewerClassic.zip 182 | asset_content_type: "application/zip" 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/rider,windows,visualstudio,visualstudiocode,csharp,lua,python,tortoisegit 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=rider,windows,visualstudio,visualstudiocode,csharp,lua,python,tortoisegit 4 | 5 | ### Csharp ### 6 | ## Ignore Visual Studio temporary files, build results, and 7 | ## files generated by popular Visual Studio add-ons. 8 | ## 9 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 10 | 11 | # User-specific files 12 | *.rsuser 13 | *.suo 14 | *.user 15 | *.userosscache 16 | *.sln.docstates 17 | 18 | # User-specific files (MonoDevelop/Xamarin Studio) 19 | *.userprefs 20 | 21 | # Mono auto generated files 22 | mono_crash.* 23 | 24 | # Build results 25 | [Dd]ebug/ 26 | [Dd]ebugPublic/ 27 | [Rr]elease/ 28 | [Rr]eleases/ 29 | x64/ 30 | x86/ 31 | [Aa][Rr][Mm]/ 32 | [Aa][Rr][Mm]64/ 33 | bld/ 34 | [Bb]in/ 35 | [Oo]bj/ 36 | [Ll]og/ 37 | [Ll]ogs/ 38 | 39 | # Visual Studio 2015/2017 cache/options directory 40 | .vs/ 41 | # Uncomment if you have tasks that create the project's static files in wwwroot 42 | #wwwroot/ 43 | 44 | # Visual Studio 2017 auto generated files 45 | Generated\ Files/ 46 | 47 | # MSTest test Results 48 | [Tt]est[Rr]esult*/ 49 | [Bb]uild[Ll]og.* 50 | 51 | # NUnit 52 | *.VisualState.xml 53 | TestResult.xml 54 | nunit-*.xml 55 | 56 | # Build Results of an ATL Project 57 | [Dd]ebugPS/ 58 | [Rr]eleasePS/ 59 | dlldata.c 60 | 61 | # Benchmark Results 62 | BenchmarkDotNet.Artifacts/ 63 | 64 | # .NET Core 65 | project.lock.json 66 | project.fragment.lock.json 67 | artifacts/ 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*[.json, .xml, .info] 147 | 148 | # Visual Studio code coverage results 149 | *.coverage 150 | *.coveragexml 151 | 152 | # NCrunch 153 | _NCrunch_* 154 | .*crunch*.local.xml 155 | nCrunchTemp_* 156 | 157 | # MightyMoose 158 | *.mm.* 159 | AutoTest.Net/ 160 | 161 | # Web workbench (sass) 162 | .sass-cache/ 163 | 164 | # Installshield output folder 165 | [Ee]xpress/ 166 | 167 | # DocProject is a documentation generator add-in 168 | DocProject/buildhelp/ 169 | DocProject/Help/*.HxT 170 | DocProject/Help/*.HxC 171 | DocProject/Help/*.hhc 172 | DocProject/Help/*.hhk 173 | DocProject/Help/*.hhp 174 | DocProject/Help/Html2 175 | DocProject/Help/html 176 | 177 | # Click-Once directory 178 | publish/ 179 | 180 | # Publish Web Output 181 | *.[Pp]ublish.xml 182 | *.azurePubxml 183 | # Note: Comment the next line if you want to checkin your web deploy settings, 184 | # but database connection strings (with potential passwords) will be unencrypted 185 | *.pubxml 186 | *.publishproj 187 | 188 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 189 | # checkin your Azure Web App publish settings, but sensitive information contained 190 | # in these scripts will be unencrypted 191 | PublishScripts/ 192 | 193 | # NuGet Packages 194 | *.nupkg 195 | # NuGet Symbol Packages 196 | *.snupkg 197 | # The packages folder can be ignored because of Package Restore 198 | **/[Pp]ackages/* 199 | # except build/, which is used as an MSBuild target. 200 | !**/[Pp]ackages/build/ 201 | # Uncomment if necessary however generally it will be regenerated when needed 202 | #!**/[Pp]ackages/repositories.config 203 | # NuGet v3's project.json files produces more ignorable files 204 | *.nuget.props 205 | *.nuget.targets 206 | 207 | # Microsoft Azure Build Output 208 | csx/ 209 | *.build.csdef 210 | 211 | # Microsoft Azure Emulator 212 | ecf/ 213 | rcf/ 214 | 215 | # Windows Store app package directories and files 216 | AppPackages/ 217 | BundleArtifacts/ 218 | Package.StoreAssociation.xml 219 | _pkginfo.txt 220 | *.appx 221 | *.appxbundle 222 | *.appxupload 223 | 224 | # Visual Studio cache files 225 | # files ending in .cache can be ignored 226 | *.[Cc]ache 227 | # but keep track of directories ending in .cache 228 | !?*.[Cc]ache/ 229 | 230 | # Others 231 | ClientBin/ 232 | ~$* 233 | *~ 234 | *.dbmdl 235 | *.dbproj.schemaview 236 | *.jfm 237 | *.pfx 238 | *.publishsettings 239 | orleans.codegen.cs 240 | 241 | # Including strong name files can present a security risk 242 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 243 | #*.snk 244 | 245 | # Since there are multiple workflows, uncomment next line to ignore bower_components 246 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 247 | #bower_components/ 248 | 249 | # RIA/Silverlight projects 250 | Generated_Code/ 251 | 252 | # Backup & report files from converting an old project file 253 | # to a newer Visual Studio version. Backup files are not needed, 254 | # because we have git ;-) 255 | _UpgradeReport_Files/ 256 | Backup*/ 257 | UpgradeLog*.XML 258 | UpgradeLog*.htm 259 | ServiceFabricBackup/ 260 | *.rptproj.bak 261 | 262 | # SQL Server files 263 | *.mdf 264 | *.ldf 265 | *.ndf 266 | 267 | # Business Intelligence projects 268 | *.rdl.data 269 | *.bim.layout 270 | *.bim_*.settings 271 | *.rptproj.rsuser 272 | *- [Bb]ackup.rdl 273 | *- [Bb]ackup ([0-9]).rdl 274 | *- [Bb]ackup ([0-9][0-9]).rdl 275 | 276 | # Microsoft Fakes 277 | FakesAssemblies/ 278 | 279 | # GhostDoc plugin setting file 280 | *.GhostDoc.xml 281 | 282 | # Node.js Tools for Visual Studio 283 | .ntvs_analysis.dat 284 | node_modules/ 285 | 286 | # Visual Studio 6 build log 287 | *.plg 288 | 289 | # Visual Studio 6 workspace options file 290 | *.opt 291 | 292 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 293 | *.vbw 294 | 295 | # Visual Studio LightSwitch build output 296 | **/*.HTMLClient/GeneratedArtifacts 297 | **/*.DesktopClient/GeneratedArtifacts 298 | **/*.DesktopClient/ModelManifest.xml 299 | **/*.Server/GeneratedArtifacts 300 | **/*.Server/ModelManifest.xml 301 | _Pvt_Extensions 302 | 303 | # Paket dependency manager 304 | .paket/paket.exe 305 | paket-files/ 306 | 307 | # FAKE - F# Make 308 | .fake/ 309 | 310 | # CodeRush personal settings 311 | .cr/personal 312 | 313 | # Python Tools for Visual Studio (PTVS) 314 | __pycache__/ 315 | *.pyc 316 | 317 | # Cake - Uncomment if you are using it 318 | # tools/** 319 | # !tools/packages.config 320 | 321 | # Tabs Studio 322 | *.tss 323 | 324 | # Telerik's JustMock configuration file 325 | *.jmconfig 326 | 327 | # BizTalk build output 328 | *.btp.cs 329 | *.btm.cs 330 | *.odx.cs 331 | *.xsd.cs 332 | 333 | # OpenCover UI analysis results 334 | OpenCover/ 335 | 336 | # Azure Stream Analytics local run output 337 | ASALocalRun/ 338 | 339 | # MSBuild Binary and Structured Log 340 | *.binlog 341 | 342 | # NVidia Nsight GPU debugger configuration file 343 | *.nvuser 344 | 345 | # MFractors (Xamarin productivity tool) working folder 346 | .mfractor/ 347 | 348 | # Local History for Visual Studio 349 | .localhistory/ 350 | 351 | # BeatPulse healthcheck temp database 352 | healthchecksdb 353 | 354 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 355 | MigrationBackup/ 356 | 357 | # Ionide (cross platform F# VS Code tools) working folder 358 | .ionide/ 359 | 360 | ### Lua ### 361 | # Compiled Lua sources 362 | luac.out 363 | 364 | # luarocks build files 365 | *.src.rock 366 | *.zip 367 | *.tar.gz 368 | 369 | # Object files 370 | *.o 371 | *.os 372 | *.ko 373 | *.elf 374 | 375 | # Precompiled Headers 376 | *.gch 377 | 378 | # Libraries 379 | *.lib 380 | *.a 381 | *.la 382 | *.lo 383 | *.def 384 | *.exp 385 | 386 | # Shared objects (inc. Windows DLLs) 387 | *.dll 388 | *.so 389 | *.so.* 390 | *.dylib 391 | 392 | # Executables 393 | *.exe 394 | *.out 395 | *.app 396 | *.i*86 397 | *.x86_64 398 | *.hex 399 | 400 | 401 | ### Python ### 402 | # Byte-compiled / optimized / DLL files 403 | *.py[cod] 404 | *$py.class 405 | 406 | # C extensions 407 | 408 | # Distribution / packaging 409 | .Python 410 | build/ 411 | develop-eggs/ 412 | dist/ 413 | downloads/ 414 | eggs/ 415 | .eggs/ 416 | lib/ 417 | lib64/ 418 | parts/ 419 | sdist/ 420 | var/ 421 | wheels/ 422 | pip-wheel-metadata/ 423 | share/python-wheels/ 424 | *.egg-info/ 425 | .installed.cfg 426 | *.egg 427 | MANIFEST 428 | 429 | # PyInstaller 430 | # Usually these files are written by a python script from a template 431 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 432 | *.manifest 433 | *.spec 434 | 435 | # Installer logs 436 | pip-log.txt 437 | pip-delete-this-directory.txt 438 | 439 | # Unit test / coverage reports 440 | htmlcov/ 441 | .tox/ 442 | .nox/ 443 | .coverage 444 | .coverage.* 445 | .cache 446 | nosetests.xml 447 | coverage.xml 448 | *.cover 449 | *.py,cover 450 | .hypothesis/ 451 | .pytest_cache/ 452 | pytestdebug.log 453 | 454 | # Translations 455 | *.mo 456 | *.pot 457 | 458 | # Django stuff: 459 | local_settings.py 460 | db.sqlite3 461 | db.sqlite3-journal 462 | 463 | # Flask stuff: 464 | instance/ 465 | .webassets-cache 466 | 467 | # Scrapy stuff: 468 | .scrapy 469 | 470 | # Sphinx documentation 471 | docs/_build/ 472 | doc/_build/ 473 | 474 | # PyBuilder 475 | target/ 476 | 477 | # Jupyter Notebook 478 | .ipynb_checkpoints 479 | 480 | # IPython 481 | profile_default/ 482 | ipython_config.py 483 | 484 | # pyenv 485 | .python-version 486 | 487 | # pipenv 488 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 489 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 490 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 491 | # install all needed dependencies. 492 | #Pipfile.lock 493 | 494 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 495 | __pypackages__/ 496 | 497 | # Celery stuff 498 | celerybeat-schedule 499 | celerybeat.pid 500 | 501 | # SageMath parsed files 502 | *.sage.py 503 | 504 | # Environments 505 | .env 506 | .venv 507 | env/ 508 | venv/ 509 | ENV/ 510 | env.bak/ 511 | venv.bak/ 512 | pythonenv* 513 | 514 | # Spyder project settings 515 | .spyderproject 516 | .spyproject 517 | 518 | # Rope project settings 519 | .ropeproject 520 | 521 | # mkdocs documentation 522 | /site 523 | 524 | # mypy 525 | .mypy_cache/ 526 | .dmypy.json 527 | dmypy.json 528 | 529 | # Pyre type checker 530 | .pyre/ 531 | 532 | # pytype static type analyzer 533 | .pytype/ 534 | 535 | # profiling data 536 | .prof 537 | 538 | ### Rider ### 539 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 540 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 541 | 542 | # User-specific stuff 543 | .idea/**/workspace.xml 544 | .idea/**/tasks.xml 545 | .idea/**/usage.statistics.xml 546 | .idea/**/dictionaries 547 | .idea/**/shelf 548 | 549 | # Generated files 550 | .idea/**/contentModel.xml 551 | 552 | # Sensitive or high-churn files 553 | .idea/**/dataSources/ 554 | .idea/**/dataSources.ids 555 | .idea/**/dataSources.local.xml 556 | .idea/**/sqlDataSources.xml 557 | .idea/**/dynamic.xml 558 | .idea/**/uiDesigner.xml 559 | .idea/**/dbnavigator.xml 560 | 561 | # Gradle 562 | .idea/**/gradle.xml 563 | .idea/**/libraries 564 | 565 | # Gradle and Maven with auto-import 566 | # When using Gradle or Maven with auto-import, you should exclude module files, 567 | # since they will be recreated, and may cause churn. Uncomment if using 568 | # auto-import. 569 | # .idea/artifacts 570 | # .idea/compiler.xml 571 | # .idea/jarRepositories.xml 572 | # .idea/modules.xml 573 | # .idea/*.iml 574 | # .idea/modules 575 | # *.iml 576 | # *.ipr 577 | 578 | # CMake 579 | cmake-build-*/ 580 | 581 | # Mongo Explorer plugin 582 | .idea/**/mongoSettings.xml 583 | 584 | # File-based project format 585 | *.iws 586 | 587 | # IntelliJ 588 | out/ 589 | 590 | # mpeltonen/sbt-idea plugin 591 | .idea_modules/ 592 | 593 | # JIRA plugin 594 | atlassian-ide-plugin.xml 595 | 596 | # Cursive Clojure plugin 597 | .idea/replstate.xml 598 | 599 | # Crashlytics plugin (for Android Studio and IntelliJ) 600 | com_crashlytics_export_strings.xml 601 | crashlytics.properties 602 | crashlytics-build.properties 603 | fabric.properties 604 | 605 | # Editor-based Rest Client 606 | .idea/httpRequests 607 | 608 | # Android studio 3.1+ serialized cache file 609 | .idea/caches/build_file_checksums.ser 610 | 611 | ### TortoiseGit ### 612 | # Project-level settings 613 | /.tgitconfig 614 | 615 | ### VisualStudioCode ### 616 | .vscode/* 617 | !.vscode/settings.json 618 | !.vscode/tasks.json 619 | !.vscode/launch.json 620 | !.vscode/extensions.json 621 | *.code-workspace 622 | 623 | ### VisualStudioCode Patch ### 624 | # Ignore all local history of files 625 | .history 626 | .ionide 627 | 628 | ### Windows ### 629 | # Windows thumbnail cache files 630 | Thumbs.db 631 | Thumbs.db:encryptable 632 | ehthumbs.db 633 | ehthumbs_vista.db 634 | 635 | # Dump file 636 | *.stackdump 637 | 638 | # Folder config file 639 | [Dd]esktop.ini 640 | 641 | # Recycle Bin used on file shares 642 | $RECYCLE.BIN/ 643 | 644 | # Windows Installer files 645 | *.cab 646 | *.msi 647 | *.msix 648 | *.msm 649 | *.msp 650 | 651 | # Windows shortcuts 652 | *.lnk 653 | 654 | ### VisualStudio ### 655 | 656 | # User-specific files 657 | 658 | # User-specific files (MonoDevelop/Xamarin Studio) 659 | 660 | # Mono auto generated files 661 | 662 | # Build results 663 | 664 | # Visual Studio 2015/2017 cache/options directory 665 | # Uncomment if you have tasks that create the project's static files in wwwroot 666 | 667 | # Visual Studio 2017 auto generated files 668 | 669 | # MSTest test Results 670 | 671 | # NUnit 672 | 673 | # Build Results of an ATL Project 674 | 675 | # Benchmark Results 676 | 677 | # .NET Core 678 | 679 | # StyleCop 680 | 681 | # Files built by Visual Studio 682 | 683 | # Chutzpah Test files 684 | 685 | # Visual C++ cache files 686 | 687 | # Visual Studio profiler 688 | 689 | # Visual Studio Trace Files 690 | 691 | # TFS 2012 Local Workspace 692 | 693 | # Guidance Automation Toolkit 694 | 695 | # ReSharper is a .NET coding add-in 696 | 697 | # TeamCity is a build add-in 698 | 699 | # DotCover is a Code Coverage Tool 700 | 701 | # AxoCover is a Code Coverage Tool 702 | 703 | # Coverlet is a free, cross platform Code Coverage Tool 704 | 705 | # Visual Studio code coverage results 706 | 707 | # NCrunch 708 | 709 | # MightyMoose 710 | 711 | # Web workbench (sass) 712 | 713 | # Installshield output folder 714 | 715 | # DocProject is a documentation generator add-in 716 | 717 | # Click-Once directory 718 | 719 | # Publish Web Output 720 | # Note: Comment the next line if you want to checkin your web deploy settings, 721 | # but database connection strings (with potential passwords) will be unencrypted 722 | 723 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 724 | # checkin your Azure Web App publish settings, but sensitive information contained 725 | # in these scripts will be unencrypted 726 | 727 | # NuGet Packages 728 | # NuGet Symbol Packages 729 | # The packages folder can be ignored because of Package Restore 730 | # except build/, which is used as an MSBuild target. 731 | # Uncomment if necessary however generally it will be regenerated when needed 732 | # NuGet v3's project.json files produces more ignorable files 733 | 734 | # Microsoft Azure Build Output 735 | 736 | # Microsoft Azure Emulator 737 | 738 | # Windows Store app package directories and files 739 | 740 | # Visual Studio cache files 741 | # files ending in .cache can be ignored 742 | # but keep track of directories ending in .cache 743 | 744 | # Others 745 | 746 | # Including strong name files can present a security risk 747 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 748 | 749 | # Since there are multiple workflows, uncomment next line to ignore bower_components 750 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 751 | 752 | # RIA/Silverlight projects 753 | 754 | # Backup & report files from converting an old project file 755 | # to a newer Visual Studio version. Backup files are not needed, 756 | # because we have git ;-) 757 | 758 | # SQL Server files 759 | 760 | # Business Intelligence projects 761 | 762 | # Microsoft Fakes 763 | 764 | # GhostDoc plugin setting file 765 | 766 | # Node.js Tools for Visual Studio 767 | 768 | # Visual Studio 6 build log 769 | 770 | # Visual Studio 6 workspace options file 771 | 772 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 773 | 774 | # Visual Studio LightSwitch build output 775 | 776 | # Paket dependency manager 777 | 778 | # FAKE - F# Make 779 | 780 | # CodeRush personal settings 781 | 782 | # Python Tools for Visual Studio (PTVS) 783 | 784 | # Cake - Uncomment if you are using it 785 | # tools/** 786 | # !tools/packages.config 787 | 788 | # Tabs Studio 789 | 790 | # Telerik's JustMock configuration file 791 | 792 | # BizTalk build output 793 | 794 | # OpenCover UI analysis results 795 | 796 | # Azure Stream Analytics local run output 797 | 798 | # MSBuild Binary and Structured Log 799 | 800 | # NVidia Nsight GPU debugger configuration file 801 | 802 | # MFractors (Xamarin productivity tool) working folder 803 | 804 | # Local History for Visual Studio 805 | 806 | # BeatPulse healthcheck temp database 807 | 808 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 809 | 810 | # Ionide (cross platform F# VS Code tools) working folder 811 | 812 | # End of https://www.toptal.com/developers/gitignore/api/rider,windows,visualstudio,visualstudiocode,csharp,lua,python,tortoisegit 813 | 814 | 815 | bin/ 816 | obj/ 817 | /packages/ 818 | riderModule.iml 819 | /_ReSharper.Caches/ 820 | /pub 821 | -------------------------------------------------------------------------------- /.idea/.idea.ZygorDownloader/.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/.idea.ZygorDownloader/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/.idea.ZygorDownloader/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea.ZygorDownloader/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea.ZygorDownloader/.idea/projectSettingsUpdater.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/.idea.ZygorDownloader/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ZygorDownloader.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZygorDownloader", "ZygorDownloader\ZygorDownloader.csproj", "{893C7E73-6BED-47F2-8FB7-9E2E81004BAB}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Any CPU = Debug|Any CPU 8 | Release|Any CPU = Release|Any CPU 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {893C7E73-6BED-47F2-8FB7-9E2E81004BAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 12 | {893C7E73-6BED-47F2-8FB7-9E2E81004BAB}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 | {893C7E73-6BED-47F2-8FB7-9E2E81004BAB}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 | {893C7E73-6BED-47F2-8FB7-9E2E81004BAB}.Release|Any CPU.Build.0 = Release|Any CPU 15 | EndGlobalSection 16 | EndGlobal 17 | -------------------------------------------------------------------------------- /ZygorDownloader/Addon/AddonInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace ZygorDownloader.Addon 5 | { 6 | public class AddonInfo 7 | { 8 | public readonly string Revision; 9 | public readonly Dictionary Toc; 10 | public readonly string Id; 11 | public readonly DateTime Date; 12 | public readonly string File; 13 | 14 | public AddonInfo(string revision, Dictionary toc, string id, DateTime date, string file) 15 | { 16 | Revision = revision; 17 | Toc = toc; 18 | Id = id; 19 | Date = date; 20 | File = file; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /ZygorDownloader/Addon/AddonInfoExtractor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text.RegularExpressions; 6 | using GlobExpressions; 7 | using MoonSharp.Interpreter; 8 | using Serilog; 9 | using Serilog.Core; 10 | using ZygorDownloader.Ioc; 11 | using ZygorDownloader.Mega; 12 | 13 | namespace ZygorDownloader.Addon 14 | { 15 | public interface IAddonInfoExtractor 16 | { 17 | AddonInfo Extract(DownloaderResult downloaderResult); 18 | } 19 | 20 | public class AddonInfoExtractor : IService, IAddonInfoExtractor 21 | { 22 | private readonly ILogger logger; 23 | 24 | public AddonInfoExtractor(ILogger logger) 25 | { 26 | this.logger = logger; 27 | } 28 | 29 | public AddonInfo Extract(DownloaderResult downloaderResult) 30 | { 31 | Dictionary tocInfo; 32 | try 33 | { 34 | tocInfo = ExtractTocInfo(downloaderResult.Directory); 35 | } 36 | catch (Exception e) 37 | { 38 | logger.Error(e, "Unable to extract addon's toc"); 39 | tocInfo = new Dictionary(); 40 | } 41 | 42 | string revision; 43 | try 44 | { 45 | revision = ExtractRevision(downloaderResult.Directory); 46 | } 47 | catch (Exception e) 48 | { 49 | logger.Error(e, "Unable to extract addon's revision"); 50 | revision = $"Unknown{downloaderResult.OriginalId}"; 51 | } 52 | 53 | return new AddonInfo(revision, tocInfo, downloaderResult.OriginalId, downloaderResult.OriginalDate, downloaderResult.OriginalFileName); 54 | } 55 | 56 | private string ExtractRevision(string directory) 57 | { 58 | var versionFiles = new DirectoryInfo(directory).GlobFiles("**/Ver.lua").ToArray(); 59 | if (versionFiles.Length > 1) 60 | { 61 | throw new Exception("More than 1 Ver.lua file found"); 62 | } 63 | 64 | if (versionFiles.Length == 0) 65 | { 66 | throw new Exception("No Ver.lua file found"); 67 | } 68 | 69 | var versionFile = versionFiles[0]; 70 | 71 | using var f = versionFile.OpenText(); 72 | var content = f.ReadToEnd(); 73 | 74 | var lua = $@" 75 | local tmp = {{}}; 76 | local ZygorGuidesViewer = tmp 77 | 78 | local function GetAddOnMetadata(...) 79 | return """" 80 | end 81 | 82 | local function wrap (...) 83 | {content} 84 | end 85 | 86 | 87 | wrap(""Zygor"", tmp) 88 | return tmp.revision or tmp.version"; 89 | 90 | var res = Script.RunString(lua); 91 | var revision = res.CastToString(); 92 | logger.Debug("Found revision {0}", revision); 93 | return revision; 94 | } 95 | 96 | private Dictionary ExtractTocInfo(string directory) 97 | { 98 | var tocArray = new DirectoryInfo(directory).GlobFiles("**/Zygor*.toc").ToArray(); 99 | if (tocArray.Length > 1) 100 | { 101 | throw new Exception("More than 1 toc file found"); 102 | } 103 | 104 | if (tocArray.Length == 0) 105 | { 106 | throw new Exception("No toc file found"); 107 | } 108 | 109 | var toc = tocArray[0]; 110 | 111 | var tocRegex = new Regex(@"^\s*##\s+(\w+[\w-]+)\s*:\s*(.*?)\s?$", 112 | RegexOptions.Multiline | RegexOptions.IgnoreCase); 113 | using var s = toc.OpenText(); 114 | var tocInfo = new Dictionary(); 115 | while (!s.EndOfStream) 116 | { 117 | var l = s.ReadLine(); 118 | if (l is null) break; 119 | var m = tocRegex.Match(l); 120 | if (!m.Success) 121 | { 122 | continue; 123 | } 124 | 125 | if (m.Groups[1].Success && !string.IsNullOrWhiteSpace(m.Groups[1].Value) && 126 | m.Groups[2].Success && m.Groups[2].Value is {}) 127 | { 128 | tocInfo[m.Groups[1].Value.Trim()] = m.Groups[2].Value.Trim(); 129 | } 130 | } 131 | 132 | logger.Debug("Found {0} toc items", tocInfo.Count); 133 | return tocInfo; 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /ZygorDownloader/Addon/AddonPacker.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.IO.Compression; 3 | using System.Linq; 4 | using System.Reflection.PortableExecutable; 5 | using GlobExpressions; 6 | using Newtonsoft.Json; 7 | using Serilog; 8 | using ZygorDownloader.Ioc; 9 | using ZygorDownloader.Mega; 10 | 11 | namespace ZygorDownloader.Addon 12 | { 13 | public class AddonPacker : IService 14 | { 15 | public readonly ILogger Logger; 16 | public IAddonInfoExtractor AddonInfoExtractor; 17 | 18 | public AddonPacker(ILogger logger, IAddonInfoExtractor addonInfoExtractor) 19 | { 20 | Logger = logger; 21 | AddonInfoExtractor = addonInfoExtractor; 22 | } 23 | 24 | public void Pack(DownloaderResult downloaderResult) 25 | { 26 | var directory = downloaderResult.Directory; 27 | var addonInfo = AddonInfoExtractor.Extract(downloaderResult); 28 | var addonName = new DirectoryInfo(directory).GlobDirectories("*").First().Name; 29 | var target = Path.Join("export", $"{addonName}.zip"); 30 | if (File.Exists(target)) 31 | { 32 | Logger.Information("Removing {0} in order to recreate anew", target); 33 | File.Delete(target); 34 | } 35 | ZipFile.CreateFromDirectory(Path.Join(directory, addonName), target, CompressionLevel.Fastest, true); 36 | using var f = File.CreateText(Path.Join("export", $"{addonName}.json")); 37 | f.Write(JsonConvert.SerializeObject(addonInfo, Formatting.Indented)); 38 | Logger.Information("Updated {0} to {1}", target, addonInfo.Revision); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /ZygorDownloader/Browser/BaseWebPage.cs: -------------------------------------------------------------------------------- 1 | using OpenQA.Selenium; 2 | 3 | namespace ZygorDownloader.Browser 4 | { 5 | public abstract class BaseWebPage : IWebPage 6 | { 7 | public abstract string Url { get; } 8 | 9 | public virtual void PreCheck(IWebDriver driver) 10 | { 11 | } 12 | 13 | public abstract void PerformActions(IWebDriver driver); 14 | 15 | public virtual void PostCheck(IWebDriver driver) 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /ZygorDownloader/Browser/Codedeception/LoginPage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.Configuration; 3 | using OpenQA.Selenium; 4 | using Serilog; 5 | using ZygorDownloader.Ioc; 6 | 7 | namespace ZygorDownloader.Browser.Codedeception 8 | { 9 | public class LoginPage : BaseWebPage, IService 10 | { 11 | private readonly ILogger Logger; 12 | private readonly IConfiguration configuration; 13 | 14 | public override string Url => "https://codedeception.net/index.php?/login/"; 15 | 16 | public override void PreCheck(IWebDriver driver) 17 | { 18 | FindElements(driver); 19 | } 20 | 21 | public override void PostCheck(IWebDriver driver) 22 | { 23 | if (driver.Url != "https://codedeception.net/" && !driver.Url.EndsWith("?_fromLogin=1")) 24 | { 25 | Logger.Warning( 26 | $"Url ({driver.Url}) doesn't ends with expected pattern, it may be due to login issue or remote site update"); 27 | } 28 | 29 | if (driver.PageSource.Contains("Guest!")) 30 | { 31 | Logger.Error($"Current page still contains the Guest Tag"); 32 | throw new Exception("Unable to log in"); 33 | } 34 | } 35 | 36 | public LoginPage(ILogger logger, IConfiguration configuration) 37 | { 38 | Logger = logger; 39 | this.configuration = configuration; 40 | } 41 | 42 | private static (IWebElement login, IWebElement password) FindElements(ISearchContext driver) 43 | { 44 | var loginField = driver.FindElement(By.Id("elInput_auth")); 45 | if (loginField is null) 46 | { 47 | throw new Exception("Unable to locate the login form"); 48 | } 49 | var passwordField = driver.FindElement(By.Id("elInput_password")); 50 | if (passwordField is null) 51 | { 52 | throw new Exception("Unable to locate the password form"); 53 | } 54 | return (loginField, passwordField); 55 | } 56 | 57 | public override void PerformActions(IWebDriver driver) 58 | { 59 | var (loginField, passwordField) = FindElements(driver); 60 | 61 | SubmitLoginForm(loginField, passwordField); 62 | } 63 | 64 | private void SubmitLoginForm(IWebElement loginField, IWebElement passwordField) 65 | { 66 | var config = configuration.GetSection("Codedeception"); 67 | loginField.SendKeys(config.GetValue("Login")); 68 | 69 | passwordField.SendKeys(config.GetValue("Password")); 70 | passwordField.Submit(); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /ZygorDownloader/Browser/Codedeception/Session.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using OpenQA.Selenium; 4 | using ZygorDownloader.Ioc; 5 | 6 | namespace ZygorDownloader.Browser.Codedeception 7 | { 8 | public interface ISession 9 | { 10 | ZygorPageResult CollectZygorLinks(); 11 | } 12 | 13 | public class Session : IService, ISession 14 | { 15 | private readonly WebDriverFactory _webDriverFactory; 16 | private readonly IServiceProvider _serviceProvider; 17 | 18 | public Session(IServiceProvider serviceProvider, WebDriverFactory webDriverFactory) 19 | { 20 | _webDriverFactory = webDriverFactory; 21 | _serviceProvider = serviceProvider; 22 | } 23 | 24 | public ZygorPageResult CollectZygorLinks() 25 | { 26 | using var driver = _webDriverFactory.Create(); 27 | 28 | var loginPage = _serviceProvider.GetService(); 29 | PerformPageActions(driver, loginPage); 30 | 31 | var zygorPage = _serviceProvider.GetService(); 32 | PerformPageActions(driver, zygorPage); 33 | if (zygorPage.Result != null) 34 | { 35 | return zygorPage.Result; 36 | } 37 | throw new Exception("zygorPage.Result is null"); 38 | } 39 | 40 | private static void PerformPageActions(TDriver driver, IWebPage page) where TDriver : IWebDriver 41 | { 42 | driver.Navigate().GoToUrl(page.Url); 43 | page.PreCheck(driver); 44 | page.PerformActions(driver); 45 | page.PostCheck(driver); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /ZygorDownloader/Browser/Codedeception/ZygorPage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | using OpenQA.Selenium; 4 | using Serilog; 5 | using ZygorDownloader.Ioc; 6 | 7 | namespace ZygorDownloader.Browser.Codedeception 8 | { 9 | public class ZygorPage : BaseWebPage, IService 10 | { 11 | private readonly ILogger Logger; 12 | 13 | public ZygorPage(ILogger logger) 14 | { 15 | Logger = logger; 16 | } 17 | 18 | public override string Url => "https://codedeception.net/index.php?/topic/14175-zygor-guides-bfa-classic/&page=1"; 19 | 20 | public ZygorPageResult? Result; 21 | 22 | public override void PerformActions(IWebDriver driver) 23 | { 24 | var source = driver.PageSource; 25 | 26 | var retail = ExtractZygorLink(source); 27 | var classic = ExtractZygorClassicLink(source); 28 | 29 | Result = new ZygorPageResult(retail, classic); 30 | } 31 | 32 | private static Uri ExtractZygorLink(string source) 33 | { 34 | var retailRegex = new Regex(@"Zygor\s+Retail\s+\|\s+.+?""\s*(https:\/\/.*mega.nz.*?)\s*""", RegexOptions.IgnoreCase); 35 | var m = retailRegex.Match(source); 36 | if (!m.Success) 37 | { 38 | throw new Exception("Unable to find latest zygor retail link"); 39 | } 40 | 41 | var url = m.Groups[1].Value; 42 | if (!Uri.TryCreate(url, UriKind.Absolute, out var uri)) 43 | { 44 | throw new Exception("The latest zygor retail link is not valid"); 45 | } 46 | 47 | return uri; 48 | } 49 | 50 | private static Uri ExtractZygorClassicLink(string source) 51 | { 52 | var classicRegex = new Regex(@"Zygor\s+Classic\s+\|\s+.+?""\s*(https:\/\/.*?mega.nz.*?)\s*""", RegexOptions.IgnoreCase); 53 | var m = classicRegex.Match(source); 54 | if (!m.Success) 55 | { 56 | throw new Exception("Unable to find latest zygor classic link"); 57 | } 58 | 59 | var url = m.Groups[1].Value; 60 | if (!Uri.TryCreate(url, UriKind.Absolute, out var uri)) 61 | { 62 | throw new Exception("The latest zygor classic link is not valid"); 63 | } 64 | 65 | return uri; 66 | } 67 | } 68 | 69 | public class ZygorPageResult 70 | { 71 | public readonly Uri ZygorUrl; 72 | public readonly Uri ZygorClassicUrl; 73 | 74 | public ZygorPageResult(Uri zygorUrl, Uri zygorClassicUrl) 75 | { 76 | ZygorUrl = zygorUrl; 77 | ZygorClassicUrl = zygorClassicUrl; 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /ZygorDownloader/Browser/IWebPage.cs: -------------------------------------------------------------------------------- 1 | using OpenQA.Selenium; 2 | 3 | namespace ZygorDownloader.Browser 4 | { 5 | public interface IWebPage where TWebDriver : IWebDriver 6 | { 7 | public string Url { get; } 8 | 9 | public void PreCheck(TWebDriver driver); 10 | 11 | public void PerformActions(TWebDriver driver); 12 | public void PostCheck(TWebDriver driver); 13 | } 14 | } -------------------------------------------------------------------------------- /ZygorDownloader/Browser/WebDriverFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using Microsoft.Extensions.Configuration; 5 | using OpenQA.Selenium; 6 | using OpenQA.Selenium.Chrome; 7 | using ZygorDownloader.Ioc; 8 | 9 | namespace ZygorDownloader.Browser 10 | { 11 | public interface IWebDriverFactory 12 | { 13 | IWebDriver Create(); 14 | } 15 | 16 | public class WebDriverFactory : IWebDriverFactory, IService 17 | { 18 | private readonly IConfigurationSection _chromeConfig; 19 | 20 | public WebDriverFactory(IConfiguration configuration) 21 | { 22 | _chromeConfig = configuration.GetSection("Selenium:Chrome"); 23 | } 24 | 25 | public IWebDriver Create() 26 | { 27 | // ReSharper disable once UseObjectOrCollectionInitializer 28 | var options = new ChromeOptions(); 29 | 30 | #if DEBUG 31 | options.LeaveBrowserRunning = true; 32 | #else 33 | HeadlessMode(options); 34 | #endif 35 | InjectConfiguration(options); 36 | DisableImageLoading(options); 37 | return new ChromeDriver(options); 38 | } 39 | 40 | private void InjectConfiguration(ChromeOptions options) 41 | { 42 | var arguments = _chromeConfig.GetValue("Arguments", new List()); 43 | if (arguments.Any()) 44 | { 45 | options.AddArguments(arguments.ToArray()); 46 | } 47 | } 48 | 49 | private void HeadlessMode(ChromeOptions options) 50 | { 51 | if (!_chromeConfig.GetValue("Headless", true)) return; 52 | if (options.Arguments.Contains("--headless")) return; 53 | options.AddArguments("--headless", "--disable-extensions", "--disable-gpu"); 54 | } 55 | 56 | private void DisableImageLoading(ChromeOptions options) 57 | { 58 | if (!_chromeConfig.GetValue("DisableImageLoading", true)) return; 59 | options.AddUserProfilePreference("profile.managed_default_content_settings.images", 2); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /ZygorDownloader/Ioc/IService.cs: -------------------------------------------------------------------------------- 1 | namespace ZygorDownloader.Ioc 2 | { 3 | public interface IService 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /ZygorDownloader/Ioc/SerilogContextualLoggerInjectionBehavior.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Serilog; 3 | using Serilog.Core; 4 | using SimpleInjector; 5 | using SimpleInjector.Advanced; 6 | 7 | namespace ZygorDownloader.Ioc 8 | { 9 | public class SerilogContextualLoggerInjectionBehavior : IDependencyInjectionBehavior 10 | { 11 | private readonly IDependencyInjectionBehavior original; 12 | private readonly Container container; 13 | private readonly Logger logger; 14 | 15 | public SerilogContextualLoggerInjectionBehavior(ContainerOptions options, Logger logger) 16 | { 17 | this.logger = logger; 18 | original = options.DependencyInjectionBehavior; 19 | container = options.Container; 20 | } 21 | 22 | public void Verify(InjectionConsumerInfo consumer) => original.Verify(consumer); 23 | 24 | public bool VerifyDependency(InjectionConsumerInfo dependency, out string? errorMessage) 25 | { 26 | return original.VerifyDependency(dependency, out errorMessage); 27 | } 28 | 29 | public InstanceProducer? GetInstanceProducer(InjectionConsumerInfo i, bool t) => 30 | i.Target.TargetType == typeof(ILogger) 31 | ? GetLoggerInstanceProducer(i.ImplementationType) 32 | : original.GetInstanceProducer(i, t); 33 | 34 | private InstanceProducer GetLoggerInstanceProducer(Type type) => 35 | Lifestyle.Singleton.CreateProducer( 36 | () => logger.ForContext(type), 37 | container); 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /ZygorDownloader/Mega/DownloaderResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ZygorDownloader.Mega 4 | { 5 | public class DownloaderResult : IDisposable 6 | { 7 | public readonly string Directory; 8 | public readonly string OriginalFileName; 9 | public readonly string OriginalId; 10 | public readonly string OriginalOwner; 11 | public readonly DateTime OriginalDate; 12 | 13 | public DownloaderResult(string directory, string originalFileName, string originalId, string originalOwner, DateTime originalDate) 14 | { 15 | Directory = directory; 16 | OriginalFileName = originalFileName; 17 | OriginalId = originalId; 18 | OriginalOwner = originalOwner; 19 | OriginalDate = originalDate; 20 | } 21 | 22 | public void Dispose() 23 | { 24 | System.IO.Directory.Delete(Directory, true); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /ZygorDownloader/Mega/RarDownloader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using CG.Web.MegaApiClient; 5 | using Serilog; 6 | using SevenZipExtractor; 7 | using ZygorDownloader.Ioc; 8 | 9 | namespace ZygorDownloader.Mega 10 | { 11 | public interface IRarDownloader 12 | { 13 | DownloaderResult DownloadFolder(Uri uri); 14 | } 15 | 16 | public class RarDownloader : IService, IRarDownloader 17 | { 18 | private readonly ILogger Logger; 19 | 20 | public RarDownloader(ILogger logger) 21 | { 22 | Logger = logger; 23 | } 24 | 25 | public DownloaderResult DownloadFolder(Uri uri) 26 | { 27 | var client = new MegaApiClient(); 28 | client.LoginAnonymous(); 29 | 30 | Logger.Debug("Successfully log into mega"); 31 | try 32 | { 33 | var nodes = client.GetNodesFromLink(uri) 34 | .Where(x => x.Type == NodeType.File && x.Name.EndsWith(".rar")) 35 | .ToArray(); 36 | if (nodes.Length > 1) 37 | { 38 | throw new Exception("There's more that 1 rar file on the mega folder"); 39 | } 40 | else if (nodes.Length <= 0) 41 | { 42 | throw new Exception("There's no rar in the remote mega folder"); 43 | } 44 | 45 | Logger.Debug("Found a rar file in {0}", uri); 46 | 47 | var node = nodes[0]; 48 | 49 | 50 | var path = Path.GetTempFileName(); 51 | Logger.Debug("Downloading {0} into {1}", node.Name, path); 52 | try 53 | { 54 | using var file = File.Open(path, FileMode.Truncate); 55 | 56 | { 57 | using var downloadStream = client.Download(node); 58 | downloadStream.CopyTo(file); 59 | } 60 | 61 | file.Seek(0, 0); 62 | using var rar = new ArchiveFile(file); 63 | var dir = path + ".extracted"; 64 | Logger.Debug("Extracting into {0}", dir); 65 | Directory.CreateDirectory(dir); 66 | try 67 | { 68 | rar.Extract(dir); 69 | return new DownloaderResult(dir, node.Name, node.Id, node.Owner, node.ModificationDate ?? node.CreationDate); 70 | } 71 | catch 72 | { 73 | Logger.Warning("Deleting {0} before throwing", dir); 74 | Directory.Delete(dir, true); 75 | throw; 76 | } 77 | } 78 | finally 79 | { 80 | Logger.Debug("Removing temporary file {0}", path); 81 | File.Delete(path); 82 | } 83 | } 84 | finally 85 | { 86 | client.Logout(); 87 | } 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /ZygorDownloader/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Threading; 6 | using Microsoft.Extensions.Configuration; 7 | using Serilog; 8 | using Serilog.Core; 9 | using Serilog.Exceptions; 10 | using SimpleInjector; 11 | using ZygorDownloader.Addon; 12 | using ZygorDownloader.Browser; 13 | using ZygorDownloader.Browser.Codedeception; 14 | using ZygorDownloader.Ioc; 15 | using ZygorDownloader.Mega; 16 | 17 | namespace ZygorDownloader 18 | { 19 | class Program 20 | { 21 | static readonly Container container; 22 | static Program() 23 | { 24 | container = new Container(); 25 | 26 | var configuration = new ConfigurationBuilder() 27 | .SetBasePath(Directory.GetCurrentDirectory()) 28 | .AddJsonFile("appsettings.json", false) 29 | .AddEnvironmentVariables(prefix: "ZY_") 30 | .AddJsonFile("overrides.json", true) 31 | .Build(); 32 | 33 | var serilogConfig = new LoggerConfiguration() 34 | .Enrich.WithExceptionDetails() 35 | .Enrich.FromLogContext() 36 | .ReadFrom.Configuration(configuration); 37 | 38 | var logger = serilogConfig.CreateLogger(); 39 | 40 | container.Options.DependencyInjectionBehavior = 41 | new SerilogContextualLoggerInjectionBehavior(container.Options, logger); 42 | 43 | container.RegisterInstance(typeof(IServiceProvider), container); 44 | container.RegisterInstance(typeof(Logger), logger); 45 | container.RegisterInstance(typeof(LoggerConfiguration), serilogConfig); 46 | container.RegisterInstance(configuration.GetType(), configuration); 47 | container.RegisterInstance(typeof(IConfiguration), configuration); 48 | container.RegisterInstance(typeof(IConfigurationRoot), configuration); 49 | 50 | var registrations = 51 | from type in Assembly.GetCallingAssembly().GetExportedTypes() 52 | where type.Namespace?.StartsWith("ZygorDownloader.") ?? false 53 | where type.GetInterfaces().Contains(typeof(IService)) 54 | from service in type.GetInterfaces() 55 | select new { service, implementation = type }; 56 | 57 | container.Options.AllowOverridingRegistrations = true; 58 | foreach (var reg in registrations) 59 | { 60 | container.Register(reg.service, reg.implementation, Lifestyle.Transient); 61 | container.Register(reg.implementation, reg.implementation, Lifestyle.Transient); 62 | } 63 | container.Options.AllowOverridingRegistrations = false; 64 | 65 | container.Verify(); 66 | } 67 | 68 | 69 | static void Main(string[] args) 70 | { 71 | var session = container.GetInstance(); 72 | var links = session.CollectZygorLinks(); 73 | if (!Directory.Exists("export")) 74 | { 75 | Directory.CreateDirectory("export"); 76 | } 77 | 78 | foreach (var link in new []{links.ZygorUrl, links.ZygorClassicUrl}) 79 | { 80 | using var res = container.GetInstance().DownloadFolder(link); 81 | container.GetInstance().Pack(res); 82 | } 83 | 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /ZygorDownloader/ZygorDownloader.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Always 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ZygorDownloader/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Serilog": { 3 | "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ], 4 | "MinimumLevel": "Debug", 5 | "WriteTo": [ 6 | { "Name": "Console" }, 7 | { "Name": "File", "Args": { "path": "Logs/log.txt" } } 8 | ], 9 | "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], 10 | "Destructure": [ 11 | { "Name": "ToMaximumDepth", "Args": { "maximumDestructuringDepth": 4 } }, 12 | { "Name": "ToMaximumStringLength", "Args": { "maximumStringLength": 100 } }, 13 | { "Name": "ToMaximumCollectionCount", "Args": { "maximumCollectionCount": 10 } } 14 | ], 15 | "Properties": { 16 | "Application": "ZygorDownloader" 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /docs/css/custom.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | background-color: #252525 4 | } 5 | 6 | body { 7 | min-height:100vh; 8 | } 9 | 10 | .flex-fill { 11 | flex:1 1 auto; 12 | } 13 | 14 | p, h1, h2, h3, h4, pre 15 | { 16 | color: white 17 | } 18 | 19 | .fill { 20 | min-height: 100%; 21 | height: 100%; 22 | } 23 | 24 | span.underline { 25 | border-bottom: 0.2em solid orange; 26 | padding-bottom: 0.05em; 27 | } 28 | 29 | .btn-dl { 30 | min-width: max(9vw, 5em); 31 | width: 10.5vw; 32 | white-space: normal; 33 | } -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zygor Downloader 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |

Zygor Downloader

21 |
22 |
23 |
24 | 25 |
26 |
27 |
28 |
Always up to date Zygor guides
29 |
30 |
31 |
32 |
33 |
34 |

Retail

35 |
36 |
37 |

Classic

38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |

Copyright © tieonlinux. All rights reserved.

46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 | 54 | 61 | 62 | --------------------------------------------------------------------------------