PedroHLC / ViewLyricsOpenSearcher

Open searcher for lyrics files (".lrc" and ".txt") , stored in Crintsoft's MiniLyrics server ("ViewLyrics.com").
33 stars 6 forks source link

[Fatal Error] :1:1: Content is not allowed in prolog. #6

Closed merichzte closed 9 years ago

merichzte commented 9 years ago

In JRE8, when I run the tester I get:

[Fatal Error] :1:1: Content is not allowed in prolog. org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(Unknown Source) at com.pedrohlc.viewlyricsppensearcher.ViewLyricsSearcher.parseResultXML(ViewLyricsSearcher.java:212) at com.pedrohlc.viewlyricsppensearcher.ViewLyricsSearcher.searchQuery(ViewLyricsSearcher.java:103) at com.pedrohlc.viewlyricsppensearcher.ViewLyricsSearcher.search(ViewLyricsSearcher.java:66) at com.pedrohlc.viewlyricsppensearcher.Tester.main(Tester.java:21)*

after adding System.out.println(neomagic.toString()); to line 169 I get:

-<?xml version="1.0" encoding='utf-8'?>
<return orgcmd="searchV1" result="OK" badrc="100" ls_dd="1" server_url="http://viewlyrics.com/" PageCount="15" CurPage="2">
  <fileinfo link="lt/z2/mc_awoilcqv.txt" artist="Foo Fighters" title="Break Out" downloads="74"/>
  <fileinfo link="lt/z2/cf_vqoklcqv.txt" artist="Foo Fighters" title="Breakout" album="There Is Nothing Left To Lose" downloads="118"/>
  <fileinfo link="lu4/x7/ns_zoaolzsq.lrc" artist="Foo Fighters" title="Breakout" album="Greatest Hits" uploader="davidseco13" downloads="327"/>
  <fileinfo link="lu4/23/sg_ioounhqb.lrc" artist="Foo Fighters" title="Break Out" uploader="CaOx" downloads="183"/>
  <fileinfo link="lu5/110408/su_wlclpisi.lrc" artist="foo fighters" title="Bridge Burning" album="Wasting Light" uploader="pesobruto" rate="5.0" ratecount="2" downloads="23802"/>
  <fileinfo link="lu5/110407/hh_shvupusi.txt" artist="Foo Fighters" title="Bridge Burning" album="Wasting Light" uploader="insomniac92" downloads="2174"/>
  <fileinfo link="lu5/120524/pa_bnvoiuso.lrc" artist="foo fighters" title="Bridge Burning (espa¨¨ol)" album="Wasting Light" uploader="khabron" downloads="64"/>
  <fileinfo link="lu5/141119/is_khvhspca.lrc" artist="Foo Fighters" title="Bridge Burning" album="Wasting Light" uploader="luch33to" timelength="286" downloads="8"/>
  <fileinfo link="lu5/120430/vo_ipslvuso.lrc" artist="Foo Fighters" title="Bridge is Burning" album="Wasting Light" uploader="frsc" timelength="286" downloads="265"/>
  <fileinfo link="lt/z2/qu_vsollcqv.txt" artist="Foo Fighters" title="Bruce" album="Pocketwatch" rate="2.6" ratecount="5" downloads="150"/>
  <fileinfo link="lt/z2/bb_vcoolcqv.txt" artist="Foo Fighters" title="Burn Away" album="One By One" downloads="52"/>
  <fileinfo link="lu5/141119/tq_akwlsoca.lrc" artist="Foo Fighters" title="Burn Away" album="One by One" uploader="luch33to" timelength="298" downloads="2"/>
  <fileinfo link="lu2/8/pb_khsiuvqk.lrc" artist="Foo Fighters" title="Burn Away" uploader="mcewendavid" rate="5.0" ratecount="6" downloads="8498"/>
  <fileinfo link="lu4/o2/sk_okaluqqb.lrc" artist="Foo Fighters" title="But Honestly" album="Echoes, Silence, Patience &amp; Grace" uploader="mcewendavid" rate="4.8" ratecount="13" downloads="8705"/>
  <fileinfo link="lu4/a3/rd_vwaoqhqz.lrc" artist="Foo Fighters" title="But Honestly" album="Echoes Silence Patience &amp; Grace" uploader="Edman" downloads="31"/>
  <fileinfo link="lu4/c2/la_nlnkwaqn.lrc" artist="Foo Fighters" title="But Honestly" uploader="mastermc0" rate="3.8" ratecount="10" downloads="3952"/>
  <fileinfo link="lu4/a2/rv_vzhzzcqn.txt" artist="Foo Fighters" title="But Honestly" downloads="172"/>
  <fileinfo link="lu5/141119/ai_icacspca.lrc" artist="Foo Fighters" title="But, Honestly" album="Echoes, Silence, Patience &amp; Grace" uploader="luch33to" timelength="275" downloads="2"/>
  <fileinfo link="lt/z2/gu_vaoplcqv.txt" artist="Foo Fighters" title="Butterflies" album="Foo Fighters" downloads="456"/>
  <fileinfo link="lt/z2/lq_vvonlcqv.txt" artist="Foo Fighters" title="Carry On Mayward Son" downloads="4"/>
  <fileinfo link="lt/z2/dt_vhoblcqv.txt" artist="Foo Fighters" title="Carry On My Wayward Son" album="Miscellaneous" downloads="168"/>
  <fileinfo link="lu4/a3/hr_vzalqhqz.lrc" artist="Foo Fighters" title="Cheer Up, Boys (Your Make Up Is Running)" album="Echoes Silence Patience &amp; Grace" uploader="Edman" downloads="48"/>
  <fileinfo link="lu5/141119/gl_ubcbspca.lrc" artist="Foo Fighters" title="Cheer Up, Boys (Your Make Up Is Running)" album="Echoes, Silence, Patience &amp; Grace" uploader="luch33to" timelength="221" downloads="1"/>
  <fileinfo link="lu4/o2/rq_oiakuqqb.lrc" artist="Foo Fighters" title="Cheer Up, Boys (Your Make Up Is Running)" album="Echoes, Silence, Patience &amp; Grace" uploader="mcewendavid" rate="4.9" ratecount="15" downloads="8489"/>
  <fileinfo link="lu4/x1/fd_vqoakwqn.txt" artist="Foo Fighters" title="Cheer Up, Boys (Your Make Up Is Running)" album="Echoes, Silence, Patience &amp; Grace" uploader="NilzoBoy" rate="2.5" ratecount="4" downloads="597"/>
  <fileinfo link="lu4/32/fi_zccuozqn.lrc" artist="Foo Fighters" title="Cheer Up Boys, Your Makeup Is Running" album="Echoes, Silence, Patience and Grace" uploader="mastermc0" rate="5.0" ratecount="7" downloads="4790"/>
  <fileinfo link="lu5/141119/vy_ucccspca.lrc" artist="Foo Fighters" title="Cold Day in the Sun" album="In Your Honor Disc 2" uploader="luch33to" timelength="200" downloads="1"/>
  <fileinfo link="lu2/c2/lr_cllcknql.lrc" artist="Foo Fighters" title="Cold Day in the Sun" rate="5.0" ratecount="5" downloads="12324"/>
  <fileinfo link="lu5/120606/ry_huonkzso.lrc" artist="Foo Fighters" title="Cold Day In The Sun" album="Skin And Bones" uploader="HaTe" timelength="206" downloads="44"/>
  <fileinfo link="lt/z2/yx_vuozlcqv.txt" artist="Foo Fighters" title="Color Pictures Of A Marigold" album="Pocketwatch" downloads="56"/>
  <fileinfo link="lu4/w1/ag_apoikuqn.lrc" artist="Foo Fighters" title="Come Alive" album="Echoes, Silence, Patience and Grace" uploader="The_Sugar" rate="4.0" ratecount="12" downloads="5373"/>
  <fileinfo link="lx2/m1/ti_aqpiupqn.txt" artist="Foo Fighters" title="Come Alive" album="Echoes Silence Patience &amp;Grace" rate="1.0" ratecount="1" downloads="258"/>
  <fileinfo link="lu4/a3/yy_vbakqhqz.lrc" artist="Foo Fighters" title="Come Alive" album="Echoes Silence Patience &amp; Grace" uploader="Edman" downloads="269"/>
  <fileinfo link="lu5/141119/ak_upcpspca.lrc" artist="Foo Fighters" title="Come Alive" album="Echoes, Silence, Patience &amp; Grace" uploader="luch33to" timelength="310" downloads="2"/>
  <fileinfo link="lu4/o2/tx_ouaiuqqb.lrc" artist="Foo Fighters" title="Come Alive" album="Echoes, Silence, Patience &amp; Grace" uploader="mcewendavid" rate="4.7" ratecount="12" downloads="9204"/>
  <fileinfo link="lu2/8/cm_kuskuvqk.lrc" artist="Foo Fighters" title="Comeback" uploader="mcewendavid" rate="5.0" ratecount="11" downloads="9905"/>
  <fileinfo link="lt/z2/kd_viowlcqv.txt" artist="Foo Fighters" title="Come Back" album="One By One" downloads="75"/>
  <fileinfo link="lt/z2/pr_vkpqlcqv.txt" artist="Foo Fighters" title="Comeback" downloads="38"/>
  <fileinfo link="lu5/141119/hb_alwosoca.lrc" artist="Foo Fighters" title="Come Back" album="One by One" uploader="luch33to" timelength="469" downloads="4"/>
  <fileinfo link="lu5/141101/ql_iuhqqsca.lrc" artist="Foo Fighters" title="Congregation" uploader="xavierfpd" timelength="311" downloads="4689"/>
  <fileinfo link="lu5/141119/hb_lvhvspca.lrc" artist="Foo Fighters" title="Congregation" album="Sonic Highways" uploader="luch33to" timelength="311" downloads="215"/>
  <fileinfo link="lt/z2/hl_vlpslcqv.txt" artist="Foo Fighters" title="Damn You Damn Everyone" album="Miscellaneous" downloads="47"/>
  <fileinfo link="lu4/a5/nq_acwicoqw.lrc" artist="Foo Fighters" title="Danny Says" album="The Missing Peices" uploader="KoNaIdY" downloads="3543"/>
  <fileinfo link="lu5/141119/tg_kqvqspca.lrc" artist="Foo Fighters" title="Danny Says" album="Medium Rare" uploader="luch33to" timelength="179" downloads="18"/>
  <fileinfo link="lx2/n/qo_pbanivqp.txt" artist="Foo Fighters" title="Danny Says" downloads="562"/>
  <fileinfo link="lu5/141125/mi_oahkcuca.lrc" artist="Foo Fighters" title="Darling Nikki" album="Have It All CDS" uploader="luch33to" timelength="204" downloads="172"/>
  <fileinfo link="lt/z2/wb_vopclcqv.txt" artist="Foo Fighters" title="Darling Nikki" rate="5.0" ratecount="2" downloads="1993"/>
  <fileinfo link="lt/z2/ap_vppalcqv.txt" artist="Foo Fighters" title="Dear Lover" album="Miscellaneous" rate="5.0" ratecount="3" downloads="344"/>
  <fileinfo link="lu4/a5/sp_vvqkcpqw.lrc" artist="Foo Fighters" title="Dear Lover" album="The Missing Peices" uploader="KoNaIdY" rate="5.0" ratecount="2" downloads="1987"/>
  <fileinfo link="lu5/141119/wf_cqzssoca.lrc" artist="Foo Fighters" title="Dear Lover" album="The Colour and the Shape" uploader="luch33to" timelength="271" downloads="1"/>
