DonationCoder.com Software > Post New Requests Here
IDEA - Create a text doc of an artists discography.
4wd:
--- Code: PowerShell ---<# .\DiscoFile-MB3.ps1 <Uri> Given the URI from https://musicbrainz.org for an artist it will retrieve the discography. eg. .\DiscoFile-MB3.ps1 https://musicbrainz.org/artist/66c662b6-6e2f-4930-8610-912e24c63ed1 Will result in a file called 'AC_DC-MB - Discography.txt' in the same directory as DiscoFile-MB3.ps1 #> param ( [string]$Uri) $web = (Invoke-WebRequest -Uri $Uri).RawContent $temp = $web -replace '[\s\S]+application\/ld\+json..([\s\S]+?)<\/script>[\s\S]*$', '$1' $json = $temp | ConvertFrom-Json $outFile = ($json.name + "-MB - Discography.txt").Split([IO.Path]::GetInvalidFileNameChars()) -join '_'if (Test-Path $outFile) { Remove-Item $outFile -Force} for ($i = 0; $i -lt $json.album.Count; $i++) { $temp = $json.album[$i].albumReleaseType if ($temp -match 'AlbumRelease') { $temp = $json.album[$i].albumProductionType if (($temp -match '(LiveAlbum)|(StudioAlbum)') -and !($temp -match '(CompilationAlbum)|(SoundtrackAlbum)')) { $albumUri = ($json.album[$i].'@id' + "?inc=releases&fmt=json") -replace '\.org\/', '.org/ws/2/' $album = (Invoke-WebRequest -Uri "$($albumUri)") | ConvertFrom-Json "$($album.releases[0].date.Substring(0,4)) - $($album.title)" | Out-File -FilePath $outFile -Append } }} Get-Content $outFile | Sort-Object | Set-Content $outFile
--- Code: Text ---1975 - High Voltage1975 - T.N.T.1976 - Dirty Deeds Done Dirt Cheap1976 - High Voltage1977 - Let There Be Rock1978 - If You Want Blood You???ve Got It1978 - Live from the Atlantic Studios1978 - Powerage1979 - Highway to Hell1980 - Back in Black1981 - For Those About to Rock (We Salute You)1983 - Flick of the Switch1985 - Fly on the Wall1988 - Blow Up Your Video1990 - The Razors Edge1992 - Live at Donington1995 - Ballbreaker1996 - No Bull: Live - Plaza De Toros, Madrid1996 - Westwood One Superstars In Concert Series2000 - Stiff Upper Lip2001 - Stiff Upper Lip: Live2007 - Plug Me In2008 - Black Ice2011 - Live at River Plate2014 - Rock or Bust2018 - Legendary FM Broadcasts - The Paradise Theatre, Boston MA 21st August 19782018 - Live At Paradise Theatre Boston 19782019 - Live at the Apocalypse2020 - AC/DC FM Broadcast Boston 19782020 - Power Up
fred dred:
:o :D
fred dred:
Any idea why I get
IDEA - Create a text doc of an artists discography.
And my text doc looks like
--- ---1975 - High Voltage
1975 - T.N.T.
1976 - Dirty Deeds Done Dirt Cheap
1976 - High Voltage
1977 - Let There Be Rock
1978 - Powerage
1979 - Highway to Hell
1980 - Back in Black
1981 - For Those About to Rock (We Salute You)
1983 - Flick of the Switch
1985 - Fly on the Wall
1988 - Blow Up Your Video
1990 - The Razors Edge
1995 - Ballbreaker
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
2000 - Stiff Upper Lip
I also get the same errors when searching Aerosmith
--- ---.\DiscoFile-MB3.ps1 https://musicbrainz.org/artist/3d2b98e5-556f-4451-a3ff-c50ea18d57cb Their list looks like
--- ---1973 - Aerosmith
1974 - Get Your Wings
1975 - Toys in the Attic
1976 - Rocks
1977 - Draw the Line
1979 - Night in the Ruts
1982 - Rock in a Hard Place
1985 - Done With Mirrors
1987 - Permanent Vacation
1989 - Pump
1993 - Get a Grip
1997 - Nine Lives
2001 - Just Push Play
2004 - Honkin??? on Bobo
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
2012 - Music From Another Dimension!
It seems to work fine searching for artists with smaller catalogues , ie 3 Doors Down (2386cd66-e923-4e8e-bf14-2eebe2e9b973)
Could it be a 'Too Many Requests' type issue? - they both failed on the 16th request.... coincidence?
(Just for info, I'm logged in on the MB site)
4wd:
The only way being logged in, (or not), to the site would matter is if you are also doing searches or browsing at the same time, since you're increasing the number of requests per second.
It looks like they impose a rate limit of one request per second from the same IP, (strange I never hit it), unless it's from specific software, (eg. picard), or uses a recognisable UserAgent, (ie. a browser, PowerShell probably doesn't by default - I might look at how you can add it, if it's possible).
You can try putting in a Start-Sleep -seconds 1 after the for statement, that will delay the requests to about one per second.
Adjust the number up as necessary to increase the delay between requests, especially if you are browsing the site at the same time.
Or use Opera to browse the site with its internal VPN turned on so it looks like a different IP.
EDIT: Looks like PowerShell has its own UserAgent but can use one of the more standard browser settings which may decrease the rate limiting. I'll look at it later today if I have time, or you can have a play ;)
https://stackoverflow.com/questions/49863488/is-there-a-unique-user-agent-value-for-a-powershell-request
fred dred:
I was logged into the MB site, but I wasn't using it - I just added that info because 'more info is more better' when it comes to figuring out why it aint working :)
Adding a delay of 0.55 seconds to the loop seems to have fixed it :Thmbsup:
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version