Permalink
Browse files

extended from youtube's "strip crap"

  • Loading branch information...
1 parent de2637c commit e278951d339ca8ebfcaf551042ea88c93f23afe1 @lacivert lacivert committed Mar 12, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 ttnet.js
View
18 ttnet.js
@@ -66,12 +66,20 @@ function cleanArtistTrack(artist, track) {
track = track.replace(/^\s+|\s+$/g,'');
// Strip crap
-
- track = track.replace(/\s*(Explicit Album Version)/i, ''); // (Explicit Album Version)
- track = track.replace(/\s*(Album Version)/i, ''); // (Album Version)
- track = track.replace(/\s*(Explicit Version)/i, ''); // (Explicit Version)
- track = track.replace(/\s*[Explicit]/i, ''); // [Explicit]
+ track = track.replace(/\s*\*+\s?\S+\s?\*+$/, ''); // **NEW**
+ track = track.replace(/\s*\[[^\]]+\]$/, ''); // [whatever]
+ track = track.replace(/\s*\.(avi|wmv|mpg|mpeg|flv)$/i, ''); // video extensions
+ track = track.replace(/\s*(of+icial\s*)?(music\s*)?video/i, ''); // (official)? (music)? video
+ track = track.replace(/\s*\(\s*of+icial\s*\)/i, ''); // (official)
+ track = track.replace(/\s+\(\s*(HD|HQ)\s*\)$/, ''); // HD (HQ)
+ track = track.replace(/\s+(HD|HQ)\s*$/, ''); // HD (HQ)
+ track = track.replace(/\s*video\s*clip/i, ''); // video clip
+ track = track.replace(/\s+\(?live\)?$/i, ''); // live
track = track.replace(/\(\s*\)/, ''); // Leftovers after e.g. (official video)
+ track = track.replace(/^(|.*\s)"(.*)"(\s.*|)$/, '$2'); // Artist - The new "Track title" featuring someone
+ track = track.replace(/^(|.*\s)'(.*)'(\s.*|)$/, '$2'); // 'Track title'
+ track = track.replace(/^[\/\s,:;~-]+/, ''); // trim starting white chars and dash
+ track = track.replace(/[\/\s,:;~-]+$/, ''); // trim trailing white chars and dash
return {artist: artist, track: track};
}

0 comments on commit e278951

Please sign in to comment.