Skip to content

Commit

Permalink
[IMPROVEMENT] minor fixes (#2866)
Browse files Browse the repository at this point in the history
* get rid of a line

* rewrite xhr to use fetch

* remove pr template
  • Loading branch information
aadibajpai authored Jun 7, 2021
1 parent 72f074b commit daafebf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 36 deletions.
20 changes: 0 additions & 20 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

3 changes: 1 addition & 2 deletions swaglyrics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def stripper(song: str, artist: str) -> str:
# replace /, !, _ with space to support more songs
url_data = url_data.replace('/', ' ').replace('!', ' ').replace('_', ' ')
for ch in ['Ø', 'ø']:
if ch in url_data:
url_data = url_data.replace(ch, '')
url_data = url_data.replace(ch, '')
url_data = re.sub(nlt, '', url_data) # remove non-latin characters before unidecode
url_data = unidecode(url_data) # convert accents and other diacritics
url_data = re.sub(aln, '', url_data) # remove punctuation and other characters
Expand Down
20 changes: 6 additions & 14 deletions swaglyrics/static/songChanged.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
function songChanged() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "/songChanged", true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
if (xhr.responseText === 'yes') {
location.reload(true)
}
setTimeout(songChanged, 5000)
}
};
xhr.send();
}
songChanged();
const songChanged = async () => {
const resp = await fetch("/songChanged")
if (resp.ok && await resp.text() === "yes") location.reload(true)
}

setInterval(songChanged, 5000);

0 comments on commit daafebf

Please sign in to comment.