add spotify preview link
This commit is contained in:
parent
ccea266fcf
commit
ce245d318d
3 changed files with 14 additions and 2 deletions
|
@ -4,7 +4,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from django.db import models
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.shortcuts import reverse
|
||||
from common.models import Entity, Mark, Review, Tag
|
||||
from common.models import Entity, Mark, Review, Tag, SourceSiteEnum
|
||||
from common.utils import ChoicesDictGenerator, GenerateDateUUIDMediaFilePath
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
|
@ -48,6 +48,9 @@ class Album(Entity):
|
|||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def get_embed_link(self):
|
||||
return self.source_url.replace("open.spotify.com/", "open.spotify.com/embed/") if self.source_site == SourceSiteEnum.SPOTIFY.value else None
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("music:retrieve_album", args=[self.id])
|
||||
|
||||
|
@ -87,6 +90,9 @@ class Song(Entity):
|
|||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def get_embed_link(self):
|
||||
return self.source_url.replace("open.spotify.com/", "open.spotify.com/embed/") if self.source_site == SourceSiteEnum.SPOTIFY.value else None
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("music:retrieve_song", args=[self.id])
|
||||
|
||||
|
|
|
@ -350,6 +350,9 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if album.source_site == "spotify" %}
|
||||
<iframe src="{{ album.get_embed_link }}" height="320" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
@ -295,7 +295,10 @@
|
|||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
{% if song.source_site == "spotify" %}
|
||||
<iframe src="{{ song.get_embed_link }}" height="80" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
Loading…
Add table
Reference in a new issue