Handle bad tracks, tracks with weird names
This commit is contained in:
parent
3205af0be6
commit
270d80ee0e
|
@ -86,18 +86,22 @@ class window.Player
|
||||||
$('.playlist li').removeClass 'now'
|
$('.playlist li').removeClass 'now'
|
||||||
$obj.addClass 'now'
|
$obj.addClass 'now'
|
||||||
_vk_music.search track.artist, track.name, track.duration, (audio) ->
|
_vk_music.search track.artist, track.name, track.duration, (audio) ->
|
||||||
_player.playSource audio.url
|
if audio is null
|
||||||
if track.length == 0
|
console.log audio
|
||||||
len = parseInt(audio.duration, 10)
|
_player.setTrack _player.nextTrack(true)
|
||||||
m = Math.floor(len / 60)
|
else
|
||||||
s = len - Math.floor(len / 60) * 60
|
_player.playSource audio.url
|
||||||
duration = m + ':' + (if s < 10 then '0' else '') + s
|
if track.length == 0
|
||||||
_session.query '/track/update_length', { track_id: track.id, length: len }, (r) ->
|
len = parseInt(audio.duration, 10)
|
||||||
if r.result is 'success'
|
m = Math.floor(len / 60)
|
||||||
$('.playlist li[data-id="'+track.id+'"] .song-duration').text(duration)
|
s = len - Math.floor(len / 60) * 60
|
||||||
$($('.album div[data-id="'+track.id+'"]').siblings()[0]).text(duration)
|
duration = m + ':' + (if s < 10 then '0' else '') + s
|
||||||
|
_session.query '/track/update_length', { track_id: track.id, length: len }, (r) ->
|
||||||
this.updateNowListening track
|
if r.result is 'success'
|
||||||
|
$('.playlist li[data-id="'+track.id+'"] .song-duration').text(duration)
|
||||||
|
$($('.album div[data-id="'+track.id+'"]').siblings()[0]).text(duration)
|
||||||
|
_player.updateNowListening track
|
||||||
|
false
|
||||||
false
|
false
|
||||||
|
|
||||||
getTrackInfo: (id) ->
|
getTrackInfo: (id) ->
|
||||||
|
|
|
@ -59,7 +59,7 @@ class window.VkontakteMusic
|
||||||
data
|
data
|
||||||
|
|
||||||
prepareQuery: (artist, track) ->
|
prepareQuery: (artist, track) ->
|
||||||
artist+" "+track.replace(/\(.*\)/i, '').split('/')[0]
|
artist+" "+this.trim(/[\w\d\s]+/.exec(track)[0]).replace(/\(.*\)/i, '').split('/')[0]
|
||||||
|
|
||||||
trim: (str) ->
|
trim: (str) ->
|
||||||
while str.indexOf(' ') isnt -1
|
while str.indexOf(' ') isnt -1
|
||||||
|
|
Loading…
Reference in New Issue