X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/1c72d045af4d7c5607a872a678eadec17498bd6d..refs/heads/master:/src/youtube/models.py?ds=sidebyside diff --git a/src/youtube/models.py b/src/youtube/models.py index df071f1..35899b6 100644 --- a/src/youtube/models.py +++ b/src/youtube/models.py @@ -1,6 +1,5 @@ import io from os import unlink -from tempfile import NamedTemporaryFile from django.db import models from django.utils.translation import gettext_lazy as _ from django.template import Template, Context @@ -232,13 +231,19 @@ class ThumbnailTemplate(models.Model): def generate(self, audiobook): try: + title = audiobook.book['title'] + if audiobook.book.get('parent'): + parent_title = audiobook.book['parent']['title'] + if not title.startswith(parent_title): + title = ", ".join((parent_title, title)) + img = create_thumbnail( self.background.path, self.definition, { "author": ', '.join((a['name'] for a in audiobook.book['authors'])), - "title": audiobook.book['title'], - "part": (audiobook.youtube_volume or audiobook.part_name).strip(), + "title": title, + "part": (audiobook.youtube_volume or audiobook.part_name).strip() if audiobook.youtube_volume_count > 1 else '', }, lambda name: Font.objects.get(name=name).truetype.path )