mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Merge pull request #5 from ZackBoe/feature-track-search
Add link to track search feature
This commit is contained in:
commit
2101b56b8c
@ -2,6 +2,8 @@ import urllib
|
|||||||
from bottle import FormsDict
|
from bottle import FormsDict
|
||||||
import datetime
|
import datetime
|
||||||
from urihandler import compose_querystring
|
from urihandler import compose_querystring
|
||||||
|
import urllib.parse
|
||||||
|
from doreah.settings import get_settings
|
||||||
|
|
||||||
|
|
||||||
# returns the proper column(s) for an artist or track
|
# returns the proper column(s) for an artist or track
|
||||||
@ -16,7 +18,10 @@ def entity_column(element,counting=[],image=None):
|
|||||||
# track
|
# track
|
||||||
# html += "<td class='artists'>" + html_links(element["artists"]) + "</td>"
|
# html += "<td class='artists'>" + html_links(element["artists"]) + "</td>"
|
||||||
# html += "<td class='title'>" + html_link(element) + "</td>"
|
# html += "<td class='title'>" + html_link(element) + "</td>"
|
||||||
html += "<td class='track'><span class='artist_in_trackcolumn'>" + html_links(element["artists"]) + "</span> – " + html_link(element) + "</td>"
|
html += "<td class='track'><span class='artist_in_trackcolumn'>"
|
||||||
|
if get_settings("TRACK_SEARCH_PROVIDER") not in [None,"ASK", ""]:
|
||||||
|
html += trackSearchLink(element)
|
||||||
|
html += html_links(element["artists"]) + "</span> – " + html_link(element) + "</td>"
|
||||||
else:
|
else:
|
||||||
# artist
|
# artist
|
||||||
html += "<td class='artist'>" + html_link(element)
|
html += "<td class='artist'>" + html_link(element)
|
||||||
@ -74,6 +79,31 @@ def trackLink(track):
|
|||||||
#artists,title = track["artists"],track["title"]
|
#artists,title = track["artists"],track["title"]
|
||||||
#return "<a href='/track?title=" + urllib.parse.quote(title) + "&" + "&".join(["artist=" + urllib.parse.quote(a) for a in artists]) + "'>" + title + "</a>"
|
#return "<a href='/track?title=" + urllib.parse.quote(title) + "&" + "&".join(["artist=" + urllib.parse.quote(a) for a in artists]) + "'>" + title + "</a>"
|
||||||
|
|
||||||
|
def trackSearchLink(track):
|
||||||
|
searchProvider = get_settings("TRACK_SEARCH_PROVIDER")
|
||||||
|
link = "<a class='trackProviderSearch' href='"
|
||||||
|
if searchProvider == "YouTube":
|
||||||
|
link += "https://www.youtube.com/results?search_query="
|
||||||
|
elif searchProvider == "YouTube Music":
|
||||||
|
link += "https://music.youtube.com/search?q="
|
||||||
|
elif searchProvider == "Google Play Music":
|
||||||
|
link += "https://play.google.com/music/listen#/srs/"
|
||||||
|
elif searchProvider == "Spotify":
|
||||||
|
link += "https://open.spotify.com/search/results/"
|
||||||
|
elif searchProvider == "Tidal":
|
||||||
|
link += "https://listen.tidal.com/search/tracks?q="
|
||||||
|
elif searchProvider == "SoundCloud":
|
||||||
|
link += "https://soundcloud.com/search?q="
|
||||||
|
elif searchProvider == "Amazon Music":
|
||||||
|
link += "https://music.amazon.com/search/"
|
||||||
|
elif searchProvider == "Deezer":
|
||||||
|
link += "https://www.deezer.com/search/"
|
||||||
|
else:
|
||||||
|
link += "https://www.google.com/search?q=" # ¯\_(ツ)_/¯
|
||||||
|
|
||||||
|
link += urllib.parse.quote(", ".join(track["artists"]) + " - " + track["title"]) + "'>🎵</a>"
|
||||||
|
return link
|
||||||
|
|
||||||
#def scrobblesTrackLink(artists,title,timekeys,amount=None,pixels=None):
|
#def scrobblesTrackLink(artists,title,timekeys,amount=None,pixels=None):
|
||||||
def scrobblesTrackLink(track,timekeys,amount=None,percent=None):
|
def scrobblesTrackLink(track,timekeys,amount=None,percent=None):
|
||||||
artists,title = track["artists"],track["title"]
|
artists,title = track["artists"],track["title"]
|
||||||
|
@ -17,6 +17,10 @@ SPOTIFY_API_SECRET = "ASK"
|
|||||||
CACHE_EXPIRE_NEGATIVE = 30 # after how many days negative results should be tried again
|
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
|
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]
|
[Database]
|
||||||
|
|
||||||
DB_CACHE_SIZE = 8192 # how many MB on disk each database cache should have available.
|
DB_CACHE_SIZE = 8192 # how many MB on disk each database cache should have available.
|
||||||
|
@ -493,7 +493,10 @@ table.list td.track span.artist_in_trackcolumn {
|
|||||||
color:#bbb;
|
color:#bbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.list td.track a.trackProviderSearch {
|
||||||
|
margin-right: 5px;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user