From a07174f03214b000dcd01c31b6d397a85b15e82f Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Sun, 24 May 2020 10:10:37 +0200 Subject: [PATCH 1/1] Part on thumbnail. --- src/archive/models.py | 10 +++++++--- src/youtube/models.py | 1 + src/youtube/thumbnail.py | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/archive/models.py b/src/archive/models.py index 4ddfe69..a4420a9 100644 --- a/src/archive/models.py +++ b/src/archive/models.py @@ -132,8 +132,11 @@ class Audiobook(models.Model): if self.translator: title += ' (tłum. %s)' % self.translator - copyright = "%s %s. Licensed to the public under %s verify at %s" % ( - self.date, ORGANIZATION, self.license.uri, self.url) + copyright = "%s %s." % ( + self.date, ORGANIZATION) + if self.license: + copyright += " Licensed to the public under %s verify at %s" % ( + self.license.uri, self.url) comment = "\n".join(( self.project.get_description(), @@ -151,11 +154,12 @@ class Audiobook(models.Model): 'date': self.date, 'genre': 'Speech', 'language': 'pol', - 'license': self.license.uri, 'organization': ORGANIZATION, 'title': title, 'project': self.project.name, } + if self.license: + tags['license'] = self.license.uri if self.project.sponsors: tags['funded_by'] = self.project.sponsors diff --git a/src/youtube/models.py b/src/youtube/models.py index 39a1d2d..43db3b0 100644 --- a/src/youtube/models.py +++ b/src/youtube/models.py @@ -189,6 +189,7 @@ class YouTube(models.Model): { "author": ', '.join((a['name'] for a in audiobook.book['authors'])), "title": audiobook.book['title'], + "part": audiobook.part_name, }, lambda name: Font.objects.get(name=name).truetype.path ) diff --git a/src/youtube/thumbnail.py b/src/youtube/thumbnail.py index 745894b..42e8070 100644 --- a/src/youtube/thumbnail.py +++ b/src/youtube/thumbnail.py @@ -44,6 +44,8 @@ def draw_version(img, d, context, get_font_path): if item.get('vskip'): cursor += item['vskip'] text = item['text'].format(**context) + if not text: + continue if item.get('uppercase'): text = text.upper() font = ImageFont.truetype(get_font_path(item['font-family']), item['font-size']) -- 2.20.1