ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

IDEA - Create a text doc of an artists discography.

<< < (2/5) > >>

4wd:
I'm not going to offer an all encompassing solution but here's something simple in PowerShell that uses Discogs - it might inspire someone ;)


--- Code: PowerShell ---<#  .\DiscoFile.ps1 <Uri>   Given the URI from https://www.discogs.com for an artist it will retrieve the  discography.   eg.   .\DiscoFile.ps1 https://www.discogs.com/artist/84752-ACDC   Will result in a file called 'AC_DC - Discography.txt' in the same directory as  DiscoFile.ps1  #> param (  [string]$Uri) $web = (Invoke-WebRequest -Uri $Uri).RawContent $temp = $web -replace '[\s\S]+artist_schema..([\s\S]+?)<\/script>[\s\S]*$', '$1' $json = $temp | ConvertFrom-Json $outFile = ($json.name + " - Discography.txt").Split([IO.Path]::GetInvalidFileNameChars()) -join '_' for ($i = 0; $i -lt $json.album.Count; $i++) {  "$($json.album[$i].datePublished) - $($json.album[$i].name)" | Out-File -FilePath $outFile -Append}
Using the example above, output will be to 'AC_DC - Discography.txt' and look like:

--- Code: Text ---1975 - T.N.T.1975 - High Voltage1976 - Dirty Deeds Done Dirt Cheap1976 - High Voltage1976 - Dirty Deeds Done Dirt Cheap1977 - Let There Be Rock1978 - Powerage1978 - If You Want Blood You've Got It1979 - Highway To Hell1980 - In Concert-2151980 - Back In Black1981 - For Those About To Rock (We Salute You)1983 - Special Radio Interview Disc1983 - Flick Of The Switch1985 - Fly On The Wall1988 - Blow Up Your Video1990 - AC/DC Interview1990 - The Razors Edge1992 - Live
Why did I choose Discogs even though the album data is incomplete?


--- Code: PowerShell ---$json = $temp | ConvertFrom-Json
Album data is available in JSON format which makes retrieving it trivial.

Having a quick look at MusicBrainz, it appears to also be in JSON format - maybe I'll devote an extra 30 5 mins to this ;)

MusicBrainz version, they don't appear to include the year in the JSON data though:


--- Code: PowerShell ---<#  .\DiscoFile-MB.ps1 <Uri>   Given the URI from https://musicbrainz.org for an artist it will retrieve the  discography.   eg.   .\DiscoFile-MB.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.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 '_' for ($i = 0; $i -lt $json.album.Count; $i++) {  "$($json.album[$i].name)" | Out-File -FilePath $outFile -Append}

fred dred:
Thank you very, very much for taking the time to do this !

I've never used powershell, so it took half an hour to figure out how to get it to run, but works great now :)

The discogs output is good, but as you said, it's far from complete - so it doesn't really help as a resource to check my collection against.

The MusicBrainz output is brilliant - but no dates means it's a pain to cross reference with my existing files.

But thank you again for taking a look - you've done far more than I ever accomplished in the months and months of tinkering with Python !

Cheers :)

 

4wd:
Thank you very, very much for taking the time to do this !-fred dred (November 07, 2020, 02:36 AM)
--- End quote ---

No problem, it was quite literally 20 minutes of playing around - working out the RegEx to remove everything I didn't want took the most time.

The MusicBrainz output is brilliant - but no dates means it's a pain to cross reference with my existing files.
--- End quote ---

You can get the dates, you just have to follow every album link but they do provide the info in JSON format without having to strip it out of the page.

For example, AC/DC's High Voltage:

XML
JSON

So it can be obtained, just grab the JSON and pull out the first date value, as an example:


--- Code: PowerShell ---$album = (Invoke-WebRequest -Uri "https://musicbrainz.org/ws/2/release-group/2b81e645-4586-4456-843a-9bc19a217470?inc=releases&fmt=json") | ConvertFrom-Json"$($album.releases[0].date) - $($album.title)"
The only problem being multiple release dates, eg. for that particular entry there are nine dates ... which one do you choose really?

Considering MusicBrainz provide album data in JSON, I'm kind of surprised that the artist page doesn't provide the same, (I mean including the album details, ie. combined artist+releases).

4wd:
This'll just grab the first date in a release:


