From 64e7fba8e062e2d5b56628ac6493031372c9d583 Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Wed, 20 Mar 2024 14:20:29 -0300 Subject: [PATCH 1/3] Add urls to findaway manifests --- api/web_publication_manifest.py | 4 ++-- tests/api/test_bibliotheca.py | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/api/web_publication_manifest.py b/api/web_publication_manifest.py index ca86751ea2..5ccf817a11 100644 --- a/api/web_publication_manifest.py +++ b/api/web_publication_manifest.py @@ -118,11 +118,11 @@ def __init__( 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:{item.part}:{item.sequence}", title=item.title, duration=item.duration, type=item.media_type, - **kwargs + **kwargs, ) total_duration += item.duration diff --git a/tests/api/test_bibliotheca.py b/tests/api/test_bibliotheca.py index 2c41d0112e..e9f3d9df70 100644 --- a/tests/api/test_bibliotheca.py +++ b/tests/api/test_bibliotheca.py @@ -692,10 +692,14 @@ def test_findaway_license_to_webpub_manifest( # 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:{part}:{sequence}" == item["href"] + ) # The total duration, in seconds, has been added to metadata. assert 28371 == int(metadata["duration"]) From 0fb44a8edec5fc5bab01e14d8ccf487bbd227cc1 Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Wed, 20 Mar 2024 14:23:47 -0300 Subject: [PATCH 2/3] Better comments --- api/web_publication_manifest.py | 3 +++ tests/api/test_bibliotheca.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/web_publication_manifest.py b/api/web_publication_manifest.py index 5ccf817a11..676ad61863 100644 --- a/api/web_publication_manifest.py +++ b/api/web_publication_manifest.py @@ -111,6 +111,9 @@ 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 + # 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 diff --git a/tests/api/test_bibliotheca.py b/tests/api/test_bibliotheca.py index e9f3d9df70..4781b7e9bc 100644 --- a/tests/api/test_bibliotheca.py +++ b/tests/api/test_bibliotheca.py @@ -684,7 +684,7 @@ 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 # files must be obtained through the Findaway SDK rather than # through regular HTTP requests. # From 7a650681237f13179b5f53afeeed617c7fb221d2 Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Wed, 20 Mar 2024 14:36:10 -0300 Subject: [PATCH 3/3] Make the urns unique --- api/web_publication_manifest.py | 2 +- tests/api/test_bibliotheca.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/web_publication_manifest.py b/api/web_publication_manifest.py index 676ad61863..19829307d1 100644 --- a/api/web_publication_manifest.py +++ b/api/web_publication_manifest.py @@ -121,7 +121,7 @@ def __init__( for item in spine_items: kwargs = {part_key: item.part, sequence_key: item.sequence} self.add_reading_order( - href=f"urn:org.thepalaceproject:findaway:{item.part}:{item.sequence}", + href=f"urn:org.thepalaceproject:findaway:{fulfillmentId}:{item.part}:{item.sequence}", title=item.title, duration=item.duration, type=item.media_type, diff --git a/tests/api/test_bibliotheca.py b/tests/api/test_bibliotheca.py index 4781b7e9bc..5434a11fbe 100644 --- a/tests/api/test_bibliotheca.py +++ b/tests/api/test_bibliotheca.py @@ -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"] ) @@ -698,7 +699,8 @@ def test_findaway_license_to_webpub_manifest( sequence = item["findaway:sequence"] assert i + 1 == sequence assert ( - f"urn:org.thepalaceproject:findaway:{part}:{sequence}" == item["href"] + f"urn:org.thepalaceproject:findaway:{fullfillment_id}:{part}:{sequence}" + == item["href"] ) # The total duration, in seconds, has been added to metadata.