Skip to content

Commit 13a92ad

Browse files
committed
update anime name lists
1 parent e00eee4 commit 13a92ad

File tree

4 files changed

+35840
-3849
lines changed

4 files changed

+35840
-3849
lines changed

get-names_anidb.ps1

+8-7
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ param(
2222
#$ProgressPreference = "SilentlyContinue"
2323

2424
$page = $startpage
25-
$total = 3971
25+
$total = 4528
2626
$result = @()
2727
$hasNextPage = $false
28+
$delay = 3.5
2829

2930
# get anonymous sesssion
3031
Invoke-WebRequest "https://anidb.net" -SessionVariable 'Session' | Out-Null
31-
Start-Sleep -Seconds 2
32+
Start-Sleep -Seconds $delay
3233

3334
function Request-Page($num)
3435
{
@@ -37,7 +38,7 @@ function Request-Page($num)
3738
$url = "https://anidb.net/character/?noalias=1&orderby.name=0.1&page=$num&view=list"
3839
$response = Invoke-WebRequest $url -WebSession $Session
3940
#$links = @($response.links | Where-Object { $_.href -match '/character/\d+$' } | Where-Object { $_.outerHTML -match '^<a [^>]+>[^<][^\n]+</a>$' })
40-
Start-Sleep -Seconds 3
41+
Start-Sleep -Seconds $delay
4142
return $response.Content
4243
}
4344

@@ -101,8 +102,8 @@ do
101102
Write-Host 'Saving the results...'
102103
'# https://anidb.net/character' | Out-File -LiteralPath $output
103104
$result | Sort-Object | Get-Unique | Out-File -LiteralPath $output -Append
104-
Read-Host -Prompt 'Rate limited, plz unban...'
105-
continue
105+
Write-Host 'Rate limited, plz unban...'
106+
break
106107
}
107108
else
108109
{
@@ -123,7 +124,7 @@ do
123124
$pos = $html.IndexOf('<a href=', $pos)
124125
$pos = $html.IndexOf('>', $pos)
125126
$endPos = $html.IndexOf('</a></td>', $pos)
126-
$name = $html.Substring($pos + 1, $endPos - $pos - 1).Replace(' ', ' ').Trim()
127+
$name = $html.Substring($pos + 1, $endPos - $pos - 1).Replace(' ', ' ').Replace('`', "'").Trim()
127128

128129
$pos = $html.IndexOf('<td data-label="Type"', $endPos)
129130
$pos = $html.IndexOf('>', $pos)
@@ -163,7 +164,7 @@ do
163164
$hasNextPage = $false
164165
}
165166
} while ($hasNextPage)
166-
Write-Host "Stopped on page $page"
167+
Write-Host "Stopped on page $page/$total"
167168
Write-Progress -Activity "Downloading" -Completed
168169

169170
Write-Host 'Saving the results...'

get-names_anilist.ps1

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ param(
2020

2121
$requestTemplate = '{ "query": "query { Page (page: {0}, perPage: 50) { characters { name { full } } pageInfo { hasNextPage lastPage } } }" }'
2222
$page = $startPage
23-
$total = 2565
23+
$total = 3171
2424
$result = @()
2525
$hasNextPage = $false
26+
$delay = 3
2627

2728
function Request-Page($num)
2829
{
2930
$json = $requestTemplate.Replace('{0}', $num)
3031
$response = Invoke-RestMethod 'https://graphql.anilist.co' -Method Post -Body $json -ContentType "application/json" -TimeoutSec 30
31-
Start-Sleep -Seconds 1.5
32+
Start-Sleep -Seconds $delay
3233
return $response.data.Page
3334
}
3435

@@ -89,7 +90,7 @@ do
8990
$name = $char.name.full
9091
if ($null -eq $name) { continue }
9192

92-
$name = $char.name.full.Replace(' ', ' ').Trim()
93+
$name = $char.name.full.Replace(' ', ' ').Replace('`', "'").Trim()
9394
if (($name.Length -lt 2) -or ("$name" -match '^\d+$'))
9495
{
9596
Write-Host "Skipping $name"
@@ -115,7 +116,7 @@ do
115116
$hasNextPage = $false
116117
}
117118
} while ($hasNextPage)
118-
Write-Host "Stopped on page $page"
119+
Write-Host "Stopped on page $page/$total"
119120
Write-Progress -Activity "Downloading" -Completed
120121

121122
Write-Host 'Saving the results...'

0 commit comments

Comments
 (0)