Skip to content

Instantly share code, notes, and snippets.

@sk89q
Created October 20, 2014 06:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sk89q/c405b25ee8984ac06772 to your computer and use it in GitHub Desktop.
Save sk89q/c405b25ee8984ac06772 to your computer and use it in GitHub Desktop.
Deduplicate Spotify tracks
<!DOCTYPE html>
<html>
<head>
<title>Deduplicate Spotify tracks based on track artist and title</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style>
body {
padding: 40px;
}
#input {
width: 90%;
height: 200px;
border: 2px solid red;
overflow: auto;
}
#output {
width: 90%;
height: 200px;
}
</style>
</head>
<body>
<div class="container">
<h1>Deduplicate Spotify tracks (based on track name)</h1>
<p>Drag your playlist into here:</p>
<div id="input" contenteditable="true"></div>
<br>
<p>Then click this button: <button class="btn btn-primary" id="deduplicate">Deduplicate</button></p>
<hr>
<h2>Results</h2>
<p>Then drag/paste this into your playlist (after clearing your playlist):</p>
<textarea id="output"></textarea>
<p><span class="label label-info">Tip:</span> The input box above now lists tracks that were removed.</p>
<hr>
<p>By <a href="http://twitter.com/sk89q">@sk89q</a></p>
</div>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
var $input = $("#input");
var $output = $("#output");
$("#deduplicate").on("click", function (e) {
var found = {};
var results = [];
var left = [];
$input.find("a").each(function () {
var $this = $(this);
var name = $this.text();
var url = $this.attr('href');
if (!found.hasOwnProperty(name)) {
found[name] = url;
results.push(url);
$this.remove();
} else {
left.push($this);
left.push("<br >");
}
});
$input.empty().append(left);
$output.val(results.join("\n"));
});
</script>
</body>
</html>
@sk89q
Copy link
Author

sk89q commented Oct 20, 2014

@shape55
Copy link

shape55 commented Apr 19, 2017

Hi, I'm not getting any results to appear in the 2nd window after Deduplicating tracks. Is there a track limit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment