Skip to main content

Topic: [Not my release] Biography view (Read 324184 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • romor
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #550
On a side note, if resource investigated can be validated as XML, i.e. XHTML, there is no need for "API", as that's already webservice in a manner of speaking. That of course, purposely, is not the case here, nor on discogs, allmusic ...

It seems that last.fm biography can however be accessed from third party webservice, like echonest: http://developer.echonest.com/api/v4/artis...=jennifer+lopez

  • marc2003
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #551
it's nothing like a webservice. it's not documented and is subject to change at any time without notification. also there is the issue of copyright and it's usually slower as well.

and i've looked at echonest before and i can't use it. there are no line breaks which makes large articles pretty much unreadable.

  • romor
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #552
Yeah, subject to change like we are witnessing. You get notified by user complaint.
It could be slower if you are accessing HTML DOM, while XHTML as XML is at as same speed as your "API webservices", because it's same technology.

Echonest response does have line breaks. Perhaps you can't see it rendered by XML style sheet in your browser, if you just clicked above link.

  • marc2003
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #553
it's not that - i tested the JSON response in a script some time ago when i discovered no line breaks. i'll take another look though....

edit: found my old post from august 2011 about it here: http://www.hydrogenaudio.org/forums/index....st&p=767576

edit2: tested again and still not usable. screenshot shows last.fm on the left and wikipedia on the right....

http://dl.dropbox.com/u/22801321/lastfm%20wiki.png
  • Last Edit: 20 February, 2013, 05:54:13 AM by marc2003

  • romor
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #554
In json response, new line is escaped with '\n'
Also double quotes are escaped with '\"'

Edit: On screenshot right perhaps there is issue as that content source was table perhaps. And that's also for wikipedia article, which is not needed as wikipedia can be accessed natively with their werservice
  • Last Edit: 20 February, 2013, 06:05:20 AM by romor

  • marc2003
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #555
In json response, new line is escaped with '\n'


in theory, yes. but take a look at the raw source.

http://developer.echonest.com/api/v4/artis...=jennifer+lopez

they are there in the wikipedia segment but not the last.fm...
  • Last Edit: 20 February, 2013, 06:04:53 AM by marc2003

  • romor
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #556
That's rendered by browser, try:

Code: [Select]
curl "http://developer.echonest.com/api/v4/artist/biographies?api_key=BJZA2W0VD8EFHZELS&license=cc-by-sa&format=json&name=jennifer+lopez" > out.json


Edit: but also in browser (Firefox) I see "\n" in your link

Edit 2: Here is raw "run external script" command for Biography View, which uses xmllint (can be replace by any tool that supports basic XPath)

Code: [Select]
cmd /c "xmllint --xpath "/response/biographies/biography/text[../site='last.fm']/text'()'" --encode utf-8 --noent "http://developer.echonest.com/api/v4/artist/biographies?api_key=BJZA2W0VD8EFHZELS&license=cc-by-sa&format=xml&name=$replace($meta(artist,0),' ',+)""


Until someone feels like writing a script it can be used to display full last.fm biography
  • Last Edit: 20 February, 2013, 06:25:20 AM by romor

  • romor
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #557
they are there in the wikipedia segment but not the last.fm...


After seeing the content in biography view processed with xmllint, it seems like they use new lines on last.fm contents to format additional information, like History, Musical style etc., while biography text new lines are stripped. These stripped new lines can be "recovered" by replacing dot followed by two spaces with dot followed by two CRLF, i.e ".  " -> ".\r\n\r\n". I'll do that later today and provide script, as there is no "sed" equivalent on Windows.

Edit: Sooner than later, here is 6 line vbscript that renders as expected full last.fm bio: https://gist.github.com/aa2ada8bdc93144abd03

How to use it (if script is placed in foobar root folder):

  • Last Edit: 20 February, 2013, 08:25:59 AM by romor

  • mire777
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #558
Amazing, thanks Romor, works perfectly  if not asking too much perhaps you could combine, your previous script foo_shout.vbs with this. So that we can have, short preview album,tracklist and now playing with biography together.
However, THANKS, THANKS, THANKS Romor
  • Last Edit: 20 February, 2013, 11:14:11 AM by mire777

  • romor
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #559
Mire, you are welcome

I don't understand your foo_shout.vbs concern
Can't you use it as external script in album tab and lastfm_bio.vbs in artist tab?

  • mire777
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #560
I thought if it is possible to merge two scripts into one. But I encountered a problem with lastfm_bio.vbs. Script don't read the full name of artist.. It reads only the first part of the name. And so for all artist... Example: for Robbie Williams, Biography text is: ''Robbie is a synthpop musician hailing from Virginia.''
Or something I'm not set correctly?

  • romor
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #561
Mire, enclose artist in double quotes. Just follow screenshot literally

  • marc2003
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #562
These stripped new lines can be "recovered" by replacing dot followed by two spaces with dot followed by two CRLF, i.e ".  " -> ".\r\n\r\n".


just done that, thanks. for anyone who uses my WSH panel mod script, i've released a mod version in the other thread.

it does make me wonder if echonest cache data forever or whether last.fm supplies them with the full info? but for now, it's fine.
  • Last Edit: 21 February, 2013, 05:38:17 AM by marc2003

  • mire777
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #563
Mire, enclose artist in double quotes. Just follow screenshot literally


Ok, now work. I had to copy quotes from the script. If i manualy write quotes, it does not work.
Thank's

  • mire777
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #564
Something I noticed, echonest, does not recognize ''&'' carakter, so if you have a song with that character, you must change it in  ''and'' carakter . fortunately i don't have a lot of those songs...

  • Timothy
  • [*]
[Not my release] Biography view
Reply #565



Thanks for this nice workaround, is it possible to get last.fm bio via script in german language?

tim

  • marc2003
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #566
echonest, does not recognize ''&'' carakter


it does when you properly encode these kind of characters before making a request.

as a workaround you try replacing

Code: [Select]
%artist%


on your command line with

Code: [Select]
$replace(%artist%,&,'%26)


@Timothy, there is no language support with this version.
  • Last Edit: 22 February, 2013, 06:00:18 AM by marc2003

  • neons
  • [*]
[Not my release] Biography view
Reply #567
Romor, your script works fine for me. Is it possible to add other possibilities. I'd like to download biography, and save it in a file, as it did foo_uie_biography earlier.And then if biography already exists in the folder, script will read that file.
If you have time to do this. Thank's.
  • Last Edit: 23 February, 2013, 01:54:51 PM by neons

  • romor
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #568
I encoded ampersand, thanks Marc

@neons: try this: https://gist.github.com/rornor/e8adee2d94cac17840b3

You should change first line - 'folder' variable to point to desired and existing folder

  • neons
  • [*]
[Not my release] Biography view
Reply #569
I encoded ampersand, thanks Marc

@neons: try this: https://gist.github.com/rornor/e8adee2d94cac17840b3

You should change first line - 'folder' variable to point to desired and existing folder


It was really fast. Works great, I've changed the ''txt'' extension in ''lfml'' , maybe if last.fm reverse his decision, biography can be readable again.Now everything works as before the change.Thank's Romor
  • Last Edit: 24 February, 2013, 09:29:57 AM by neons

  • mire777
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #570
I tried the new script. One problem, if you turn off the network, and play song, script would make an empty biography file, because it does not provide the test network. And later when you turn on your network, the script will not overwrite that file.
I changed something and I was able to prevent this behavior, but I don't understand how it works, and whether it is well written, so can you update, thanks

This is my script:

Code: [Select]
       
Dim WshShell
Set WshShell = createobject("wscript.shell")
strURL = "www.google.com"
set png = WshShell.exec("ping -n 1 " & strURL)
do until png.status = 1
wscript.sleep 50
loop
strPing = lcase(png.stdout.readall)
Select Case True
     Case InStr(strPing, "reply from") > 1

folder = "C:\Users\mire\Desktop\foobar2000 xch4\lyrics\biography"
On Error resume Next
With CreateObject("Scripting.FileSystemObject")
If Not .FileExists(folder & "\" & WScript.Arguments.Item(0) & ".txt") Then
Set xml = CreateObject("MSXML2.DOMDocument.6.0")
xml.async = false
xml.load("http://developer.echonest.com/api/v4/artist/biographies?api_key=PKDMY7Z0SGFBW" & UCase(Right("denial", 4)) & "&license=cc-by-sa&format=xml&name=" & Replace(WScript.Arguments.Item(0), "&", "%26"))
.OpenTextFile(folder & "\" & WScript.Arguments.Item(0) & ".txt", 2, 1).Write(Replace(Replace(xml.selectSingleNode("/response/biographies/biography/text[../site='last.fm']").text, ". ", "." & vbCrLf & vbCrLf), ". ", "." & vbCrLf & vbCrLf) & vbCrLf & vbCrLf & "WIKIPEDIA BIO:" & vbCrLf & vbCrLf & Replace(Replace(xml.selectSingleNode("/response/biographies/biography/text[../site='wikipedia']").text, ". ", "." & vbCrLf & vbCrLf), ". ", "." & vbCrLf & vbCrLf))
End If
WScript.Echo .OpenTextFile(folder & "\" & WScript.Arguments.Item(0) & ".txt").ReadAll
End With
End Select
  • Last Edit: 24 February, 2013, 02:18:34 PM by mire777

  • romor
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #571
Mire, I updated script not to create empty files, like in scenario when user looses connection

  • mire777
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #572
Ok thanks. It's a good idea to save biography in case that something happens with the site. I hope it will not happen again...

  • kjllmeplz
  • [*]
[Not my release] Biography view
Reply #573
romor : thanks for the script.
But it still does not recognize ''&''.




  • marc2003
  • [*][*][*][*][*]
[Not my release] Biography view
Reply #574
I encoded ampersand, thanks Marc


oh sorry, i didn't even look at your script. i just assumed it didn't based on the problem that was reported and the fact that mine works ok.