New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audiobook play time #2551
base: main
Are you sure you want to change the base?
Audiobook play time #2551
Changes from all commits
bfa64a9
bee0f31
2cfbfe2
0dbfff3
647b3c6
9f7d520
54a7931
d10abf4
9925df1
92c07f4
c0eb7d4
4cfaba0
791b65c
7e37086
b550693
bf32945
6fa56dc
b331271
88ade64
024aeb9
9c8f484
65448ce
6008f1f
bcedca5
6c0a329
e2b6efd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.20 on 2023-08-01 13:00 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("bookwyrm", "0179_populate_sort_title"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="edition", | ||
name="audiobook_play_time", | ||
field=models.DurationField(blank=True, null=True), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{% spaceless %} | ||
|
||
{% load i18n %} | ||
{% load book_display_tags %} | ||
|
||
{% firstof book.physical_format_detail book.get_physical_format_display as format %} | ||
{% firstof book.physical_format book.physical_format_detail as format_property %} | ||
{% with pages=book.pages %} | ||
{% if format or pages %} | ||
|
||
{% if format_property %} | ||
<meta itemprop="bookFormat" content="{{ format_property }}"> | ||
{% if book.physical_format == "AudiobookFormat" and book.audiobook_play_time %} | ||
<meta itemprop="timeRequired" content="{{ book.audiobook_play_time|iso_duration }}"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I tested this, it looks like this line was passing in a string-ified version of the duration (for the arbitrary numbers I tried, |
||
{% endif %} | ||
{% endif %} | ||
|
||
{% if pages %} | ||
<meta itemprop="numberOfPages" content="{{ pages }}"> | ||
{% endif %} | ||
|
||
<p> | ||
{% if format and not pages %} | ||
mouse-reeve marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{{ format }} | ||
{% if book.physical_format == "AudiobookFormat" and book.audiobook_play_time %} | ||
<br /> | ||
{% trans "Play time:" %} | ||
{{ book.audiobook_play_time|localized_duration }} | ||
{% endif %} | ||
{% elif format and pages %} | ||
{% blocktrans %}{{ format }}, {{ pages }} pages{% endblocktrans %} | ||
{% elif pages %} | ||
{% blocktrans %}{{ pages }} pages{% endblocktrans %} | ||
{% endif %} | ||
</p> | ||
{% endif %} | ||
{% endwith %} | ||
|
||
{% endspaceless %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is calling a standard Django model field, rather than a custom BookWyrm activitypub model field, it's not going to be serialized in ActivityPub. To fix this, there needs to be a subclass of
DurationField
in https://github.com/bookwyrm-social/bookwyrm/blob/main/bookwyrm/models/fields.py#L528 -- that code will handle parsing the string version of the play time into a DurationField.I know this is kind of murky depths of how the activitypub implementation works --is that something you want to do, and if so does that give you enough of an idea of how to proceed? If you'd rather not, I can go ahead and make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joachimesque Have you seen this?