+ @property
+ def url(self):
+ return f'https://wolnelektury.pl/katalog/lektura/{self.slug}/'
+
+ @property
+ def parts_count(self):
+ return type(self).objects.filter(slug=self.slug).count()
+
+ @property
+ def youtube_volume_count(self):
+ total = 0
+ prev_volume = None
+ for a in type(self).objects.filter(slug=self.slug).order_by("index"):
+ if not a.youtube_volume or a.youtube_volume != prev_volume:
+ total += 1
+ prev_volume = a.youtube_volume
+ return total
+
+ @property
+ def youtube_volume_index(self):
+ index = 0
+ prev_volume = None
+ for a in type(self).objects.filter(slug=self.slug, index__lte=self.index).order_by("index"):
+ if not a.youtube_volume or a.youtube_volume != prev_volume:
+ index += 1
+ prev_volume = a.youtube_volume
+ return index
+
+ @property
+ def is_youtube_publishable(self):
+ return (
+ not self.youtube_volume
+ or not type(self)
+ .objects.filter(youtube_volume=self.youtube_volume, index__lt=self.index)
+ .exists()
+ )
+
+ def get_mp3_tags(self): return json.loads(self.mp3_tags) if self.mp3_tags else None
+ def get_ogg_tags(self): return json.loads(self.ogg_tags) if self.ogg_tags else None
+ def get_mp3_published_tags(self): return json.loads(self.mp3_published_tags) if self.mp3_published_tags else None
+ def get_ogg_published_tags_tags(self): return json.loads(self.ogg_published_tags) if self.ogg_published_tags else None
+ def set_mp3_tags(self, tags): self.mp3_tags = json.dumps(tags)
+ def set_ogg_tags(self, tags): self.ogg_tags = json.dumps(tags)
+