Skip to content
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

Output URNs for hrefs in findaway manfiests #1740

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions api/web_publication_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,21 @@ def __init__(
# Add the SpineItems as reading order items. None of them will
# have working 'href' fields -- it's just to give the client a
# picture of the structure of the timeline.
# For the href we return a URN that includes the part and sequence
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Might be worthwhile to remove the second sentence of the previous paragraph.

# numbers, these URNs are not expected to be resolved, but the client
# can use them to identify the reading order items for bookmarks etc.
part_key = "findaway:part"
sequence_key = "findaway:sequence"
total_duration = 0
spine_items.sort(key=SpineItem.sort_key)
for item in spine_items:
kwargs = {part_key: item.part, sequence_key: item.sequence}
self.add_reading_order(
href=None,
href=f"urn:org.thepalaceproject:findaway:{fulfillmentId}:{item.part}:{item.sequence}",
title=item.title,
duration=item.duration,
type=item.media_type,
**kwargs
**kwargs,
)
total_duration += item.duration

Expand Down
16 changes: 11 additions & 5 deletions tests/api/test_bibliotheca.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,8 @@ def test_findaway_license_to_webpub_manifest(
assert "abcdef01234789abcdef0123" == encrypted["findaway:checkoutId"]
assert "1234567890987654321ababa" == encrypted["findaway:licenseId"]
assert "3M" == encrypted["findaway:accountId"]
assert "123456" == encrypted["findaway:fulfillmentId"]
fullfillment_id = encrypted["findaway:fulfillmentId"]
assert "123456" == fullfillment_id
assert (
"aaaaaaaa-4444-cccc-dddd-666666666666" == encrypted["findaway:sessionKey"]
)
Expand All @@ -684,18 +685,23 @@ def test_findaway_license_to_webpub_manifest(
assert 16.201 == first["duration"]
assert "Track 1" == first["title"]

# There is no 'href' value for the readingOrder items because the
# The 'href' value for the readingOrder is a URN because the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: This first paragraph could be taken to imply that the URN is used by the Findaway SDK.

Possible rephrasing:

The 'href' value for the readingOrder is a URN. We do not use it to retrieve files, since that must be done through the Findaway SDK.

# files must be obtained through the Findaway SDK rather than
# through regular HTTP requests.
#
# Since this is a relatively small book, it only has one part,
# part #0. Within that part, the items have been sorted by
# their sequence.
for i, item in enumerate(reading_order):
assert None == item.get("href", None)
assert Representation.MP3_MEDIA_TYPE == item["type"]
assert 0 == item["findaway:part"]
assert i + 1 == item["findaway:sequence"]
part = item["findaway:part"]
assert 0 == part
sequence = item["findaway:sequence"]
assert i + 1 == sequence
assert (
f"urn:org.thepalaceproject:findaway:{fullfillment_id}:{part}:{sequence}"
== item["href"]
)

# The total duration, in seconds, has been added to metadata.
assert 28371 == int(metadata["duration"])
Expand Down