{"id":351,"date":"2009-09-01T22:31:49","date_gmt":"2009-09-02T01:31:49","guid":{"rendered":"http:\/\/tangopardo.com.ar\/2cf7\/?p=351"},"modified":"2009-09-01T22:31:49","modified_gmt":"2009-09-02T01:31:49","slug":"fixing-amaroks-support-for-wikipedia-without-recompiling","status":"publish","type":"post","link":"https:\/\/tangopardo.com.ar\/2cf7\/2009\/09\/01\/fixing-amaroks-support-for-wikipedia-without-recompiling","title":{"rendered":"Fixing Amarok&#8217;s support for Wikipedia without recompiling"},"content":{"rendered":"<p>Some time ago Wikipedia changed its markup and because of that one of my favorites players, Amarok stopped showing the artist information. This wasn&#8217;t something that bugged me that much to take the approach suggested in <a href=\"http:\/\/forums.freebsd.org\/showthread.php?t=2005\">tons<\/a> <a href=\"http:\/\/bugs.gentoo.org\/show_bug.cgi?id=256389\">of<\/a> <a href=\"https:\/\/bugs.launchpad.net\/ubuntu\/+source\/amarok\/+bug\/316140\/\">places<\/a>:<\/p>\n<blockquote><p>edit contextbrowser.cpp and change:<\/p>\n<p>from: m_wiki = m_wiki.mid( m_wiki.find( &#8220;&lt;h1 class=\\&#8221;firstHeading\\&#8221;&gt;&#8221; ) );<br \/>\nto: m_wiki = m_wiki.mid( m_wiki.find( &#8220;&lt;h1 id=\\&#8221;firstHeading\\&#8221; class=\\&#8221;firstHeading\\&#8221;&gt;&#8221; ));<\/p><\/blockquote>\n<p>&#8230; save, compile and you are done. Nice as pie. Isn&#8217;t the free software world wonderful? Not that this is something hard, but I didn&#8217;t feel like doing it that way.<\/p>\n<p>Sooo, today I came back home a bit tired after college and work and instead of having some sleep I chose to tackle this little problem. From the code above, we see that there&#8217;s a function that takes a static string (in this context by &#8220;static&#8221; I mean something not generated at runtime), this means that we can [generally] replace the string in the binary and it should work.<\/p>\n<p>Hands on!<\/p>\n<blockquote>\n<pre>#cd \/usr\/bin\r\n#grep firstHeading amarokapp<\/pre>\n<\/blockquote>\n<p>Yuck. Nothing!<\/p>\n<blockquote>\n<pre>#ldd amarokapp\r\n(...some output ommited)\r\nlibamarok.so.0 =&gt; \/usr\/lib\/libamarok.so.0 (0xb79a1000)\r\n#grep firstHeading \/usr\/lib\/libamarok.so.0\r\nBinary file libamarok.so.0 matches<\/pre>\n<\/blockquote>\n<p>There! so we have to modify libamarok.so.0<br \/>\nIn my system libamarok.so.0 is a symlink to libamarok.so.0.0.0<br \/>\nThis is nothing spectacular, first backup then edit<\/p>\n<blockquote>\n<pre>#cd \/usr\/lib\r\n#cp libamarok.so.0.0.0 libamarok.so.0.0.0.orig\r\n#hexedit libamarok.so.0.0.0<\/pre>\n<\/blockquote>\n<p>Here I used hexedit because it was at hand, any decent hex editor should do fine. Even vim works. In this case we can do this easily because the target string is shorter than the original, so we can pad the rest with zeroes (or add a single one at the end of the new string). Obligatory? screenshots:<\/p>\n<div id=\"attachment_357\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_antes.png.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-357\" data-attachment-id=\"357\" data-permalink=\"https:\/\/tangopardo.com.ar\/2cf7\/2009\/09\/01\/fixing-amaroks-support-for-wikipedia-without-recompiling\/parche_amarok_antes-png\" data-orig-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_antes.png.jpg\" data-orig-size=\"1152,699\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"parche_amarok_antes.png\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;hexedit of libamarok.so, before&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_antes.png-300x182.jpg\" data-large-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_antes.png-1024x621.jpg\" class=\"size-medium wp-image-357\" title=\"parche_amarok_antes.png\" src=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_antes.png-300x182.jpg\" alt=\"hexedit of libamarok.so, before\" width=\"300\" height=\"182\" srcset=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_antes.png-300x182.jpg 300w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_antes.png-1024x621.jpg 1024w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_antes.png.jpg 1152w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-357\" class=\"wp-caption-text\">hexedit of libamarok.so, before<\/p><\/div>\n<div id=\"attachment_358\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues.png.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-358\" data-attachment-id=\"358\" data-permalink=\"https:\/\/tangopardo.com.ar\/2cf7\/2009\/09\/01\/fixing-amaroks-support-for-wikipedia-without-recompiling\/parche_amarok_despues-png\" data-orig-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues.png.jpg\" data-orig-size=\"1152,699\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"parche_amarok_despues.png\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;hexedit of libamarok.so, after (bold: changed text)&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues.png-300x182.jpg\" data-large-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues.png-1024x621.jpg\" class=\"size-medium wp-image-358\" title=\"parche_amarok_despues.png\" src=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues.png-300x182.jpg\" alt=\"hexedit of libamarok.so, after (bold: changed text)\" width=\"300\" height=\"182\" srcset=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues.png-300x182.jpg 300w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues.png-1024x621.jpg 1024w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues.png.jpg 1152w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-358\" class=\"wp-caption-text\">hexedit of libamarok.so, after (bold: changed text)<\/p><\/div>\n<p>Note: <strong>Close Amarok before saving!!<\/strong><\/p>\n<p>Mine quite certainly didn&#8217;t like having its library changed while running and died as if\u00a0 I killed it with a -9. After running it again everything works as expected:<\/p>\n<div id=\"attachment_360\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues2.png.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-360\" data-attachment-id=\"360\" data-permalink=\"https:\/\/tangopardo.com.ar\/2cf7\/2009\/09\/01\/fixing-amaroks-support-for-wikipedia-without-recompiling\/parche_amarok_despues2-png\" data-orig-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues2.png.jpg\" data-orig-size=\"1280,999\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"parche_amarok_despues2.png\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Amarok showing the Garbage page&#8217;s&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues2.png-300x234.jpg\" data-large-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues2.png-1024x799.jpg\" class=\"size-medium wp-image-360\" title=\"parche_amarok_despues2.png\" src=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues2.png-300x234.jpg\" alt=\"Amarok showing the Garbage page's\" width=\"300\" height=\"234\" srcset=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues2.png-300x234.jpg 300w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues2.png-1024x799.jpg 1024w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues2.png.jpg 1280w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-360\" class=\"wp-caption-text\">Amarok showing the Garbage page&#39;s<\/p><\/div>\n<div id=\"attachment_361\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues1.png.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-361\" data-attachment-id=\"361\" data-permalink=\"https:\/\/tangopardo.com.ar\/2cf7\/2009\/09\/01\/fixing-amaroks-support-for-wikipedia-without-recompiling\/parche_amarok_despues1-png\" data-orig-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues1.png.jpg\" data-orig-size=\"1280,1024\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"parche_amarok_despues1.png\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Regina Spektor&#8217;s bio&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues1.png-300x240.jpg\" data-large-file=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues1.png-1024x819.jpg\" class=\"size-medium wp-image-361\" title=\"parche_amarok_despues1.png\" src=\"http:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues1.png-300x240.jpg\" alt=\"Regina Spektor's bio\" width=\"300\" height=\"240\" srcset=\"https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues1.png-300x240.jpg 300w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues1.png-1024x819.jpg 1024w, https:\/\/tangopardo.com.ar\/2cf7\/wp-content\/uploads\/2009\/09\/parche_amarok_despues1.png.jpg 1280w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-361\" class=\"wp-caption-text\">Regina Spektor&#39;s bio<\/p><\/div>\n<p>I really like what the compression artifacts did to the background, should change that later.<\/p>\n<p>Whoaa, enough for tonight,\u00a0 gotta sleep a bit.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some time ago Wikipedia changed its markup and because of that one of my favorites players, Amarok stopped showing the artist information. This wasn&#8217;t something that bugged me that much to take the approach suggested in tons of places: edit contextbrowser.cpp and change: from: m_wiki = m_wiki.mid( m_wiki.find( &#8220;&lt;h1 class=\\&#8221;firstHeading\\&#8221;&gt;&#8221; ) ); to: m_wiki = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12,3,22],"tags":[],"class_list":["post-351","post","type-post","status-publish","format-standard","hentry","category-psico","category-software","category-software-libre"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pmnbC-5F","_links":{"self":[{"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/posts\/351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/comments?post=351"}],"version-history":[{"count":9,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/posts\/351\/revisions"}],"predecessor-version":[{"id":364,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/posts\/351\/revisions\/364"}],"wp:attachment":[{"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/media?parent=351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/categories?post=351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tangopardo.com.ar\/2cf7\/wp-json\/wp\/v2\/tags?post=351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}