From cc3f9f7fef801023f1bb6711f25b6da7344ca540 Mon Sep 17 00:00:00 2001 From: Zack Boehm Date: Wed, 21 Aug 2019 16:19:01 -0400 Subject: [PATCH] Add track search feature Adds a link to the search results for each track on a provider of choice --- htmlgenerators.py | 32 +++++++++++++++++++++++++++++++- settings/default.ini | 4 ++++ website/css/maloja.css | 5 ++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/htmlgenerators.py b/htmlgenerators.py index c8b7b5e..94e0642 100644 --- a/htmlgenerators.py +++ b/htmlgenerators.py @@ -2,6 +2,8 @@ import urllib from bottle import FormsDict import datetime from urihandler import compose_querystring +import urllib.parse +from doreah.settings import get_settings # returns the proper column(s) for an artist or track @@ -16,7 +18,10 @@ def entity_column(element,counting=[],image=None): # track # html += "" + html_links(element["artists"]) + "" # html += "" + html_link(element) + "" - html += "" + html_links(element["artists"]) + " – " + html_link(element) + "" + html += "" + if get_settings("TRACK_SEARCH_PROVIDER") not in [None,"ASK", ""]: + html += trackSearchLink(element) + html += html_links(element["artists"]) + " – " + html_link(element) + "" else: # artist html += "" + html_link(element) @@ -74,6 +79,31 @@ def trackLink(track): #artists,title = track["artists"],track["title"] #return "" + title + "" +def trackSearchLink(track): + searchProvider = get_settings("TRACK_SEARCH_PROVIDER") + link = "🎵" + return link + #def scrobblesTrackLink(artists,title,timekeys,amount=None,pixels=None): def scrobblesTrackLink(track,timekeys,amount=None,percent=None): artists,title = track["artists"],track["title"] diff --git a/settings/default.ini b/settings/default.ini index 9a12d93..bf1390f 100644 --- a/settings/default.ini +++ b/settings/default.ini @@ -17,6 +17,10 @@ SPOTIFY_API_SECRET = "ASK" CACHE_EXPIRE_NEGATIVE = 30 # after how many days negative results should be tried again CACHE_EXPIRE_POSITIVE = 300 # after how many days positive results should be refreshed +# Can be 'YouTube', 'YouTube Music', 'Google Play Music', 'Spotify', 'Tidal', 'SoundCloud', 'Deezer', 'Amazon Music' +# Leave empty to disable +TRACK_SEARCH_PROVIDER = "YouTube" + [Database] DB_CACHE_SIZE = 8192 # how many MB on disk each database cache should have available. diff --git a/website/css/maloja.css b/website/css/maloja.css index ca50cec..179d370 100644 --- a/website/css/maloja.css +++ b/website/css/maloja.css @@ -493,7 +493,10 @@ table.list td.track span.artist_in_trackcolumn { color:#bbb; } - +table.list td.track a.trackProviderSearch { + margin-right: 5px; + padding: 0 10px; +}