fnp
/
audio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Flatten the post data.
[audio.git]
/
src
/
youtube
/
models.py
diff --git
a/src/youtube/models.py
b/src/youtube/models.py
index
356e335
..
32d5f04
100644
(file)
--- a/
src/youtube/models.py
+++ b/
src/youtube/models.py
@@
-24,6
+24,7
@@
YOUTUBE_TITLE_LIMIT = 100
class YouTube(models.Model):
class YouTube(models.Model):
+ name = models.CharField(max_length=255)
title_template = models.CharField(max_length=1024, blank=True)
description_template = models.TextField(blank=True)
category = models.IntegerField(null=True, blank=True, choices=[
title_template = models.CharField(max_length=1024, blank=True)
description_template = models.TextField(blank=True)
category = models.IntegerField(null=True, blank=True, choices=[
@@
-44,6
+45,9
@@
class YouTube(models.Model):
verbose_name = _("YouTube configuration")
verbose_name_plural = _("YouTube configurations")
verbose_name = _("YouTube configuration")
verbose_name_plural = _("YouTube configurations")
+ def __str__(self):
+ return self.name
+
def get_context(self, audiobook):
return Context(dict(
audiobook=audiobook,
def get_context(self, audiobook):
return Context(dict(
audiobook=audiobook,
@@
-212,6
+216,7
@@
class Font(models.Model):
class ThumbnailTemplate(models.Model):
class ThumbnailTemplate(models.Model):
+ youtube = models.ForeignKey(YouTube, models.CASCADE)
order = models.SmallIntegerField()
is_active = models.BooleanField()
background = models.FileField(upload_to='youtube/thumbnail')
order = models.SmallIntegerField()
is_active = models.BooleanField()
background = models.FileField(upload_to='youtube/thumbnail')
@@
-227,12
+232,18
@@
class ThumbnailTemplate(models.Model):
def generate(self, audiobook):
try:
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'])),
img = create_thumbnail(
self.background.path,
self.definition,
{
"author": ', '.join((a['name'] for a in audiobook.book['authors'])),
- "title":
audiobook.book['title']
,
+ "title":
title
,
"part": (audiobook.youtube_volume or audiobook.part_name).strip(),
},
lambda name: Font.objects.get(name=name).truetype.path
"part": (audiobook.youtube_volume or audiobook.part_name).strip(),
},
lambda name: Font.objects.get(name=name).truetype.path