From daafebf5719f4e02319f58cabcce51c1a9d5b0fa Mon Sep 17 00:00:00 2001 From: Aadi Bajpai Date: Mon, 7 Jun 2021 03:30:01 -0500 Subject: [PATCH] [IMPROVEMENT] minor fixes (#2866) * get rid of a line * rewrite xhr to use fetch * remove pr template --- .github/PULL_REQUEST_TEMPLATE.md | 20 -------------------- swaglyrics/cli.py | 3 +-- swaglyrics/static/songChanged.js | 20 ++++++-------------- 3 files changed, 7 insertions(+), 36 deletions(-) delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5fbf0efd..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,20 +0,0 @@ -Please prefix your pull request with one of the following: **[FEATURE]** **[FIX]** **[IMPROVEMENT]**. - -**In raising this pull request, I confirm the following (please check boxes):** - -- [ ] I have read and understood the [contributors guide](https://github.com/SwagLyrics/SwagLyrics-For-Spotify/blob/master/.github/CONTRIBUTING.md). -- [ ] I have checked that another pull request for this purpose does not exist. -- [ ] I have considered, and confirmed that this submission will be valuable to others. -- [ ] I accept that this submission may not be used, and the pull request closed at the will of the maintainer. -- [ ] I give this submission freely, and claim no ownership to its content. - -**My familiarity with the project is as follows (check one):** - -- [ ] I have never used the project. -- [ ] I have used the project briefly. -- [ ] I have used the project extensively, but have not contributed previously. -- [ ] I am an active contributor to the project. - ---- - -{pull request content here} diff --git a/swaglyrics/cli.py b/swaglyrics/cli.py index 4b56fd62..657fc4fa 100644 --- a/swaglyrics/cli.py +++ b/swaglyrics/cli.py @@ -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 diff --git a/swaglyrics/static/songChanged.js b/swaglyrics/static/songChanged.js index 80992c8e..aa36b625 100644 --- a/swaglyrics/static/songChanged.js +++ b/swaglyrics/static/songChanged.js @@ -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(); \ No newline at end of file +const songChanged = async () => { + const resp = await fetch("/songChanged") + if (resp.ok && await resp.text() === "yes") location.reload(true) +} + +setInterval(songChanged, 5000);