Advertisement
Guest User

LFMP fix 2

a guest
Jan 28th, 2012
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.60 KB | None | 0 0
  1. To correct - you need to edit the file
  2. replacing all references to it on the site VKONTAKTE.RU to VK.COM, use replace (Ctrl+H or find it manually), should only be two instances.
  3. save the changes:
  4.  
  5. Windows 2000/XP
  6. C: \ Documents and Settings \ replace this text with your own username \ Local Settings \ Application Data \ Google \ Chrome \ User Data \ Default \ Extensions \ bbncpldmanoknoahidbgmkgobgmhnafh \ 2.9.66_0 \ javascript \ vk.js
  7.  
  8. Windows 7
  9. C: \ Users \ REPLACE THIS TEXT TO YOUR USERNAME \ AppData \ Local \ Google \ Chrome \ User Data \ Default \ Extensions \ bbncpldmanoknoahidbgmkgobgmhnafh \ 2.9.66_0 \ javascript \ vk.js
  10.  
  11. (if your Windows is not installed on C: drive, then look for a file on the same path on another drive)
  12. If still not found, just search for "bbncpldmanoknoahidbgmkgobgmhnafh"
  13. Then - reboot the expansion
  14. (if you do not know how, just close all the windows Chrome and restart it again).
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. Copy and Paste all bellow if you don't know how to search.
  22.  
  23.  
  24.  
  25. var _gaq = _gaq || [];
  26.  
  27. /**
  28. VK
  29.  
  30. Module for working with vk.com
  31. **/
  32. var VK = {
  33. determineSearchMethod: function(callback){
  34. console.log("Trying to determine search method")
  35.  
  36. xhrRequest("http://vk.com", "GET", null, function(xhr){
  37. console.log(xhr.responseText.match(/logout/));
  38.  
  39. if(!xhr.responseText.match(/logout/)){
  40. xhrRequest("http://vk.com", "GET", null, function(xhr_vk){
  41. if(!xhr_vk.responseText.match(/logout/)) {
  42. callback({search_method:'test_mode'})
  43. } else {
  44. callback({search_method:'vk.com'})
  45. }
  46. })
  47. } else {
  48. callback({search_method:'vk.com'})
  49. }
  50. })
  51. },
  52.  
  53. /**
  54. VK.#_rawSearch(artist, song, callback)
  55.  
  56. Searching by parsing page. Callback function must return hash with url.
  57. **/
  58. _rawSearch: function(artist, song, duration, callback){
  59. var track = artist + " " + song
  60.  
  61. var url = "http://"+VK.search_method+"/al_search.php"
  62. var data = "c%5Bq%5D="+encodeURIComponent(track)+"&al=1&c%5Bsection%5D=audio&c%5Bsort%5D=2"
  63.  
  64. xhrRequest(url, "POST", data, function(xhr){
  65.  
  66. // User logged off from vkontakte
  67. if(xhr.responseText.match(/progress\.gif/)){
  68. delete VK.search_method
  69.  
  70. VK.search(artist, song, duration, callback)
  71.  
  72. return
  73. }
  74.  
  75. var container = document.getElementById('vk_search');
  76. response = xhr.responseText.replace(/^<!--/, '').replace(/->->/g, '-->');
  77.  
  78. container.innerHTML = response.split('<!>').join('');
  79.  
  80. var audio_data = []
  81. var audio_rows = container.querySelectorAll('div.audio')
  82.  
  83. for(var i=0; i<audio_rows.length; i++){
  84. if(i>10) break
  85.  
  86. var url_data = audio_rows[i].querySelector('input[type=hidden]').value.split(',');
  87. var url = url_data[0];
  88. var duration = url_data[1];
  89.  
  90. var title = audio_rows[i].querySelector('td.info span');
  91.  
  92. audio_data.push({
  93. artist: audio_rows[i].querySelector('td.info a').innerHTML,
  94. title: title.textContent.trim(),
  95. duration: duration,
  96. url: url
  97. })
  98. }
  99.  
  100. console.log("Tracks:", audio_data);
  101.  
  102. if(audio_data.length > 0){
  103.  
  104. audio_data.lastIndex = 0
  105.  
  106. for(var i=0;i<audio_data.length; i++){
  107. console.log(audio_data[i], Math.abs(parseInt(audio_data[i].duration) - duration), artist, song, audio_data[i].artist.toLowerCase(), artist.toLowerCase() == audio_data[i].artist.toLowerCase())
  108.  
  109. if(audio_data[i].artist.toLowerCase() == artist && audio_data[i].title.toLowerCase() == song){
  110. if(!duration || Math.abs(parseInt(audio_data[i].duration) - duration) <= 2){
  111. audio_data.lastIndex = i
  112. break
  113. }
  114. } else if(!audio_data[i].title.toLowerCase().match(/(remix|mix)/) &&
  115. audio_data[i].artist.toLowerCase() == artist &&
  116. audio_data[i].title.toLowerCase() == song){
  117. audio_data.lastIndex = i
  118. }
  119. }
  120.  
  121. //Caching for 3 hours
  122. CACHE.set(track, audio_data, 1000*60*60*2)
  123.  
  124. callback(audio_data)
  125. } else {
  126. callback({error:'not_found'})
  127. }
  128. })
  129.  
  130. return false
  131. },
  132.  
  133. /**
  134. VK Applications for using in test_mode. [user_id, app_id, app_key]
  135. **/
  136. apps: [
  137. [327488, 525159, 'g5vuj9EWFO'],
  138. [2118012, 1882836,'xYsD1Dtsng'],
  139. [19730188, 1881945, 'rcj0HPk4Wk'],
  140. [85838504, 1887506, 'nTCyM7WEBo'],
  141. [9142393, 1891705, 'MlO3y0UXFV'],
  142. [86844124, 1891718, '8NgTW7tjWm'],
  143. [4824199, 1915951, 'pvHpN0V001'],
  144. [5573107, 1914989, 'CChij669jU'],
  145.  
  146. [6240007, 1972474, 'DMXPeITyti'], // От вконтакт пользователя
  147. [102802046, 1985438, 'sPZCZS5YxJ'], //ivaninvanov@mail.ru
  148. [102813567, 1985491, 'UjgLqfMPgc'], //ivaninvanov1@mail.ru
  149. [102815638, 1985494, 'vI7EmQNdS9'],
  150. [102819736, 1985507, '3V0H9Y7zo9']
  151.  
  152. ],
  153.  
  154. getApiData: function(){
  155. return VK.apps[Math.floor(Math.random()*VK.apps.length)]
  156. },
  157.  
  158. /**
  159. VK#_testmodeSearch(artist, song, callback)
  160.  
  161. Searching vkontakte with api in test_mode
  162. **/
  163. _testmodeSearch: function(artist, song, duration, callback){
  164. var track = artist + " " + song
  165.  
  166. var api = VK.getApiData()
  167. var url = "http://api.vk.com/api.php"
  168.  
  169. md5hash = MD5(api[0]+'api_id='+api[1]+'count=10format=jsonmethod=audio.searchq='+track+'sort=2test_mode=1'+api[2])
  170. var data = 'api_id='+api[1]+'&method=audio.search&format=json&sig='+md5hash+'&sort=2&test_mode=1&count=10&q='+encodeURIComponent(track)
  171.  
  172. console.log("Search url:", url+'?'+data)
  173.  
  174. xhrRequest("http://chromusapp.appspot.com/sign_data", "POST", "track="+encodeURIComponent(artist+song), function(xhr){
  175. console.log(xhr.responseText);
  176. })
  177.  
  178. xhrRequest(url, "GET", data, function(xhr){
  179. // Too many requests and now we banned for some time
  180. if(xhr.responseText.match(/\:false/)){
  181. // Checking if user logged into vkontakte
  182. VK.determineSearchMethod(function(response){
  183. if(response.search_method == "test_mode"){
  184. callback({error:'overload'})
  185. } else {
  186. VK.search_method = response.search_method
  187. VK.search(artist, song, duration, callback)
  188. }
  189. })
  190.  
  191. return
  192. }
  193.  
  194. var response_text = xhr.responseText.replace(/\u001D/g,'').replaceEntities()
  195.  
  196. var results = JSON.parse(response_text);
  197.  
  198. console.log(results)
  199.  
  200. if(results.response){
  201. var vk_tracks = []
  202.  
  203. if(results.response[1]){
  204. vk_tracks.lastIndex = 0
  205. for(var i=1; i<results.response.length; i++){
  206. var audio = results.response[i].audio
  207.  
  208. console.log(audio)
  209. vk_tracks.push(audio)
  210.  
  211. if(audio.artist.toLowerCase() == artist && audio.title.toLowerCase() == song){
  212. if(!duration || Math.abs((parseInt(audio.duration) - duration) <= 2)){
  213. vk_tracks.lastIndex = vk_tracks.length - 1
  214.  
  215. break
  216. }
  217. } else if(!audio.title.toLowerCase().match(/(remix|mix)/) && audio.artist.toLowerCase() == artist){
  218. vk_tracks.lastIndex = vk_tracks.length - 1
  219. }
  220. }
  221. console.log("Selected track:", vk_tracks[vk_tracks.lastIndex])
  222. }
  223.  
  224. if(vk_tracks && vk_tracks.length > 0){
  225. //vk_track.duration = parseInt(vk_track.duration)
  226.  
  227. //Caching for 3 hours
  228. CACHE.set(track, vk_tracks, 1000*60*60*3)
  229.  
  230. callback(vk_tracks)
  231. } else {
  232. callback({error:'not_found'})
  233. }
  234. } else {
  235. if(results.error)
  236. callback({error:results.error})
  237. else{
  238. console.error("ERROR!:", results)
  239. callback({error:'Unknown error while searching track'})
  240. }
  241. }
  242. })
  243. },
  244.  
  245.  
  246. /**
  247. VK#search(artist, song, callback)
  248. - artist (String): Artist
  249. - song (String): Song
  250. - callback (Function): Function to be called when search compete, to obtain results.
  251. **/
  252. search: function(artist, song, duration, callback){
  253. console.log("Seaching:", artist, " - ", song)
  254. console.log("Search method:", this.search_method)
  255.  
  256. if(this.search_method == undefined){
  257. this.determineSearchMethod(function(response){
  258. console.log("Search method:", response.search_method)
  259.  
  260. VK.search_method = response.search_method
  261.  
  262. VK.search(artist, song, duration, callback)
  263. })
  264.  
  265. return
  266. }
  267.  
  268. artist = artist.toLowerCase()
  269. song = song.toLowerCase()
  270.  
  271. if(duration != undefined)
  272. duration = parseInt(duration)
  273.  
  274. var track = artist + " " + song
  275.  
  276. if(CACHE.get(track))
  277. return callback(CACHE.get(track))
  278.  
  279. _gaq.push(['_trackEvent', 'vkontakte_search', this.search_method, artist+'-'+song]);
  280.  
  281. if(this.search_method == "test_mode")
  282. this._testmodeSearch(artist, song, duration, callback)
  283. else
  284. this._rawSearch(artist, song, duration, callback)
  285.  
  286. console.log("Setting search method to null");
  287. this.search_method = undefined;
  288. }
  289. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement