Skip to content

Commit

Permalink
fixed zip normal zip download
Browse files Browse the repository at this point in the history
  • Loading branch information
akashrchandran committed Mar 5, 2024
1 parent 66ad372 commit 2b81ec0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions static/js/spotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ noramlDownload = async () => {
let bar = document.getElementById('progress');
downloadbtn.forEach((btn) => {
const id = btn.getAttribute('data-id');
const name = btn.getAttribute('data-name');
promises.push(get_lyrics(id).then(response => {
const attributes = ['data-name', 'data-album', 'data-artist', 'data-title', 'data-length'];
const [name, album, artist, title, length] = attributes.map(attr => btn.getAttribute(attr));
const lyrics = response[0]
const sync = response[1]
if (lyrics == null) {
Expand All @@ -54,6 +55,7 @@ noramlDownload = async () => {
btn.previousElementSibling.classList.add('badge', 'bg-warning');
btn.previousElementSibling.textContent = 'Synced lyrics not available';
}
lyrics.unshift(`[ar:${artist}]\n[al:${album}]\n[ti:${title}]\n[length:${length}]\n\n`);
zip.file(`${sanitizeFilename(name)}.lrc`, lyrics.join(""));
count++;
let variable = ((count / downloadbtn.length) * 100).toFixed(2);
Expand Down Expand Up @@ -141,10 +143,12 @@ downloadbtn.forEach((btn) => {
btn.addEventListener('click', async () => {
btn.innerHTML = '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>';
btn.classList.add('disabled');
const id = btn.getAttribute('data-id');
const name = btn.getAttribute('data-name');
const attributes = ['data-id', 'data-name', 'data-album', 'data-artist', 'data-title', 'data-length'];
const [id, name, album, artist, title, length] = attributes.map(attr => btn.getAttribute(attr));

const response = await get_lyrics(id);
let lyrics = response[0];
lyrics.unshift(`[ar:${artist}]\n[al:${album}]\n[ti:${title}]\n[length:${length}]\n\n`);
let sync = response[1];
if (lyrics == null) {
btn.innerHTML = '<i class="fa fa-times" aria-hidden="true"></i>';
Expand Down
2 changes: 1 addition & 1 deletion templates/spotify.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h4>{{ data['popularity'] }} popularity</h4>
<span class="bg-danger text-wrap mx-3"></span>
<button type="button" class="btn btn-success float-end" title="download lyrics" name="download"
data-id="{{ data['id'] }}" data-name="{{ data['track_number']}}. {{ data['name'] }}"
data-artist="{{ data['artists'] }}"
data-artist="{{ data['artist'] }}"
data-album="{{ data['album'] }}" data-title="{{ data['name'] }}"
data-length="{{ data['duration'] }}">
<i class="fa fa-download" aria-hidden="true"></i>
Expand Down

0 comments on commit 2b81ec0

Please sign in to comment.