--- Code: PowerShell ---<#  .\DiscoFile-MB2.ps1 <Uri>   Given the URI from https://musicbrainz.org for an artist it will retrieve the  discography.   eg.   .\DiscoFile-MB2.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.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++) {  $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) - $($album.title)" | Out-File -FilePath $outFile -Append}
Example output:

--- Code: Text ---1976-02-14 - Dreamboat Annie1977-04-19 - Magazine1977-05-15 - Little Queen1978-10-07 - Dog & Butterfly1980-02-14 - B??b?? le Strange1982-06-05 - Private Audition1983-08-20 - Passionworks1985-07-06 - Heart1987-06-05 - Bad Animals1990-03-26 - Brigade1993-10-30 - Desire Walks On2004-06-22 - Jupiters Darling2010-08-27 - Red Velvet Car2012-09-28 - Fanatic2016-07-08 - Beautiful Broken1980-11-29 - Greatest Hits / Live1981 - Heart: Best of the Early Years1995-12-11 - Definitive Collection1996-07-03 - Ballads: The Greatest Hits1997-03-11 - These Dreams: Heart???s Greatest Hits1998-08-25 - Greatest Hits2000-06-27 - Greatest Hits: 1985???19952002-11-26 - The Essential Heart2005-09-27 - Love Alive2005-11-15 - The Collection2006-01-10 - Love Songs2008 - Playlist: The Very Best of Heart2009 - Private Audition / Passionworks2011-06-23 - Heart / Bad Animals2012-06-01 - Strange Euphoria2012 - Super Hits2013-05-13 - Icon2013 - Original Album Classics2014-10-14 - The Box Set Series1991-09-24 - Rock the House Live!1995-08-09 - The Road Home2003 - Alive in Seattle2007-10-23 - Dreamboat Annie Live2008-08-05 - Live2014-02-21 - Fanatic Live From Caesars Colosseum2014-11-07 - Heart & Friends: Home for the Holidays2016-11-25 - Live at the Royal Albert Hall2019-01-25 - Live in Atlantic City1975-06 - Magic Man1975 - Crazy on You1975 - How Deep It Goes1976-12 - Dreamboat Annie1976 - (Love Me Like Music) I???ll Be Your Song1977 - Barracuda1977 - Heartless1977 - Kick It Out1977 - Little Queen / Treat Me Well1978 - Straight On1978 - Without You1985-09-14 - Never1985 - Nothin??? at All1986-01-18 - These Dreams1986-07-19 - If Looks Could Kill1987 - There???s the Girl1987 - Who Will You Run To1988-02 - Never / These Dreams1990-03-28 - All I Wanna Do Is Make Love to You1990-09 - Stranded1990 - I Didn???t Want to Need You1990 - Secret1991 - You???re the Voice1993-11 - Black on Black II1993 - Will You Be There (In the Morning)1994 - The Woman in Me1998 - What About Love2012-08-21 - Fanatic2013-11-08 - Heart Christmas Single 20132017-11-03 - Band on the Run2017-11-03 - Letting Go2013-01-15 - Stairway to Heaven (live at the Kennedy Center Honors)2018-10-23 - Lost Angel2019-01-11 - B??b?? le Strange2019-01-16 - Crazy on You2012-11-12 - A Million Miles (Abe Clements remix)1988 - If Looks Could Kill2010-03-05 - WTF+4
You could add filtering to restrict it to certain types of releases by matching in the albumProductionType or albumReleaseType, eg.


--- Code: PowerShell ---for ($i = 0; $i -lt $json.album.Count; $i++) {  if ($json.album[$i].albumProductionType -match 'StudioAlbum') {    $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) - $($album.title)" | Out-File -FilePath $outFile -Append  }}
So goes the theory :P

fred dred:
(EDIT - I was writing this as you posted your last post above)

The only problem being multiple release dates, eg. for that particular entry there are nine dates ... which one do you choose really?
-4wd (November 07, 2020, 03:21 AM)
--- End quote ---

That's one of the reasons I became fixated on the allmusic site.

Here's the info. There's a nice list of release dates and album titles, surely it can't be that difficult I kept telling myself - to my mind it's just a matter of pulling those bit's of info off the page haha. (My coding skills are extremely basic, and I just couldn't get any of the Python modules to get the info I wanted - or even to work most of the time if I'm honest).

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version