Merge pull request #185 from plastikman/develop-nolicense-fixcoverart
Cherry picked https://sourceforge.net/p/subsonic/code/4587/master
commit
8d28f2ab87
@ -0,0 +1,69 @@ |
||||
/* |
||||
* This file is part of Libresonic. |
||||
* |
||||
* Libresonic is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* Libresonic is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
* Copyright 2016 (C) Libresonic Authors |
||||
* Based upon Subsonic, Copyright 2009 (C) Sindre Mehus |
||||
*/ |
||||
|
||||
package org.libresonic.player.domain; |
||||
|
||||
/** |
||||
* @author Sindre Mehus |
||||
* @version $Id$ |
||||
*/ |
||||
public class AlbumNotes { |
||||
|
||||
private final String notes; |
||||
private final String musicBrainzId; |
||||
private final String lastFmUrl; |
||||
private final String smallImageUrl; |
||||
private final String mediumImageUrl; |
||||
private final String largeImageUrl; |
||||
|
||||
public AlbumNotes(String notes, String musicBrainzId, String lastFmUrl, String smallImageUrl, |
||||
String mediumImageUrl, String largeImageUrl) { |
||||
this.notes = notes; |
||||
this.musicBrainzId = musicBrainzId; |
||||
this.lastFmUrl = lastFmUrl; |
||||
this.smallImageUrl = smallImageUrl; |
||||
this.mediumImageUrl = mediumImageUrl; |
||||
this.largeImageUrl = largeImageUrl; |
||||
} |
||||
|
||||
public String getNotes() { |
||||
return notes; |
||||
} |
||||
|
||||
public String getMusicBrainzId() { |
||||
return musicBrainzId; |
||||
} |
||||
|
||||
public String getLastFmUrl() { |
||||
return lastFmUrl; |
||||
} |
||||
|
||||
public String getSmallImageUrl() { |
||||
return smallImageUrl; |
||||
} |
||||
|
||||
public String getMediumImageUrl() { |
||||
return mediumImageUrl; |
||||
} |
||||
|
||||
public String getLargeImageUrl() { |
||||
return largeImageUrl; |
||||
} |
||||
} |
@ -0,0 +1,50 @@ |
||||
/* |
||||
* This file is part of Libresonic. |
||||
* |
||||
* Libresonic is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* Libresonic is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
* Copyright 2014 (C) Sindre Mehus |
||||
*/ |
||||
|
||||
package org.libresonic.player.domain; |
||||
|
||||
/** |
||||
* @author Sindre Mehus |
||||
* @version $Id$ |
||||
*/ |
||||
public class LastFmCoverArt { |
||||
|
||||
private final String imageUrl; |
||||
private final String artist; |
||||
private final String album; |
||||
|
||||
public LastFmCoverArt(String imageUrl, String artist, String album) { |
||||
this.imageUrl = imageUrl; |
||||
this.artist = artist; |
||||
this.album = album; |
||||
} |
||||
|
||||
public String getImageUrl() { |
||||
return imageUrl; |
||||
} |
||||
|
||||
public String getArtist() { |
||||
return artist; |
||||
} |
||||
|
||||
public String getAlbum() { |
||||
return album; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,49 @@ |
||||
/** |
||||
* This file is part of Libresonic. |
||||
* |
||||
* Libresonic is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* Libresonic is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Libresonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
* Copyright 2014 (C) Sindre Mehus |
||||
*/ |
||||
|
||||
package org.libresonic.player.service; |
||||
|
||||
import java.util.LinkedHashMap; |
||||
import java.util.Map; |
||||
|
||||
import de.umass.lastfm.cache.ExpirationPolicy; |
||||
|
||||
/** |
||||
* Artist and album info is cached permanently. Everything else is cached one year. |
||||
* |
||||
* @author Sindre Mehus |
||||
* @version $Id$ |
||||
*/ |
||||
public class LastFmExpirationPolicy implements ExpirationPolicy { |
||||
|
||||
private final static long ONE_YEAR = 12 * 30 * 24 * 3600 * 1000L; |
||||
|
||||
private final Map<String, Long> methodToExpirationTime = new LinkedHashMap<String, Long>() {{ |
||||
put("artist.getInfo", Long.MAX_VALUE); // Cache forever
|
||||
put("album.getInfo", Long.MAX_VALUE); // Cache forever
|
||||
put("album.search", -1L); // Don't cache
|
||||
}}; |
||||
|
||||
@Override |
||||
public long getExpirationTime(String method, Map<String, String> params) { |
||||
Long expirationTime = methodToExpirationTime.get(method); |
||||
return expirationTime == null ? ONE_YEAR : expirationTime; |
||||
} |
||||
} |
||||
|
@ -1,144 +1,143 @@ |
||||
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="iso-8859-1" %> |
||||
<%@ include file="include.jsp" %> |
||||
|
||||
<%-- |
||||
PARAMETERS |
||||
albumId: ID of album. |
||||
playlistId: ID of playlist. |
||||
podcastChannelId: ID of podcast channel |
||||
coverArtSize: Height and width of cover art. |
||||
caption1: Caption line 1 |
||||
caption2: Caption line 2 |
||||
caption3: Caption line 3 |
||||
captionCount: Number of caption lines to display (default 0) |
||||
showLink: Whether to make the cover art image link to the album page. |
||||
showZoom: Whether to display a link for zooming the cover art. |
||||
showChange: Whether to display a link for changing the cover art. |
||||
appearAfter: Fade in after this many milliseconds, or nil if no fading in should happen. |
||||
hideOverflow: Hide cover art overflow when height is greater than width |
||||
--%> |
||||
<c:choose> |
||||
<c:when test="${empty param.coverArtSize}"> |
||||
<c:set var="size" value="auto"/> |
||||
</c:when> |
||||
<c:otherwise> |
||||
<c:set var="size" value="${param.coverArtSize}px"/> |
||||
</c:otherwise> |
||||
</c:choose> |
||||
|
||||
<c:set var="captionCount" value="${empty param.captionCount ? 0 : param.captionCount}"/> |
||||
|
||||
<str:randomString count="5" type="alphabet" var="divId"/> |
||||
<str:randomString count="5" type="alphabet" var="imgId"/> |
||||
<str:randomString count="5" type="alphabet" var="playId"/> |
||||
|
||||
<div class="coverart dropshadow"> |
||||
<div style="width:${size};max-width:${size};height:${size};max-height:${size};cursor:pointer;<c:if test="${param.hideOverflow}">overflow:hidden</c:if>;" title="${param.caption1}" id="${divId}"> |
||||
|
||||
<c:if test="${not empty param.albumId}"> |
||||
<c:url value="main.view" var="targetUrl"> |
||||
<c:param name="id" value="${param.albumId}"/> |
||||
</c:url> |
||||
</c:if> |
||||
<c:if test="${not empty param.playlistId}"> |
||||
<c:url value="playlist.view" var="targetUrl"> |
||||
<c:param name="id" value="${param.playlistId}"/> |
||||
</c:url> |
||||
</c:if> |
||||
<c:if test="${not empty param.podcastChannelId}"> |
||||
<c:url value="podcastChannel.view" var="targetUrl"> |
||||
<c:param name="id" value="${param.podcastChannelId}"/> |
||||
</c:url> |
||||
</c:if> |
||||
|
||||
<c:url value="/coverArt.view" var="coverArtUrl"> |
||||
<c:if test="${not empty param.coverArtSize}"> |
||||
<c:param name="size" value="${param.coverArtSize}"/> |
||||
</c:if> |
||||
<c:if test="${not empty param.albumId}"> |
||||
<c:param name="id" value="${param.albumId}"/> |
||||
</c:if> |
||||
<c:if test="${not empty param.podcastChannelId}"> |
||||
<c:param name="id" value="pod-${param.podcastChannelId}"/> |
||||
</c:if> |
||||
<c:if test="${not empty param.playlistId}"> |
||||
<c:param name="id" value="pl-${param.playlistId}"/> |
||||
</c:if> |
||||
</c:url> |
||||
|
||||
<c:url value="/coverArt.view" var="zoomCoverArtUrl"> |
||||
<c:param name="id" value="${param.albumId}"/> |
||||
</c:url> |
||||
|
||||
<div style="position: relative; width: 0; height: 0"> |
||||
<img src="<spring:theme code="playOverlayImage"/>" id="${playId}" |
||||
style="position: relative; top: 8px; left: 8px; z-index: 2; display:none" > |
||||
</div> |
||||
<c:choose> |
||||
<c:when test="${param.showLink}"><a href="${targetUrl}" title="${param.caption1}"></c:when> |
||||
<c:when test="${param.showZoom}"><a href="${zoomCoverArtUrl}" rel="zoom" title="${param.caption1}"></c:when> |
||||
</c:choose> |
||||
<img src="${coverArtUrl}" id="${imgId}" alt="${param.caption1}" |
||||
style="display:none"> |
||||
<c:if test="${param.showLink or param.showZoom}"></a></c:if> |
||||
</div> |
||||
|
||||
<c:if test="${captionCount gt 0}"> |
||||
<div class="caption1" style="width:${param.coverArtSize - 16}px"><a href="${targetUrl}" title="${param.caption1}">${param.caption1}</a></div> |
||||
</c:if> |
||||
<c:if test="${captionCount gt 1}"> |
||||
<div class="caption2" style="width:${param.coverArtSize - 16}px">${param.caption2} </div> |
||||
</c:if> |
||||
<c:if test="${captionCount gt 2}"> |
||||
<div class="caption3" style="width:${param.coverArtSize - 16}px">${param.caption3} </div> |
||||
</c:if> |
||||
</div> |
||||
|
||||
<c:if test="${param.showChange or param.showZoom}"> |
||||
<div style="padding-top:6px;text-align:right"> |
||||
<c:if test="${param.showChange}"> |
||||
<c:url value="/changeCoverArt.view" var="changeCoverArtUrl"> |
||||
<c:param name="id" value="${param.albumId}"/> |
||||
</c:url> |
||||
<a class="detail" href="${changeCoverArtUrl}"><fmt:message key="coverart.change"/></a> |
||||
</c:if> |
||||
|
||||
<c:if test="${param.showZoom and param.showChange}"> |
||||
| |
||||
</c:if> |
||||
|
||||
<c:if test="${param.showZoom}"> |
||||
<a class="detail" rel="zoom" title="${param.caption1}" href="${zoomCoverArtUrl}"><fmt:message key="coverart.zoom"/></a> |
||||
</c:if> |
||||
</div> |
||||
</c:if> |
||||
|
||||
<script type="text/javascript"> |
||||
$(document).ready(function () { |
||||
setTimeout("$('#${imgId}').fadeIn(500)", ${empty param.appearAfter ? 0 : param.appearAfter}); |
||||
}); |
||||
|
||||
$("#${divId}").mouseenter(function () { |
||||
$("#${playId}").show(); |
||||
$("#${imgId}").stop(); |
||||
$("#${imgId}").animate({opacity: 0.7}, 150); |
||||
}); |
||||
$("#${divId}").mouseleave(function () { |
||||
$("#${playId}").hide(); |
||||
$("#${imgId}").stop(); |
||||
$("#${imgId}").animate({opacity: 1.0}, 150); |
||||
}); |
||||
$("#${playId}").click(function () { |
||||
<c:if test="${not empty param.albumId}"> |
||||
top.playQueue.onPlay(${param.albumId}); |
||||
</c:if> |
||||
<c:if test="${not empty param.playlistId}"> |
||||
top.playQueue.onPlayPlaylist(${param.playlistId}); |
||||
</c:if> |
||||
<c:if test="${not empty param.podcastChannelId}"> |
||||
top.playQueue.onPlayPodcastChannel(${param.podcastChannelId}); |
||||
</c:if> |
||||
}); |
||||
|
||||
</script> |
||||
|
||||
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="iso-8859-1" %> |
||||
<%@ include file="include.jsp" %> |
||||
|
||||
<%-- |
||||
PARAMETERS |
||||
albumId: ID of album. |
||||
playlistId: ID of playlist. |
||||
podcastChannelId: ID of podcast channel |
||||
coverArtSize: Height and width of cover art. |
||||
caption1: Caption line 1 |
||||
caption2: Caption line 2 |
||||
caption3: Caption line 3 |
||||
captionCount: Number of caption lines to display (default 0) |
||||
showLink: Whether to make the cover art image link to the album page. |
||||
showZoom: Whether to display a link for zooming the cover art. |
||||
showChange: Whether to display a link for changing the cover art. |
||||
appearAfter: Fade in after this many milliseconds, or nil if no fading in should happen. |
||||
--%> |
||||
<c:choose> |
||||
<c:when test="${empty param.coverArtSize}"> |
||||
<c:set var="size" value="auto"/> |
||||
</c:when> |
||||
<c:otherwise> |
||||
<c:set var="size" value="${param.coverArtSize}px"/> |
||||
</c:otherwise> |
||||
</c:choose> |
||||
|
||||
<c:set var="captionCount" value="${empty param.captionCount ? 0 : param.captionCount}"/> |
||||
|
||||
<str:randomString count="5" type="alphabet" var="divId"/> |
||||
<str:randomString count="5" type="alphabet" var="imgId"/> |
||||
<str:randomString count="5" type="alphabet" var="playId"/> |
||||
|
||||
<div class="coverart dropshadow"> |
||||
<div style="width:${size};max-width:${size};height:${size};max-height:${size};cursor:pointer" title="${param.caption1}" id="${divId}"> |
||||
|
||||
<c:if test="${not empty param.albumId}"> |
||||
<c:url value="main.view" var="targetUrl"> |
||||
<c:param name="id" value="${param.albumId}"/> |
||||
</c:url> |
||||
</c:if> |
||||
<c:if test="${not empty param.playlistId}"> |
||||
<c:url value="playlist.view" var="targetUrl"> |
||||
<c:param name="id" value="${param.playlistId}"/> |
||||
</c:url> |
||||
</c:if> |
||||
<c:if test="${not empty param.podcastChannelId}"> |
||||
<c:url value="podcastChannel.view" var="targetUrl"> |
||||
<c:param name="id" value="${param.podcastChannelId}"/> |
||||
</c:url> |
||||
</c:if> |
||||
|
||||
<c:url value="/coverArt.view" var="coverArtUrl"> |
||||
<c:if test="${not empty param.coverArtSize}"> |
||||
<c:param name="size" value="${param.coverArtSize}"/> |
||||
</c:if> |
||||
<c:if test="${not empty param.albumId}"> |
||||
<c:param name="id" value="${param.albumId}"/> |
||||
</c:if> |
||||
<c:if test="${not empty param.podcastChannelId}"> |
||||
<c:param name="id" value="pod-${param.podcastChannelId}"/> |
||||
</c:if> |
||||
<c:if test="${not empty param.playlistId}"> |
||||
<c:param name="id" value="pl-${param.playlistId}"/> |
||||
</c:if> |
||||
</c:url> |
||||
|
||||
<c:url value="/coverArt.view" var="zoomCoverArtUrl"> |
||||
<c:param name="id" value="${param.albumId}"/> |
||||
</c:url> |
||||
|
||||
<div style="position: relative; width: 0; height: 0"> |
||||
<img src="<spring:theme code="playOverlayImage"/>" id="${playId}" |
||||
style="position: relative; top: 8px; left: 8px; z-index: 2; display:none" > |
||||
</div> |
||||
<c:choose> |
||||
<c:when test="${param.showLink}"><a href="${targetUrl}" title="${param.caption1}"></c:when> |
||||
<c:when test="${param.showZoom}"><a href="${zoomCoverArtUrl}" rel="zoom" title="${param.caption1}"></c:when> |
||||
</c:choose> |
||||
<img src="${coverArtUrl}" id="${imgId}" alt="${param.caption1}" |
||||
style="display:none"> |
||||
<c:if test="${param.showLink or param.showZoom}"></a></c:if> |
||||
</div> |
||||
|
||||
<c:if test="${captionCount gt 0}"> |
||||
<div class="caption1" style="width:${param.coverArtSize - 16}px"><a href="${targetUrl}" title="${param.caption1}">${param.caption1}</a></div> |
||||
</c:if> |
||||
<c:if test="${captionCount gt 1}"> |
||||
<div class="caption2" style="width:${param.coverArtSize - 16}px">${param.caption2} </div> |
||||
</c:if> |
||||
<c:if test="${captionCount gt 2}"> |
||||
<div class="caption3" style="width:${param.coverArtSize - 16}px">${param.caption3} </div> |
||||
</c:if> |
||||
</div> |
||||
|
||||
<c:if test="${param.showChange or param.showZoom}"> |
||||
<div style="padding-top:6px;text-align:right"> |
||||
<c:if test="${param.showChange}"> |
||||
<c:url value="/changeCoverArt.view" var="changeCoverArtUrl"> |
||||
<c:param name="id" value="${param.albumId}"/> |
||||
</c:url> |
||||
<a class="detail" href="${changeCoverArtUrl}"><fmt:message key="coverart.change"/></a> |
||||
</c:if> |
||||
|
||||
<c:if test="${param.showZoom and param.showChange}"> |
||||
| |
||||
</c:if> |
||||
|
||||
<c:if test="${param.showZoom}"> |
||||
<a class="detail" rel="zoom" title="${param.caption1}" href="${zoomCoverArtUrl}"><fmt:message key="coverart.zoom"/></a> |
||||
</c:if> |
||||
</div> |
||||
</c:if> |
||||
|
||||
<script type="text/javascript"> |
||||
$(document).ready(function () { |
||||
setTimeout("$('#${imgId}').fadeIn(500)", ${empty param.appearAfter ? 0 : param.appearAfter}); |
||||
}); |
||||
|
||||
$("#${divId}").mouseenter(function () { |
||||
$("#${playId}").show(); |
||||
$("#${imgId}").stop(); |
||||
$("#${imgId}").animate({opacity: 0.7}, 150); |
||||
}); |
||||
$("#${divId}").mouseleave(function () { |
||||
$("#${playId}").hide(); |
||||
$("#${imgId}").stop(); |
||||
$("#${imgId}").animate({opacity: 1.0}, 150); |
||||
}); |
||||
$("#${playId}").click(function () { |
||||
<c:if test="${not empty param.albumId}"> |
||||
top.playQueue.onPlay(${param.albumId}); |
||||
</c:if> |
||||
<c:if test="${not empty param.playlistId}"> |
||||
top.playQueue.onPlayPlaylist(${param.playlistId}); |
||||
</c:if> |
||||
<c:if test="${not empty param.podcastChannelId}"> |
||||
top.playQueue.onPlayPodcastChannel(${param.podcastChannelId}); |
||||
</c:if> |
||||
}); |
||||
|
||||
</script> |
||||
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in new issue