mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
steal some of @tcsenpai 's changes from the PR
+ ditch the LAST FM API KEY thing + expose the Musixmatch urls + use the kerve last fm api to download similar artist data + use google.it instead of the Google public dns to check internet connectivity (to make it work in all environments) + return og Dockerfile to fix ARM support
This commit is contained in:
@@ -44,9 +44,6 @@ class HandleArgs:
|
||||
sys.exit(0)
|
||||
|
||||
config_keys = [
|
||||
"LASTFM_API_KEY",
|
||||
"PLUGIN_LYRICS_AUTHORITY",
|
||||
"PLUGIN_LYRICS_ROOT_URL",
|
||||
"SWINGMUSIC_APP_VERSION",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
LASTFM_API_KEY = ""
|
||||
PLUGIN_LYRICS_AUTHORITY = ""
|
||||
PLUGIN_LYRICS_ROOT_URL = ""
|
||||
SWINGMUSIC_APP_VERSION = ""
|
||||
|
||||
@@ -14,7 +14,7 @@ def fetch_similar_artists(name: str):
|
||||
"""
|
||||
Fetches similar artists from Last.fm
|
||||
"""
|
||||
url = f"https://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist={urllib.parse.quote_plus(name, safe='')}&api_key={settings.Keys.LASTFM_API_KEY}&format=json&limit=250"
|
||||
url = f"https://kerve.last.fm/kerve/similarartists?artist={urllib.parse.quote_plus(name, safe='')}&autocorrect=1&tracks=1&image_size=large&limit=250&format=json"
|
||||
|
||||
try:
|
||||
response = requests.get(url, timeout=10)
|
||||
@@ -25,7 +25,7 @@ def fetch_similar_artists(name: str):
|
||||
data = response.json()
|
||||
|
||||
try:
|
||||
artists = data["similarartists"]["artist"]
|
||||
artists = data["results"]["artist"]
|
||||
except KeyError:
|
||||
return []
|
||||
|
||||
|
||||
+6
-9
@@ -235,26 +235,23 @@ class TCOLOR:
|
||||
|
||||
class Keys:
|
||||
# get last fm api key from os environment
|
||||
LASTFM_API_KEY = os.environ.get("LASTFM_API_KEY")
|
||||
PLUGIN_LYRICS_AUTHORITY = os.environ.get("PLUGIN_LYRICS_AUTHORITY")
|
||||
PLUGIN_LYRICS_ROOT_URL = os.environ.get("PLUGIN_LYRICS_ROOT_URL")
|
||||
PLUGIN_LYRICS_AUTHORITY = os.environ.get("apic-desktop.musixmatch.com")
|
||||
PLUGIN_LYRICS_ROOT_URL = os.environ.get("https://apic-desktop.musixmatch.com/ws/1.1/")
|
||||
SWINGMUSIC_APP_VERSION = os.environ.get("SWINGMUSIC_APP_VERSION")
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
if IS_BUILD:
|
||||
cls.LASTFM_API_KEY = configs.LASTFM_API_KEY
|
||||
cls.PLUGIN_LYRICS_AUTHORITY = configs.PLUGIN_LYRICS_AUTHORITY
|
||||
cls.PLUGIN_LYRICS_ROOT_URL = configs.PLUGIN_LYRICS_ROOT_URL
|
||||
cls.SWINGMUSIC_APP_VERSION = configs.SWINGMUSIC_APP_VERSION
|
||||
|
||||
cls.verify_keys()
|
||||
|
||||
@classmethod
|
||||
def verify_keys(cls):
|
||||
if not cls.LASTFM_API_KEY:
|
||||
print("ERROR: LASTFM_API_KEY not set in environment")
|
||||
sys.exit(0)
|
||||
# if not cls.LASTFM_API_KEY:
|
||||
# print("ERROR: LASTFM_API_KEY not set in environment")
|
||||
# sys.exit(0)
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def get(cls, key: str):
|
||||
|
||||
@@ -44,7 +44,6 @@ class TrackStore:
|
||||
"""
|
||||
|
||||
cls.tracks.append(track)
|
||||
print(f"\n A: Current track count:, {len(cls.tracks)} \n")
|
||||
|
||||
@classmethod
|
||||
def add_tracks(cls, tracks: list[Track]):
|
||||
@@ -53,7 +52,6 @@ class TrackStore:
|
||||
"""
|
||||
|
||||
cls.tracks.extend(tracks)
|
||||
print(f"\n E: Current track count:, {len(cls.tracks)} \n")
|
||||
|
||||
@classmethod
|
||||
def remove_track_obj(cls, track: Track):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import socket as Socket
|
||||
|
||||
|
||||
def has_connection(host="8.8.8.8", port=53, timeout=3):
|
||||
def has_connection(host="google.it", port=80, timeout=3):
|
||||
"""
|
||||
Host: 8.8.8.8 (google-public-dns-a.google.com)
|
||||
OpenPort: 53/tcp
|
||||
|
||||
Reference in New Issue
Block a user