Last.FM Rework and Auto DJ mode (2 Viewers)

jameson_uk

Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    1 tiny hick-up in HTTP response:
    Code:
    [2013-05-04 14:39:31,975] [Error  ] [Announce/Auto DJ] [ERROR] - Error in Last.fm AutoDJ
    [2013-05-04 14:39:31,984] [Log	] [Announce/Auto DJ] [ERROR] - Exception: MediaPortal.LastFM.LastFMException: Error in HTTP response ---> System.Xml.XmlException: Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 2, position 3.
      at System.Xml.XmlTextReaderImpl.Throw(Exception e)
      at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
      at System.Xml.XmlTextReaderImpl.ParsePI(BufferBuilder piInDtdStringBuilder)
      at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
      at System.Xml.XmlTextReaderImpl.Read()
      at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
      at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
      at System.Xml.Linq.XDocument.Parse(String text)
      at MediaPortal.LastFM.LastFMLibrary.GetXml(String querystring, String httpMethod, Boolean useHttps)
      --- End of inner exception stack trace ---
      at MediaPortal.LastFM.LastFMLibrary.GetXml(String querystring, String httpMethod, Boolean useHttps)
      at MediaPortal.LastFM.LastFMLibrary.GetSimilarTracks(String strTrack, String strArtist)
      at MediaPortal.ProcessPlugins.LastFMScrobbler.LastFMScrobbler.AutoDJ(String strArtist, String strTrack)  Message: Error in HTTP response  Site  : System.Xml.Linq.XDocument GetXml(System.String, System.String, Boolean)  Source : LastFMLibrary  Inner Exception(s):  -> Error in HTTP response  -> Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 2, position 3.  Stack Trace:	 at MediaPortal.LastFM.LastFMLibrary.GetXml(String querystring, String httpMethod, Boolean useHttps)
      at MediaPortal.LastFM.LastFMLibrary.GetSimilarTracks(String strTrack, String strArtist)
      at MediaPortal.ProcessPlugins.LastFMScrobbler.LastFMScrobbler.AutoDJ(String strArtist, String strTrack)
    which was completely unnoticeable in MP ;)
    I had this too once the other day. Is basically that last.fm returned something that was not valid. I will add some other logging to try and catch this if it happens again
     

    seco

    Retired Team Member
  • Premium Supporter
  • August 7, 2007
    1,575
    1,239
    Home Country
    Finland Finland
    Code:
    The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 2, position 3.

    I got this error in Rockstar when I was sending XML which was not properly encoded, e.g. track name contained non-ascii characters like ä and ö.

    I fixed this by using HttpUtility.UrlEncode() for track, album and artist name.

    Now, if we only had one single C# library for LastFM we would not need to fix all these problems in every implementation we have :p
     
    Last edited:

    jameson_uk

    Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    Code:
    The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 2, position 3.

    I got this error in Rockstar when I was sending XML which was not properly encoded, e.g. track name contained non-ascii characters like ä and ö.

    I fixed this by using HttpUtility.UrlEncode() for track, album and artist name.
    I am doing this already with all parameters
    Code:
    	  strLastFMURL = methodParams.Aggregate(strLastFMURL,
    											(current, methodParam) => current + ("&" + methodParam.Key + "=" + HttpUtility.UrlEncode(methodParam.Value)));

    I guess this is probably going wrong somewhere but will need to try and debug. Is anyone able to reproduce this consistently with a track (probably one with a non ascii character in there)
     

    seco

    Retired Team Member
  • Premium Supporter
  • August 7, 2007
    1,575
    1,239
    Home Country
    Finland Finland
    What is LastFmHelper.dll and from where does it come from?
     

    jameson_uk

    Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    What is LastFmHelper.dll and from where does it come from?
    It is in a private repository as it contains the key and secret. All it does is order the parameters, add the API key and if necessary sign it.
     

    jameson_uk

    Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    Here you go... _LastFmNowPlaying and _LastFmPlaylist, respectively.
    Did you choose the "Report a bug to Team Mediaportal" option ? If not could you try it with this option as that will make it easier for me to see what is going on.

    Here you go...
    OK I can't see anything odd here but there have been some changes to other parts around this that may make a difference.
    A new build will be added shortly to the first posts here, can you try that and see if you still get the issue? (I have added a little extra debugging to try and locate any issue)
     

    jameson_uk

    Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    which was completely unnoticeable in MP ;)
    OK I have not been able to bottom this out but I have applied a tiny change to LastFMHelper.dll and changed a few other things so new build incoming...
    Please can you keep an eye out for this error
     

    IchBinsShort

    Portal Pro
    January 3, 2008
    683
    54
    Home Country
    Germany Germany
    The way I see this rework will probably not be include in the MediaPortal 1.4, or do I see that wrong? Or you can install the whole as a plugin later? Because it actually works but it very well especially much better than the old plugin. It does not work all at once, too. Yes it could be added by and by new functions.
     

    jameson_uk

    Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    The way I see this rework will probably not be include in the MediaPortal 1.4, or do I see that wrong? Or you can install the whole as a plugin later? Because it actually works but it very well especially much better than the old plugin. It does not work all at once, too. Yes it could be added by and by new functions.
    Yes too late for 1.4 but I am aiming for 1.5. There are a few things to resolve before it is ready but I am getting there :cool:
     

    catavolt

    Design Group Manager
  • Team MediaPortal
  • August 13, 2007
    14,634
    10,684
    Königstein (Taunus)
    Home Country
    Germany Germany
    Would be nice to have only the necessary dlls instead a complete MP package (if possible ofc) ;)
    This way it could be tested w/o loosing latest changes in the 1.4.0 Pre-Release Testing thread ;)
     

    Users who are viewing this thread

    Top Bottom