</return> 

So guessing that "-" at the beginning is creating trouble. I checked stackoverflow for possible answers: http://stackoverflow.com/a/18275066 http://stackoverflow.com/a/7390288

seems relevant. Yet I am not good at this yet, so not sure how to implement them.

merichzte commented 9 years ago

I changed 21 to 22 on line 167, it worked without errors, but not sure if this is a solution.

PedroHLC commented 9 years ago

In Java I used to use 21, in OSDLyrics we're using 23, in PHP 22. For encrypting (the decryption is using the same algorithm, and I quite believe their server too) we're using: {3 bytes for encryption settings, 3 NULL bytes, 16 bytes with request MD5, NULL-ended encrypted string} So, remembering we start counting the array at 0, 3+3+16=22. Than start decrypting at 22 would be the right one anyway...

I'm pretty sure this has something to do with issue #3, maybe there were some 2 bytes combination in MD5 that was being read as an UTF-8 character.

merichzte commented 9 years ago

is it possible to check for "<"character then start? Some queries works with 21 some with 22.

PedroHLC commented 9 years ago

Would be wrong, it should always be 22, the problem is that some bytes are misread and interpreted as an UTF-8 multi-byte character. For correctly fixing it, we'll need to catch the result as ISO_8859_1/Binary from the package receiving till decryption, and make sure all the methods called are also treating the String this way, the decryption result and the following should continue to be in UTF-8. The same way you found a querie that in the current code the 22 bytes results in 21 characters, there will be some who can even endup in 10 characters.

merichzte commented 9 years ago

The decryption part is something I still need to get my head around.

PedroHLC commented 9 years ago

Seems to have been fixed in 9887cc5395d51bc5f664d11930ae34cad6d681e9, can you check it?

merichzte commented 9 years ago

works great! this is a great tool.