-i https://py.mdrn.pl:8443/simple
django>=1.11,<2.0
-jsonfield==2.0.2
django-cas==2.1.1.1
-django-bootstrap4
+django-bootstrap4==0.0.7
celery[redis]==4.2
kombu
redis
vine
-mutagen
+mutagen==1.42.0
requests
requests-oauthlib
from django.db import models, migrations
import archive.utils
-import jsonfield.fields
import archive.models
('modified', models.DateTimeField(null=True, editable=False)),
('mp3_status', models.SmallIntegerField(null=True, editable=False, choices=[(1, 'Waiting'), (2, 'Encoding'), (3, 'Tagging'), (4, 'Sending')])),
('mp3_task', models.CharField(max_length=64, null=True, editable=False)),
- ('mp3_tags', jsonfield.fields.JSONField(null=True, editable=False)),
+ ('mp3_tags', models.TextField(null=True, editable=False)),
('mp3_file', models.FileField(storage=archive.utils.OverwriteStorage(), upload_to=b'archive/final', null=True, editable=False)),
- ('mp3_published_tags', jsonfield.fields.JSONField(null=True, editable=False)),
+ ('mp3_published_tags', models.TextField(null=True, editable=False)),
('mp3_published', models.DateTimeField(null=True, editable=False)),
('ogg_status', models.SmallIntegerField(null=True, editable=False, choices=[(1, 'Waiting'), (2, 'Encoding'), (3, 'Tagging'), (4, 'Sending')])),
('ogg_task', models.CharField(max_length=64, null=True, editable=False)),
- ('ogg_tags', jsonfield.fields.JSONField(null=True, editable=False)),
+ ('ogg_tags', models.TextField(null=True, editable=False)),
('ogg_file', models.FileField(storage=archive.utils.OverwriteStorage(), upload_to=b'archive/final', null=True, editable=False)),
- ('ogg_published_tags', jsonfield.fields.JSONField(null=True, editable=False)),
+ ('ogg_published_tags', models.TextField(null=True, editable=False)),
('ogg_published', models.DateTimeField(null=True, editable=False)),
],
options={
from django.db import models
from time import sleep
-from jsonfield.fields import JSONField
from django.utils.encoding import force_bytes
from django.utils.translation import ugettext_lazy as _
from archive.constants import status
# publishing process
mp3_status = models.SmallIntegerField(null=True, editable=False, choices=status.choices)
mp3_task = models.CharField(max_length=64, null=True, editable=False)
- mp3_tags = JSONField(null=True, editable=False)
+ mp3_tags = models.TextField(null=True, editable=False)
mp3_file = models.FileField(null=True, upload_to='archive/final', storage=OverwriteStorage(), editable=False)
- mp3_published_tags = JSONField(null=True, editable=False)
+ mp3_published_tags = models.TextField(null=True, editable=False)
mp3_published = models.DateTimeField(null=True, editable=False)
ogg_status = models.SmallIntegerField(null=True, editable=False, choices=status.choices)
ogg_task = models.CharField(max_length=64, null=True, editable=False)
- ogg_tags = JSONField(null=True, editable=False)
+ ogg_tags = models.TextField(null=True, editable=False)
ogg_file = models.FileField(null=True, upload_to='archive/final', storage=OverwriteStorage(), editable=False)
- ogg_published_tags = JSONField(null=True, editable=False)
+ ogg_published_tags = models.TextField(null=True, editable=False)
ogg_published = models.DateTimeField(null=True, editable=False)
-
class Meta:
verbose_name = _("audiobook")
verbose_name_plural = _("audiobooks")
def __unicode__(self):
return self.title
+ 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)
+
def published(self):
return self.mp3_published and self.ogg_published
@classmethod
def set_tags(cls, audiobook, file_name):
- tags = getattr(audiobook, "%s_tags" % cls.ext)['tags']
+ tags = getattr(audiobook, "get_%s_tags" % cls.ext)()['tags']
if not tags.get('flac_sha1'):
tags['flac_sha1'] = audiobook.get_source_sha1()
audio = File(file_name)
@classmethod
def put(cls, user, audiobook, path):
- tags = getattr(audiobook, "%s_tags" % cls.ext)
+ tags = getattr(audiobook, "get_%s_tags" % cls.ext)()
data = {
'book': tags['url'],
'type': cls.ext,
@classmethod
def set_tags(cls, audiobook, file_name):
- mp3_tags = audiobook.mp3_tags['tags']
+ mp3_tags = audiobook.get_mp3_tags()['tags']
if not mp3_tags.get('flac_sha1'):
mp3_tags['flac_sha1'] = audiobook.get_source_sha1()
audio = id3.ID3(file_name)
<hr/>
<h2>MP3</h2>
- {% tags_table audiobook.mp3_tags.tags %}
+ {% tags_table audiobook.get_mp3_tags.tags %}
<p>Status: <b>{{ audiobook.get_mp3_status_display }}</b></p>
{% endif %}
<hr/>
<h2>Ogg Vorbis</h2>
- {% tags_table audiobook.ogg_tags.tags %}
+ {% tags_table audiobook.get_ogg_tags.tags %}
<p>Status: <b>{{ audiobook.get_ogg_status_display }}</b></p>
{% endif %}
<p><a href="{% url 'download' audiobook.id 'mp3' %}">{% trans "Download MP3 file." %}</a></p>
{% if audiobook.mp3_published %}
<p>{% trans "Published:" %} {{ audiobook.mp3_published }}</a></p>
- {% if audiobook.mp3_published_tags.tags %}
- {% tags_table audiobook.mp3_published_tags.tags %}
+ {% if audiobook.get_mp3_published_tags.tags %}
+ {% tags_table audiobook.get_mp3_published_tags.tags %}
{% endif %}
{% else %}
<p>{% trans "Not published yet." %}</p>
<p><a href="{% url 'download' audiobook.id 'ogg' %}">{% trans "Download Ogg Vorbis file." %}</a></p>
{% if audiobook.ogg_published %}
<p>{% trans "Published:" %} {{ audiobook.ogg_published }}</a></p>
- {% if audiobook.ogg_published_tags.tags %}
- {% tags_table audiobook.ogg_published_tags.tags %}
+ {% if audiobook.get_ogg_published_tags.tags %}
+ {% tags_table audiobook.get_ogg_published_tags.tags %}
{% endif %}
{% else %}
<p>{% trans "Not published yet." %}</p>
'url': audiobook.url,
'tags': audiobook.new_publish_tags(),
}
- audiobook.mp3_tags = tags
- audiobook.ogg_tags = tags
+ audiobook.set_mp3_tags(tags)
+ audiobook.set_ogg_tags(tags)
audiobook.mp3_status = audiobook.ogg_status = status.WAITING
audiobook.save()
# isn't there a race here?