From 26ac94b62157df64fa55718395ea986271f759a5 Mon Sep 17 00:00:00 2001 From: jvlflame Date: Tue, 1 Sep 2020 00:19:23 -0700 Subject: [PATCH] Remove legacy files --- .../Private/New-CloudflareSession.ps1 | 69 ------------------- src/Javinizer/Private/Update-Javinizer.ps1 | 29 -------- src/Javinizer/cfscraper.py | 8 --- 3 files changed, 106 deletions(-) delete mode 100644 src/Javinizer/Private/New-CloudflareSession.ps1 delete mode 100644 src/Javinizer/Private/Update-Javinizer.ps1 delete mode 100644 src/Javinizer/cfscraper.py diff --git a/src/Javinizer/Private/New-CloudflareSession.ps1 b/src/Javinizer/Private/New-CloudflareSession.ps1 deleted file mode 100644 index 647b9a30..00000000 --- a/src/Javinizer/Private/New-CloudflareSession.ps1 +++ /dev/null @@ -1,69 +0,0 @@ -function New-CloudflareSession { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Position = 0)] - [string]$Url = "http://www.javlibrary.com/en/", - [string]$ScriptRoot - ) - - begin { - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function started" - $cookieName = @() - $cookieContent = @() - $requestObject = @() - $cfPath = Join-Path -Path $ScriptRoot -ChildPath 'cfscraper.py' - } - - process { - if ($PSCmdlet.ShouldProcess('Current Shell', 'Create new CloudFlare session')) { - try { - if ([System.Environment]::OSVersion.Platform -eq 'Win32NT') { - $cfScrape, $userAgent = python $cfPath $Url - } elseif ([System.Environment]::OSVersion.Platform -eq 'Unix') { - $cfScrape, $userAgent = python3 $cfPath $Url - } - } catch { - throw $_ - } - - $cfScrapeSplit = ($cfScrape -split ";").Trim() - - foreach ($cookie in $cfScrapeSplit) { - $cookieName += ($cookie -split '=')[0] - $cookieContent += ($cookie -split '=')[1] - } - - $requestObject += [pscustomobject]@{ - CookieName = $cookieName - CookieContent = $cookieContent - UserAgent = $userAgent - } - - $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession - - - # Create __cfuid cookie - $cookie = New-Object System.Net.Cookie($requestObject.CookieName[0], $requestObject.CookieContent[0], '/', 'javlibrary.com') - $session.Cookies.Add($cookie) - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Cookie __cfuid: [$($requestObject.CookieContent[0])]" - - - # Create cf_clearance cookie - $cookie = New-Object System.Net.Cookie($requestObject.CookieName[1], $requestObject.CookieContent[1], '/', 'javlibrary.com') - $session.Cookies.Add($cookie) - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Cookie cf_clearance: [$($requestObject.CookieContent[1])]" - - # Replace WebRequest session UserAgent with UserAgent created by cfscrape - # This is needed so that you will not be flagged as a bot by CloudFlare - $session.UserAgent = $requestObject.UserAgent - } - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] UserAgent: [$($session.UserAgent)]" - $global:Session = $session - $global:SessionCFDUID = $requestObject.CookieContent[0] - } - - end { - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Successfully created session with Cloudflare" - Write-Debug "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] Function ended" - } -} diff --git a/src/Javinizer/Private/Update-Javinizer.ps1 b/src/Javinizer/Private/Update-Javinizer.ps1 deleted file mode 100644 index 645e094c..00000000 --- a/src/Javinizer/Private/Update-Javinizer.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -function Update-Javinizer { - $currentVer = (Get-InstalledModule -Name Javinizer -ErrorAction 'SilentlyContinue').Version - $latestVer = (Find-Module -Name Javinizer -ErrorAction 'SilentlyContinue').Version - - if ($null -eq $currentVer) { - # do nothing - } elseif ($currentVer -ne $latestVer) { - Write-Host "[$(Get-TimeStamp)][$($MyInvocation.MyCommand.Name)] There is a newer version of Javinizer available: [$currentVer --> $latestVer]" -ForegroundColor Red - } -} - - -<# -function Update-Javinizer { - param ( - [string]$ScriptRoot, - [object]$Settings - ) - - $currentVer = (Get-InstalledModule -Name Javinizer).Version - $latestVer = (Find-Module -Name Javinizer).Version - Update-Module -Name Javinizer -AcceptLicense -Confirm:$false -Force - - $modulePaths = (Get-Module -ListAvailable).Path | Where-Object { $_ -match 'Javinizer' } - $currentVerPath = (Get-Item ($modulePaths | Where-Object { $_ -match "$currentVer" })).DirectoryName - $latestVerPath = (Get-Item ($modulePaths | Where-Object { $_ -match "$latestVer" })).DirectoryName - -} -#> diff --git a/src/Javinizer/cfscraper.py b/src/Javinizer/cfscraper.py deleted file mode 100644 index ace8df5b..00000000 --- a/src/Javinizer/cfscraper.py +++ /dev/null @@ -1,8 +0,0 @@ -import cloudscraper -import sys - -cookie_value, user_agent = cloudscraper.get_cookie_string( - sys.argv[1], browser={'browser': 'chrome', 'mobile': False}) -#cookie_value, user_agent = cloudscraper.get_cookie_string(sys.argv[1]) - -print('{}\n{}'.format(cookie_value, user_agent))